I am trying to do login test by phpunit in laravel. I have 5.5 so visit method is not supported. Here is what I am doing
public function testLoginPost(){
Session::start();
$response = $this->call('POST', 'login', [
    'email' => 'sokhter@yahoo.com',
    'password' => '123456',
    '_token' => csrf_token()
]);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('auth.login', $response->original->name());}
```
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.
```
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire