Skip to content

[Intl] made RegionBundle merge fallback data if using a country-specific locale #8564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getLanguageName($lang, $region = null, $locale = null)
$locale = \Locale::getDefault();
}

if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
if (null === ($languages = $this->readEntry($locale, array('Languages'), true))) {
return null;
}

Expand All @@ -49,7 +49,7 @@ public function getLanguageNames($locale = null)
$locale = \Locale::getDefault();
}

if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
if (null === ($languages = $this->readEntry($locale, array('Languages'), true))) {
return array();
}

Expand Down Expand Up @@ -102,7 +102,7 @@ public function getScriptNames($locale = null)
$locale = \Locale::getDefault();
}

if (null === ($scripts = $this->readEntry($locale, array('Scripts')))) {
if (null === ($scripts = $this->readEntry($locale, array('Scripts'), true))) {
return array();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getCountryName($country, $locale = null)
$locale = \Locale::getDefault();
}

return $this->readEntry($locale, array('Countries', $country));
return $this->readEntry($locale, array('Countries', $country), true);
}

/**
Expand All @@ -39,7 +39,7 @@ public function getCountryNames($locale = null)
$locale = \Locale::getDefault();
}

if (null === ($countries = $this->readEntry($locale, array('Countries')))) {
if (null === ($countries = $this->readEntry($locale, array('Countries'), true))) {
return array();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testGetCountryName()
{
$this->reader->expects($this->once())
->method('readEntry')
->with(self::RES_DIR, 'en', array('Countries', 'AT'))
->with(self::RES_DIR, 'en', array('Countries', 'AT'), true)
->will($this->returnValue('Austria'));

$this->assertSame('Austria', $this->bundle->getCountryName('AT', 'en'));
Expand All @@ -55,7 +55,7 @@ public function testGetCountryNames()

$this->reader->expects($this->once())
->method('readEntry')
->with(self::RES_DIR, 'en', array('Countries'))
->with(self::RES_DIR, 'en', array('Countries'), true)
->will($this->returnValue($sortedCountries));

$this->assertSame($sortedCountries, $this->bundle->getCountryNames('en'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ public function getInvalidCountries()
array('EN'),
);
}

public function testValidateUsingCountrySpecificLocale()
{
\Locale::setDefault('en_GB');
$existingCountry = 'GB';
$this->context->expects($this->never())
->method('addViolation');

$this->validator->validate($existingCountry, new Country());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add some assertion, otherwise this test will be marked as fail when run (phpunit) in strict mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the same apply to all the other test cases in that class currently there (and most of the other tests against validators, for that matter)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stloyd $this->context->expects($this->never()) is an assertion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again forgot something about phpunit 😢

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,16 @@ public function getInvalidLanguages()
array('foobar'),
);
}

public function testValidateUsingCountrySpecificLocale()
{
\Locale::setDefault('fr_FR');
$existingLanguage = 'en';
$this->context->expects($this->never())
->method('addViolation');

$this->validator->validate($existingLanguage, new Language(array(
'message' => 'aMessage'
)));
}
}