Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\Display;
|
|
use Tests\TestCase;
|
|
|
|
class DisplayTest extends TestCase
|
|
{
|
|
public function test_country_code_accepts_alpha_3_alpha_2_and_names(): void
|
|
{
|
|
$display = new Display;
|
|
|
|
$this->assertSame('GB', $display->countryCode(['CountryIsoCode' => 'GBR']));
|
|
$this->assertSame('DE', $display->countryCode(['CountryIsoCode' => 'de']));
|
|
$this->assertSame('GB', $display->countryCode(['Country' => 'United Kingdom']));
|
|
$this->assertNull($display->countryCode(['CountryIsoCode' => 'ZZZZ']));
|
|
$this->assertNull($display->countryCode([]));
|
|
}
|
|
|
|
public function test_flag_renders_image_or_dash(): void
|
|
{
|
|
$display = new Display;
|
|
|
|
$this->assertStringContainsString('flagcdn.com/w40/fr.png', (string) $display->flag(['CountryIsoCode' => 'FRA']));
|
|
$this->assertStringContainsString('—', (string) $display->flag([]));
|
|
}
|
|
|
|
public function test_date_times_are_readable_and_drop_midnight(): void
|
|
{
|
|
$display = new Display;
|
|
|
|
$this->assertSame('Thu 8 Oct 2026', $display->dateTime('2026-10-08T00:00:00'));
|
|
$this->assertSame('Thu 8 Oct 2026, 14:30', $display->dateTime('2026-10-08T14:30:00'));
|
|
$this->assertSame('—', $display->dateTime(null));
|
|
$this->assertSame('not a date', $display->dateTime('not a date'));
|
|
}
|
|
}
|