Files
monica/tests/Feature/Auth/AuthenticationTest.php
T
2024-04-07 22:37:54 +02:00

51 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature\Auth;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class AuthenticationTest extends TestCase
{
use DatabaseTransactions;
#[Test]
public function login_screen_can_be_rendered()
{
$this->withoutVite();
$response = $this->get('/login');
$response->assertStatus(200);
}
#[Test]
public function users_can_authenticate_using_the_login_screen()
{
$user = User::factory()->create();
$response = $this->post('/login', [
'email' => $user->email,
'password' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect('/vaults');
}
#[Test]
public function users_can_not_authenticate_with_invalid_password()
{
$user = User::factory()->create();
$this->post('/login', [
'email' => $user->email,
'password' => 'wrong-password',
]);
$this->assertGuest();
}
}