From d74763310045ccf2bf485549f8ba942184e31087 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 4 Nov 2024 09:22:19 +0100 Subject: [PATCH] skip tests requiring the intl extension if it's not installed --- Tests/CountriesTest.php | 23 +++++++++++++++++++++++ Tests/CurrenciesTest.php | 17 +++++++++++++++++ Tests/LanguagesTest.php | 25 +++++++++++++++++++++++++ Tests/LocalesTest.php | 17 +++++++++++++++++ Tests/ScriptsTest.php | 17 +++++++++++++++++ Tests/TimezonesTest.php | 23 +++++++++++++++++++++++ 6 files changed, 122 insertions(+) diff --git a/Tests/CountriesTest.php b/Tests/CountriesTest.php index f35932e5..7d698897 100644 --- a/Tests/CountriesTest.php +++ b/Tests/CountriesTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Intl\Countries; use Symfony\Component\Intl\Exception\MissingResourceException; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -535,6 +536,10 @@ public function testGetCountryCodes() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $countries = array_keys(Countries::getNames($displayLocale)); sort($countries); @@ -544,6 +549,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Countries::getNames('de_AT'), Countries::getNames()); @@ -554,6 +561,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -565,6 +576,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Countries::getNames($displayLocale); foreach ($names as $country => $name) { @@ -636,6 +651,10 @@ public function testAlpha3CodeExists() */ public function testGetAlpha3Name($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Countries::getNames($displayLocale); foreach ($names as $alpha2 => $name) { @@ -656,6 +675,10 @@ public function testGetAlpha3NameWithInvalidCountryCode() */ public function testGetAlpha3Names($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Countries::getAlpha3Names($displayLocale); $alpha3Codes = array_keys($names); diff --git a/Tests/CurrenciesTest.php b/Tests/CurrenciesTest.php index 737878bf..da8c99ea 100644 --- a/Tests/CurrenciesTest.php +++ b/Tests/CurrenciesTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Intl\Currencies; use Symfony\Component\Intl\Exception\MissingResourceException; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -600,6 +601,10 @@ public function testGetCurrencyCodes() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Currencies::getNames($displayLocale); $keys = array_keys($names); @@ -618,6 +623,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Currencies::getNames('de_AT'), Currencies::getNames()); @@ -628,6 +635,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -639,6 +650,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $expected = Currencies::getNames($displayLocale); $actual = []; @@ -651,6 +666,8 @@ public function testGetName($displayLocale) public function testGetNameDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $expected = Currencies::getNames('de_AT'); diff --git a/Tests/LanguagesTest.php b/Tests/LanguagesTest.php index ce703b47..c5e5576c 100644 --- a/Tests/LanguagesTest.php +++ b/Tests/LanguagesTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Languages; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -1713,6 +1714,10 @@ public function testGetLanguageCodes() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $languages = array_keys($names = Languages::getNames($displayLocale)); sort($languages); @@ -1730,6 +1735,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Languages::getNames('de_AT'), Languages::getNames()); @@ -1740,6 +1747,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -1751,6 +1762,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Languages::getNames($displayLocale); foreach ($names as $language => $name) { @@ -1767,6 +1782,8 @@ public function testLocalizedGetName() public function testGetNameDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $names = Languages::getNames('de_AT'); @@ -1877,6 +1894,10 @@ public function testAlpha3CodeExists() */ public function testGetAlpha3Name($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Languages::getAlpha3Names($displayLocale); foreach ($names as $language => $name) { @@ -1896,6 +1917,10 @@ public function testGetAlpha3NameWithInvalidLanguageCode() */ public function testGetAlpha3Names($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $languages = array_keys($names = Languages::getAlpha3Names($displayLocale)); sort($languages); diff --git a/Tests/LocalesTest.php b/Tests/LocalesTest.php index 4e331d28..f729eb52 100644 --- a/Tests/LocalesTest.php +++ b/Tests/LocalesTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Locales; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -34,6 +35,10 @@ public function testGetAliases() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $locales = array_keys(Locales::getNames($displayLocale)); sort($locales); @@ -46,6 +51,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Locales::getNames('de_AT'), Locales::getNames()); @@ -56,6 +63,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -67,6 +78,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Locales::getNames($displayLocale); foreach ($names as $locale => $name) { @@ -76,6 +91,8 @@ public function testGetName($displayLocale) public function testGetNameDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $names = Locales::getNames('de_AT'); diff --git a/Tests/ScriptsTest.php b/Tests/ScriptsTest.php index 96ac0f36..20c311ca 100644 --- a/Tests/ScriptsTest.php +++ b/Tests/ScriptsTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Scripts; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -235,6 +236,10 @@ public function testGetScriptCodes() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $scripts = array_keys(Scripts::getNames($displayLocale)); sort($scripts); @@ -247,6 +252,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Scripts::getNames('de_AT'), Scripts::getNames()); @@ -257,6 +264,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -268,6 +279,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Scripts::getNames($displayLocale); foreach ($names as $script => $name) { @@ -277,6 +292,8 @@ public function testGetName($displayLocale) public function testGetNameDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $names = Scripts::getNames('de_AT'); diff --git a/Tests/TimezonesTest.php b/Tests/TimezonesTest.php index b0af8d8b..4edae830 100644 --- a/Tests/TimezonesTest.php +++ b/Tests/TimezonesTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Intl\Countries; use Symfony\Component\Intl\Exception\MissingResourceException; use Symfony\Component\Intl\Timezones; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * @group intl-data @@ -468,6 +469,10 @@ public function testGetIds() */ public function testGetNames($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $zones = array_keys(Timezones::getNames($displayLocale)); sort($zones); @@ -478,6 +483,8 @@ public function testGetNames($displayLocale) public function testGetNamesDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $this->assertSame(Timezones::getNames('de_AT'), Timezones::getNames()); @@ -488,6 +495,10 @@ public function testGetNamesDefaultLocale() */ public function testGetNamesSupportsAliases($alias, $ofLocale) { + if ('en' !== $ofLocale) { + IntlTestHelper::requireFullIntl($this); + } + // Can't use assertSame(), because some aliases contain scripts with // different collation (=order of output) than their aliased locale // e.g. sr_Latn_ME => sr_ME @@ -499,6 +510,10 @@ public function testGetNamesSupportsAliases($alias, $ofLocale) */ public function testGetName($displayLocale) { + if ('en' !== $displayLocale) { + IntlTestHelper::requireFullIntl($this); + } + $names = Timezones::getNames($displayLocale); foreach ($names as $language => $name) { @@ -508,6 +523,8 @@ public function testGetName($displayLocale) public function testGetNameDefaultLocale() { + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('de_AT'); $names = Timezones::getNames('de_AT'); @@ -603,6 +620,12 @@ public function testGetCountryCodeWithUnknownTimezone() */ public function testGetGmtOffsetAvailability(string $timezone) { + try { + new \DateTimeZone($timezone); + } catch (\Exception $e) { + $this->markTestSkipped(sprintf('The timezone "%s" is not available.', $timezone)); + } + // ensure each timezone identifier has a corresponding GMT offset Timezones::getRawOffset($timezone); Timezones::getGmtOffset($timezone);