Laravel - PHPUnit简单测试失败

3

我不太明白...首个测试phpunit正常运行。 然后我添加了新的路由和新方法。

Route::get( '/about', 'HomeController@about' );

所以,我更改了ExampleTest内部的行:

public function testBasicExample()
    {
        $response = $this->call('GET', '/about');

        $this->assertEquals(200, $response->getStatusCode());
    }

我遇到了一个错误:

断言失败,302与预期的200不匹配。

我做错了什么?


你的HomeController里有什么?你在那里进行重定向吗? - Laurence
只需 return "Hello" - shock
哦!我的错误。我有一个 $this->middleware('auth'); :D - shock
1个回答

0
public function testBasicExample()
{
    $response = $this->call('GET', '/about')->response;

    $this->assertEquals(200, $response->status());
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接