Files
InvoiceShelf/tests/Unit/AddressCountryLocalizationTest.php
T
Darko Gjorgjijoski 5ef7804e60 refactor: adopt modular domain architecture (#747)
* refactor: stabilize model identities for domain migration

* refactor: extract module platform context

* refactor: assign models to domain contexts

* refactor: extract ai platform context

* refactor: extract storage platform context

* refactor: extract mail platform context

* refactor: extract pdf platform context

* refactor: extract operations platform context

* refactor: move installation into operations platform

* refactor: extract money domain context

* refactor: extract taxation domain context

* refactor: extract catalog domain context

* refactor: extract metadata domain context

* refactor: extract reporting domain context

* refactor: extract purchases domain context

* refactor: extract receivables domain context

* refactor: extract accounts domain context

* refactor: complete reporting statement boundary

* refactor: extract contacts domain context

* refactor: extract sales domain context

* refactor: remove legacy application layers

* fix: migrate legacy bouncer role identities
2026-08-05 17:40:03 +02:00

58 lines
1.6 KiB
PHP

<?php
use App\Domains\Contacts\Models\Address;
use App\Domains\Contacts\Models\Country;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
});
it('returns localized country name for German locale', function () {
App::setLocale('de');
$address = Address::factory()->create([
'country_id' => Country::where('code', 'DE')->first()->id,
]);
expect($address->country_name)->toBe('Deutschland');
});
it('returns localized country name for French locale', function () {
App::setLocale('fr');
$address = Address::factory()->create([
'country_id' => Country::where('code', 'DE')->first()->id,
]);
expect($address->country_name)->toBe('Allemagne');
});
it('returns null when address has no country', function () {
$address = Address::factory()->create([
'country_id' => null,
]);
expect($address->country_name)->toBeNull();
});
it('falls back to database name when intl lookup fails', function () {
App::setLocale('de');
// Create a country with a code that won't be found in ICU data
$country = new Country;
$country->timestamps = false;
$country->code = 'XX';
$country->name = 'Unknown Land';
$country->phonecode = 0;
$country->save();
$address = Address::factory()->create([
'country_id' => $country->id,
]);
expect($address->country_name)->toBe('Unknown Land');
});