This commit is contained in:
Hermes
2026-06-04 17:23:49 +00:00
parent c737312ada
commit 7dd8023222
4 changed files with 315 additions and 118 deletions

View File

@@ -24,6 +24,7 @@ final class LocaleSwitcherTest extends TestCase
{
$html = (new LocaleSwitcher('en', '/'))->render();
self::assertStringContainsString('<ul class="locale-switcher"', $html);
self::assertStringContainsString('<details class="locale-switcher-mobile"', $html);
// The 3 inactive locales render as <a hreflang="..">. The active
// locale renders as <span lang=".."> (no hreflang). Together all
@@ -34,7 +35,10 @@ final class LocaleSwitcherTest extends TestCase
"locale '$code' is missing from switcher",
);
}
self::assertSame(4, substr_count($html, 'class="flag"'), 'expected 4 flag SVGs');
// Both the desktop list and the mobile dropdown render a flag per locale
self::assertSame(4, substr_count($html, 'class="locale-switcher__option'), 'expected 4 desktop options');
self::assertSame(4, substr_count($html, 'class="locale-switcher-mobile__option'), 'expected 4 mobile options');
self::assertSame(9, substr_count($html, 'class="flag"'), 'expected 9 flag SVGs (4 desktop + 4 mobile menu + 1 mobile trigger)');
}
#[Test]