Fixes for 2 code quality findings in i18n tests (#3923)

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix failing timezone alias test to match actual validateTimezone behavior

US/Eastern is a legacy tzdata backward-compatibility alias excluded from
DateTimeZone::listIdentifiers(), so validateTimezone() correctly rejects
it. The test asserted the opposite and failed CI.

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
Adam DaleyandCopilot Autofix powered by AI authored and GitHub committed 2026-07-07 01:58:59 +01:00
1 parent 0880c60501
commit 1be5a8e72d
1 file changed
+12
+12
View File
@@ -99,6 +99,14 @@ test('getActiveTimezone ignores an invalid fb_timezone cookie', function (): voi
expect(i18n::getActiveTimezone())->toBe('UTC');
});
test('getActiveTimezone ignores an invalid fb_timezone cookie when explicit arguments are valid', function (): void {
$_COOKIE['fb_timezone'] = 'Definitely/Not_Real';
expect(i18n::getActiveTimezone('America/New_York', 'Asia/Tokyo'))->toBe('America/New_York');
expect(i18n::getActiveTimezone('America/New_York', null))->toBe('America/New_York');
expect(i18n::getActiveTimezone(null, 'Asia/Tokyo'))->toBe('Asia/Tokyo');
});
test('getActiveTimezone falls back to valid fb_timezone cookie when client timezone is invalid', function (): void {
$_COOKIE['fb_timezone'] = 'Europe/Berlin';
@@ -138,6 +146,10 @@ test('validateTimezone returns the value when it is a known IANA identifier', fu
expect(i18n::validateTimezone('UTC'))->toBe('UTC');
});
test('validateTimezone rejects deprecated/alias timezone identifiers not in the canonical IANA list', function (): void {
expect(fn (): ?string => i18n::validateTimezone('US/Eastern'))->toThrow(FOSSBilling\InformationException::class);
});
test('validateTimezone throws InformationException for an unknown identifier', function (): void {
expect(fn (): ?string => i18n::validateTimezone('Mars/Olympus_Mons'))->toThrow(FOSSBilling\InformationException::class);
});