【发布时间】:2017-08-19 21:15:53
【问题描述】:
如何测试验证错误中抛出的php单元中的特定验证错误? 使用下面的代码,我们可以检查会话是否有错误,但不是确切的错误
$this->assertSessionHasErrors();
【问题讨论】:
-
> 我正在使用 phpunit 7.5 和 Lumen 5.8 - 当对您的
Request或规则使用单元测试时,您可以执行$this->expectException$this->expectException('Illuminate\Validation\ValidationException');和$this->expectExceptionMessage = "The name field is required";- 另请参阅 stackoverflow.com/questions/18647836/…跨度> -
注意:异常不包含验证信息!它只是说
The given data was invalid
标签: php unit-testing laravel-5 phpunit tdd