initial
All checks were successful
linter / quality (push) Successful in 1m37s
tests / ci (8.4) (push) Successful in 2m13s
tests / ci (8.5) (push) Successful in 1m25s

This commit is contained in:
Tim Basten
2026-03-05 11:41:39 +08:00
commit 564f78dcda
182 changed files with 21145 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace Tests\Feature\Auth;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LoginTest extends TestCase
{
use RefreshDatabase;
public function test_login_page_is_accessible(): void
{
$response = $this->get('/login');
$response->assertStatus(200);
}
public function test_user_is_redirected_to_login_when_unauthenticated(): void
{
$response = $this->get('/dashboard');
$response->assertRedirect('/login');
}
public function test_authenticated_user_is_redirected_away_from_login(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/login');
$response->assertRedirect('/dashboard');
}
public function test_user_can_logout(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/logout');
$response->assertRedirect('/login');
$this->assertGuest();
}
public function test_login_fails_with_invalid_credentials(): void
{
User::factory()->create(['username' => 'testuser']);
$response = $this->post('/login', [
'username' => 'testuser',
'password' => 'wrongpassword',
]);
$this->assertGuest();
}
}