Optimierung 5.3 (Teil 1): Contact::displayName()
Anzeigename eines Kontakts (Vor-/Nachname mit Fallback) als Model-Methode. Ersetzt die identische Inline-Logik an 6 eindeutigen Relation-$contact-Stellen (Admin: Benutzer-/PM-/Firmen-Detail; Kunde: Press-Kit-/PM-Detail). Bewusst noch offen: Select-/toBase-Varianten ($contactOption/$contactResult/ $lookupContact, stdClass-Risiko) sowie web/release-detail (User-Frontend). Test: ContactDisplayNameTest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6bf6a091d3
commit
178adb00e2
8 changed files with 38 additions and 6 deletions
21
tests/Feature/ContactDisplayNameTest.php
Normal file
21
tests/Feature/ContactDisplayNameTest.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Contact;
|
||||
|
||||
test('displayName joins first and last name', function () {
|
||||
$contact = Contact::factory()->make(['first_name' => 'Erika', 'last_name' => 'Mustermann']);
|
||||
|
||||
expect($contact->displayName())->toBe('Erika Mustermann');
|
||||
});
|
||||
|
||||
test('displayName trims a missing part', function () {
|
||||
$contact = Contact::factory()->make(['first_name' => null, 'last_name' => 'Mustermann']);
|
||||
|
||||
expect($contact->displayName())->toBe('Mustermann');
|
||||
});
|
||||
|
||||
test('displayName falls back when both names are empty', function () {
|
||||
$contact = Contact::factory()->make(['first_name' => null, 'last_name' => null]);
|
||||
|
||||
expect($contact->displayName())->toBe(__('Kontakt ohne Name'));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue