Files
vkv/tests/Feature/Auth/LoginControllerTest.php
Zdeněk Burda 41e3ce6f25 Initial commit
2026-01-09 21:26:40 +01:00

44 lines
1.0 KiB
PHP

<?php
namespace Tests\Feature\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LoginControllerTest extends TestCase
{
use RefreshDatabase;
public function test_login_success_returns_user(): void
{
$user = $this->createUser([
'password' => 'demodemo',
]);
$response = $this->withSession([])->postJson('/api/login', [
'email' => $user->email,
'password' => 'demodemo',
]);
$response->assertStatus(200)
->assertJsonFragment([
'id' => $user->id,
'email' => $user->email,
]);
}
public function test_login_inactive_user_fails(): void
{
$user = $this->createInactiveUser([
'password' => 'demodemo',
]);
$response = $this->withSession([])->postJson('/api/login', [
'email' => $user->email,
'password' => 'demodemo',
]);
$response->assertStatus(422);
}
}