diff --git a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php index 1f1a4e567b7a8..dff4c157cda81 100644 --- a/src/Symfony/Component/Intl/Tests/CurrenciesTest.php +++ b/src/Symfony/Component/Intl/Tests/CurrenciesTest.php @@ -772,6 +772,20 @@ public function testForNumericCodeFailsIfInvalidNumericCode($currency) Currencies::forNumericCode($currency); } + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidCurrencyCode() + { + Currencies::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Currencies::exists('EUR')); + $this->assertFalse(Currencies::exists('XXX')); + } + private function getNumericToAlpha3Mapping() { $numericToAlpha3 = []; diff --git a/src/Symfony/Component/Intl/Tests/LanguagesTest.php b/src/Symfony/Component/Intl/Tests/LanguagesTest.php index 6fa059b29445a..74610076ceee9 100644 --- a/src/Symfony/Component/Intl/Tests/LanguagesTest.php +++ b/src/Symfony/Component/Intl/Tests/LanguagesTest.php @@ -915,4 +915,18 @@ public function testGetAlpha3CodeFailsIfNoAlpha3Equivalent($language) { Languages::getAlpha3Code($language); } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidLanguageCode() + { + Languages::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Languages::exists('nl')); + $this->assertFalse(Languages::exists('zxx')); + } } diff --git a/src/Symfony/Component/Intl/Tests/LocalesTest.php b/src/Symfony/Component/Intl/Tests/LocalesTest.php index e7ffbd2ca9a42..18bd2d9ccf8c6 100644 --- a/src/Symfony/Component/Intl/Tests/LocalesTest.php +++ b/src/Symfony/Component/Intl/Tests/LocalesTest.php @@ -84,4 +84,18 @@ public function testGetNameDefaultLocale() $this->assertSame($name, Locales::getName($locale)); } } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidLocale() + { + Locales::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Locales::exists('nl_NL')); + $this->assertFalse(Locales::exists('zxx_ZZ')); + } } diff --git a/src/Symfony/Component/Intl/Tests/RegionsTest.php b/src/Symfony/Component/Intl/Tests/RegionsTest.php index 80d4ca98bf638..a00245a5f5947 100644 --- a/src/Symfony/Component/Intl/Tests/RegionsTest.php +++ b/src/Symfony/Component/Intl/Tests/RegionsTest.php @@ -343,4 +343,18 @@ public function testLocaleAliasesAreLoaded() $this->assertSame($countryNameZhTw, $countryNameHantZhTw, 'zh_TW is an alias to zh_Hant_TW'); $this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh'); } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidRegionCode() + { + Regions::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Regions::exists('NL')); + $this->assertFalse(Regions::exists('ZZ')); + } } diff --git a/src/Symfony/Component/Intl/Tests/ScriptsTest.php b/src/Symfony/Component/Intl/Tests/ScriptsTest.php index 5b404fda85aaa..71ca1a0031374 100644 --- a/src/Symfony/Component/Intl/Tests/ScriptsTest.php +++ b/src/Symfony/Component/Intl/Tests/ScriptsTest.php @@ -274,4 +274,18 @@ public function testGetNameDefaultLocale() $this->assertSame($name, Scripts::getName($script)); } } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidScriptCode() + { + Scripts::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Scripts::exists('Hans')); + $this->assertTrue(Scripts::exists('Zzzz')); + } } diff --git a/src/Symfony/Component/Intl/Tests/TimezonesTest.php b/src/Symfony/Component/Intl/Tests/TimezonesTest.php index 021364b777a81..dd0c7e00f3466 100644 --- a/src/Symfony/Component/Intl/Tests/TimezonesTest.php +++ b/src/Symfony/Component/Intl/Tests/TimezonesTest.php @@ -515,4 +515,18 @@ public function testGetNameDefaultLocale() $this->assertSame($name, Timezones::getName($language)); } } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testGetNameWithInvalidTimezoneId() + { + Timezones::getName('foo'); + } + + public function testExists() + { + $this->assertTrue(Timezones::exists('Europe/Amsterdam')); + $this->assertFalse(Timezones::exists('Etc/Unknown')); + } }