mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
Install Breeze
This commit is contained in:
parent
337c77f8a2
commit
32d63c09e7
55 changed files with 5782 additions and 88 deletions
72
tests/Feature/Auth/AuthenticationTest.php
Normal file
72
tests/Feature/Auth/AuthenticationTest.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('login screen can be rendered', function () {
|
||||
$response = $this->get('/login');
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertSeeVolt('pages.auth.login');
|
||||
});
|
||||
|
||||
test('users can authenticate using the login screen', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$component = Volt::test('pages.auth.login')
|
||||
->set('form.email', $user->email)
|
||||
->set('form.password', 'password');
|
||||
|
||||
$component->call('login');
|
||||
|
||||
$component
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect(route('dashboard', absolute: false));
|
||||
|
||||
$this->assertAuthenticated();
|
||||
});
|
||||
|
||||
test('users can not authenticate with invalid password', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$component = Volt::test('pages.auth.login')
|
||||
->set('form.email', $user->email)
|
||||
->set('form.password', 'wrong-password');
|
||||
|
||||
$component->call('login');
|
||||
|
||||
$component
|
||||
->assertHasErrors()
|
||||
->assertNoRedirect();
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
test('navigation menu can be rendered', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->get('/dashboard');
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertSeeVolt('layout.navigation');
|
||||
});
|
||||
|
||||
test('users can logout', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$component = Volt::test('layout.navigation');
|
||||
|
||||
$component->call('logout');
|
||||
|
||||
$component
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect('/');
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue