Added logout test
This commit is contained in:
parent
5af536273e
commit
00ae95e965
1 changed files with 28 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Tests\Feature;
|
||||
namespace Tests\Feature\Auth;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -102,4 +102,31 @@ class LoginControllerTest extends TestCase
|
|||
$redirect = $this->submitForm($form)->getHeaderLine('Location');
|
||||
$this->assertSame(route('profile'), $redirect);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_logout_the_user()
|
||||
{
|
||||
$this->createAdminUser();
|
||||
|
||||
$response = $this->get(route('login.show'));
|
||||
$form = $this->getCrawler($response)
|
||||
->selectButton('Login')
|
||||
->form([
|
||||
'username' => 'admin@example.com',
|
||||
'password' => 'admin',
|
||||
'remember' => 'on',
|
||||
], 'POST');
|
||||
|
||||
$this->submitForm($form);
|
||||
$this->assertSame(200, $response->getStatusCode());
|
||||
|
||||
$response = $this->post(route('logout'));
|
||||
$this->assertSame(302, $response->getStatusCode());
|
||||
|
||||
$response = $this->get(route('home'));
|
||||
$this->assertSame(302, $response->getStatusCode());
|
||||
$this->assertSame(route('login.show'), $response->getHeaderLine('Location'));
|
||||
|
||||
$this->assertFalse($this->app->getContainer()->get('session')->get('logged'));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue