Fixed the handling of the intl locale when setting the default locale
Calling setDefaultLocale was replacing the intl locale even if the locale was already set in the Request, thus leading to a different value than the request locale.
This commit is contained in:
parent
0247dd5237
commit
8c6b7a4912
@ -1055,7 +1055,11 @@ class Request
|
||||
*/
|
||||
public function setDefaultLocale($locale)
|
||||
{
|
||||
$this->setPhpDefaultLocale($this->defaultLocale = $locale);
|
||||
$this->defaultLocale = $locale;
|
||||
|
||||
if (null === $this->locale) {
|
||||
$this->setPhpDefaultLocale($locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,6 +900,27 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($request->isXmlHttpRequest());
|
||||
}
|
||||
|
||||
public function testIntlLocale()
|
||||
{
|
||||
if (!extension_loaded('intl')) {
|
||||
$this->markTestSkipped('The intl extension is needed to run this test.');
|
||||
}
|
||||
|
||||
$request = new Request();
|
||||
|
||||
$request->setDefaultLocale('fr');
|
||||
$this->assertEquals('fr', $request->getLocale());
|
||||
$this->assertEquals('fr', \Locale::getDefault());
|
||||
|
||||
$request->setLocale('en');
|
||||
$this->assertEquals('en', $request->getLocale());
|
||||
$this->assertEquals('en', \Locale::getDefault());
|
||||
|
||||
$request->setDefaultLocale('de');
|
||||
$this->assertEquals('en', $request->getLocale());
|
||||
$this->assertEquals('en', \Locale::getDefault());
|
||||
}
|
||||
|
||||
public function testGetCharsets()
|
||||
{
|
||||
$request = new Request();
|
||||
|
Reference in New Issue
Block a user