From 4c64f49a88a4df6c44124c0ff27eb05b83862fc6 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 25 Jan 2023 12:24:07 +0100 Subject: [PATCH] MDL-76675 date: Only test all TZ names with PHPUNIT_LONGTEST enabled It happens often that some timezone is renamed, split, added to the IANAs list of timezones (that, for PHP is kept updated by the php-timezonedb PECL extension). When the information coming from the extension changes, all the PHPUnit jobs in the world start failing (that's when CIs update their PHP images, when devs update their packages, ...). So, what we are doing here is to move that test that check for every single string existing to be run only when PHPUNIT_LONGTEST is enabled. That way only places running all tests will run that one. And every other run just will skip it. This corresponds to point 1 & 2 of the issue, lower impact in general and, still be able to enable the tests to run. --- lib/tests/date_test.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/tests/date_test.php b/lib/tests/date_test.php index 3cdaf211621a2..27ac4b6077c3f 100644 --- a/lib/tests/date_test.php +++ b/lib/tests/date_test.php @@ -166,7 +166,18 @@ public function test_php_gmt_offsets() { } } - public function test_timezone_lang_strings() { + /** + * We are only checking lang strings existence here, not code. + * + * @coversNothing + */ + public function test_timezone_all_lang_strings() { + // We only run this test when PHPUNIT_LONGTEST is enabled, test_get_localised_timezone() + // is already checking the names of a few, hopefully stable enough to be run always. + if (!PHPUNIT_LONGTEST) { + $this->markTestSkipped('PHPUNIT_LONGTEST is not defined'); + } + $phpzones = DateTimeZone::listIdentifiers(); $manager = get_string_manager(); foreach ($phpzones as $tz) { @@ -183,6 +194,12 @@ public function test_get_localised_timezone() { $result = core_date::get_localised_timezone('Pacific/Auckland'); $this->assertSame('Pacific/Auckland', $result); + $result = core_date::get_localised_timezone('Europe/Madrid'); + $this->assertSame('Europe/Madrid', $result); + + $result = core_date::get_localised_timezone('America/New_York'); + $this->assertSame('America/New_York', $result); + $result = core_date::get_localised_timezone('99'); $this->assertSame('Server timezone (Pacific/Auckland)', $result);