繁体   English   中英

Laravel 5 | PHPUnit测试错误

[英]Laravel 5 | PHPUnit Testing Error

我只是想获取link(Path)的状态码。

[我也使用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

我的测试代码有什么问题...?

最后,我找到了解决方案。

实际上,我的查看文件中存在一些验证错误。

验证$ errors变量最初未定义,因此在PHPUnit测试案例中将其视为错误。

因此它为我返回了500 Internal Server错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM