Cross-cutting migration affecting the entire stack: - Database: 3 migrations splitting name columns with data migration - Models: first_name/last_name on User, Person; contact_first_name/contact_last_name on Company; backward-compatible name accessors - API: all resources return first_name, last_name, full_name; assignablePersons endpoint updated - Requests: validation rules updated for all person/user/company forms - Services: VolunteerRegistrationService, ShiftAssignmentService, InvitationService updated - Frontend: TypeScript types, Zod schemas, all forms split into Voornaam/Achternaam fields - Display: all person/user name references use full_name; initials use first_name[0]+last_name[0] - Tests: all 371 tests passing - Docs: SCHEMA.md and API.md updated Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
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_user_can_login_with_valid_credentials(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->postJson('/api/v1/auth/login', [
|
|
'email' => $user->email,
|
|
'password' => 'password',
|
|
]);
|
|
|
|
$response->assertOk()
|
|
->assertJsonStructure([
|
|
'success',
|
|
'data' => ['user' => ['id', 'first_name', 'last_name', 'full_name', 'email'], 'token'],
|
|
'message',
|
|
])
|
|
->assertJson(['success' => true]);
|
|
}
|
|
|
|
public function test_login_fails_with_invalid_credentials(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->postJson('/api/v1/auth/login', [
|
|
'email' => $user->email,
|
|
'password' => 'wrong-password',
|
|
]);
|
|
|
|
$response->assertUnauthorized();
|
|
}
|
|
|
|
public function test_login_requires_email_and_password(): void
|
|
{
|
|
$response = $this->postJson('/api/v1/auth/login', []);
|
|
|
|
$response->assertUnprocessable()
|
|
->assertJsonValidationErrors(['email', 'password']);
|
|
}
|
|
}
|