diff --git a/src/Symfony/Component/Intl/Tests/TimezonesTest.php b/src/Symfony/Component/Intl/Tests/TimezonesTest.php index cc000c1482..ef922e1de8 100644 --- a/src/Symfony/Component/Intl/Tests/TimezonesTest.php +++ b/src/Symfony/Component/Intl/Tests/TimezonesTest.php @@ -603,6 +603,15 @@ class TimezonesTest extends ResourceBundleTestCase Timezones::forCountryCode('foobar'); } + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + * @expectedExceptionMessage Country codes must be in uppercase, but "nl" was passed. Try with "NL" country code instead. + */ + public function testForCountryCodeWithWrongCountryCode() + { + Timezones::forCountryCode('nl'); + } + /** * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException */ diff --git a/src/Symfony/Component/Intl/Timezones.php b/src/Symfony/Component/Intl/Timezones.php index 94afc71860..dd72d35925 100644 --- a/src/Symfony/Component/Intl/Timezones.php +++ b/src/Symfony/Component/Intl/Timezones.php @@ -109,6 +109,10 @@ final class Timezones extends ResourceBundle return []; } + if (Countries::exists(strtoupper($country))) { + throw new MissingResourceException(sprintf('Country codes must be in uppercase, but "%s" was passed. Try with "%s" country code instead.', $country, strtoupper($country))); + } + throw $e; } }