Webiondev123's avatar

login test failed

 public function testLoginPost(){
    Session::start();

    $response = $this->call('POST', 'login', [
        'email' => '[email protected]',
        'password' => '123456',
        '_token' => csrf_token()
    ]);
    $this->assertEquals(200, $response->getStatusCode());
    $this->assertEquals('auth.login', $response->original->name());
}

output

c:\wamp64\www\fundtheneedy\tests\Unit>phpunit Fundtheneedy
PHPUnit 6.5.8 by Sebastian Bergmann and contributors.

.F                                                                  2 / 2 (100%)

Time: 321 ms, Memory: 14.00MB

There was 1 failure:

1) Tests\Unit\Fundtheneedy::testLoginPost
Failed asserting that 302 matches expected 200.

C:\wamp64\www\fundtheneedy\tests\Unit\Fundtheneedy.php:30

FAILURES!
Tests: 2, Assertions: 2, Failures: 1.

0 likes
1 reply
jcphpdev's avatar

A 302 status code is a standard Redirect response code in Laravel. If auth was unsuccessful, the app would redirect back with a 302; or if auth was successful, it might redirect to the intended URL with a 302 code.

Please or to participate in this conversation.