You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
<?php
|
|
|
|
namespace Tests\Feature\Auth;
|
|
|
|
use App\User;
|
|
use Tests\BrowserKitTestCase;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
class UserLoginTest extends BrowserKitTestCase
|
|
{
|
|
use DatabaseMigrations;
|
|
|
|
/** @test */
|
|
public function it_validates_the_login_form()
|
|
{
|
|
$this->visit(route('login'))
|
|
->type('foobar', 'username')
|
|
->type('secret', 'password')
|
|
->press('Login')
|
|
->dontSeeIsAuthenticated()
|
|
->seePageIs(route('login'));
|
|
$this->see(trans('auth.failed'));
|
|
}
|
|
|
|
/** @test */
|
|
public function user_can_login()
|
|
{
|
|
$user = factory(User::class)->create(['password' => '123456']);
|
|
|
|
$this->visit(route('login'));
|
|
$this->type($user->username, 'username');
|
|
$this->type('123456', 'password');
|
|
$this->press('Login');
|
|
|
|
$this->seePageIs(route('home'));
|
|
$this->see($user->name);
|
|
|
|
// $this->dump();
|
|
|
|
$this->press('logout-button');
|
|
$this->seePageIs(route('login'));
|
|
}
|
|
|
|
/** @test */
|
|
public function it_can_logout_of_the_application()
|
|
{
|
|
$user = factory(User::class)->create(['password' => '123456']);
|
|
$this->actingAs($user)
|
|
->visit(route('home'))
|
|
->press('logout-button')
|
|
->seePageis(route('login'))
|
|
->dontSeeIsAuthenticated();
|
|
}
|
|
}
|