Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
1016 B
PHP
35 lines
1016 B
PHP
<?php
|
|
|
|
use App\Models\Client;
|
|
use App\Models\ClientContact;
|
|
|
|
test('primary_contact_email returns principal contact email', function () {
|
|
$client = Client::factory()->create();
|
|
$principal = $client->contacts->firstWhere('is_principal', true);
|
|
|
|
expect($client->primary_contact_email)->toBe($principal->email);
|
|
});
|
|
|
|
test('primary_contact_email falls back to old contact_email column', function () {
|
|
$client = Client::factory()->create([
|
|
'contact_email' => 'fallback@test.com',
|
|
]);
|
|
|
|
// Remove all contacts to force fallback
|
|
$client->contacts()->delete();
|
|
$client->unsetRelation('primaryContact');
|
|
|
|
expect($client->primary_contact_email)->toBe('fallback@test.com');
|
|
});
|
|
|
|
test('primary_contact_email returns null when no contact exists', function () {
|
|
$client = Client::factory()->create([
|
|
'contact_email' => null,
|
|
]);
|
|
|
|
$client->contacts()->delete();
|
|
$client->unsetRelation('primaryContact');
|
|
|
|
expect($client->primary_contact_email)->toBeNull();
|
|
});
|