From 70b2749acfe7cb66f13251a0a8b1c3771a3f098d Mon Sep 17 00:00:00 2001 From: Hidehito Nozawa Date: Mon, 18 May 2015 13:28:46 +0900 Subject: [PATCH] When both of query string and cookie exists, query string wins. Signed-off-by: Hidehito Nozawa --- src/ShouldBee/Translation/Negotiation.php | 2 +- tests/ShouldBee/Translation/NegotiationTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ShouldBee/Translation/Negotiation.php b/src/ShouldBee/Translation/Negotiation.php index fa77d3a..081ab2c 100644 --- a/src/ShouldBee/Translation/Negotiation.php +++ b/src/ShouldBee/Translation/Negotiation.php @@ -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; } diff --git a/tests/ShouldBee/Translation/NegotiationTest.php b/tests/ShouldBee/Translation/NegotiationTest.php index 5588f41..5b46275 100644 --- a/tests/ShouldBee/Translation/NegotiationTest.php +++ b/tests/ShouldBee/Translation/NegotiationTest.php @@ -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); } } \ No newline at end of file