Navigation Menu

Skip to content

Commit

Permalink
Fix corrupted global state.
Browse files Browse the repository at this point in the history
On my non en_US machine tests following this would fail as my default
locale of en_CA was picked up.
  • Loading branch information
markstory committed Aug 9, 2014
1 parent 22e551a commit 75207a0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/TestCase/Routing/Filter/LocaleSelectorFilterTest.php
Expand Up @@ -25,14 +25,24 @@
*/
class LocaleSelectorFilterTest extends TestCase {

/**
* setup
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->locale = Locale::getDefault();
}

/**
* Resets the default locale
*
* @return void
*/
public function tearDown() {
parent::tearDown();
Locale::setDefault('');
Locale::setDefault($this->locale);
}

/**
Expand Down Expand Up @@ -67,6 +77,7 @@ public function testSimpleSelection() {
* @return void
*/
public function testWithWhitelist() {
Locale::setDefault('en_US');
$filter = new LocaleSelectorFilter([
'locales' => ['en_CA', 'en_IN', 'es_VE']
]);
Expand All @@ -77,8 +88,8 @@ public function testWithWhitelist() {
]);
$filter->beforeDispatch(new Event('name', null, ['request' => $request]));
$this->assertEquals('es_VE', Locale::getDefault());
Locale::setDefault('');

Locale::setDefault('en_US');
$request = new Request([
'environment' => [
'HTTP_ACCEPT_LANGUAGE' => 'en-GB;q=0.8,es-ES;q=0.9,da-DK;q=0.4'
Expand Down

0 comments on commit 75207a0

Please sign in to comment.