【发布时间】:2016-06-04 18:56:44
【问题描述】:
我只想获取链接的状态码(路径)。
[我也使用 Auth]
我的输入:
public function testPath()
{
$this->withoutMiddleware();
$this->call('GET', '/admin/create');
$this->assertResponseStatus(200);
}
即使我在浏览器上检查了这个,我也得到了正确的响应。 但是在 PHPUnit 测试中,我得到以下错误...
1) ItemsTest::testPath
Expected status code 200, got 500.
Failed asserting that 500 matches expected 200
我的测试代码有什么问题...?
【问题讨论】:
-
尝试
$this->visit('/admin/create');而不是$this->call('GET', '/admin/create'); -
K...那我怎么检查它的状态码....
-
$cont = $this->visit('/admin/create'); $cont->assertResponseOk();我得到同样的错误......
-
你设置好路线了吗?
-
是的......我解决了......问题是由验证错误变量发生......
标签: unit-testing laravel testing phpunit laravel-5.2