Skip to content

Commit

Permalink
When both of query string and cookie exists, query string wins.
Browse files Browse the repository at this point in the history
Signed-off-by: Hidehito Nozawa <[email protected]>
  • Loading branch information
suin committed May 18, 2015
1 parent cc1a1dc commit 70b2749
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ShouldBee/Translation/Negotiation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static function negotiate(array $availableLanguages)
{
$language = $availableLanguages[0];
$language = self::negotiateByAcceptLanguage($availableLanguages, $language);
$language = self::negotiateByQueryString($availableLanguages, $language);
$language = self::negotiateByCookie($availableLanguages, $language);
$language = self::negotiateByQueryString($availableLanguages, $language);

return $language;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ShouldBee/Translation/NegotiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public function testNegotiation()
$language = Negotiation::negotiate($availableLanguages);
$this->assertSame('ja', $language);

// set query string.
$_GET['language'] = 'ko';
$language = Negotiation::negotiate($availableLanguages);
$this->assertSame('ko', $language);

// set cookie.
$_COOKIE['language'] = 'zh';
$language = Negotiation::negotiate($availableLanguages);
$this->assertSame('zh', $language);

// set query string.
$_GET['language'] = 'ko';
$language = Negotiation::negotiate($availableLanguages);
$this->assertSame('ko', $language);
}
}

0 comments on commit 70b2749

Please sign in to comment.