diff --git a/src/Cache/HashTrait.php b/src/Cache/HashTrait.php index aa6f4a6..79a8d05 100644 --- a/src/Cache/HashTrait.php +++ b/src/Cache/HashTrait.php @@ -21,7 +21,7 @@ public function hash($url, $id, array $headers) $headerString = ""; foreach ($headers as $key => $value) { if ($key != Headers::HEADER_XFF) { - $headerString = $key.$value; + $headerString .= $key.$value; } } @@ -39,11 +39,7 @@ public function hash($url, $id, array $headers) */ public function isCachable($url, $httpMethod) { - if ($httpMethod === Client::HTTP_GET && $this->isInitialized()) { - return true; - } - - return false; + return $httpMethod === Client::HTTP_GET && $this->isInitialized(); } /** diff --git a/src/Cache/MemcachedCache.php b/src/Cache/MemcachedCache.php index 06fcb15..a1b7954 100644 --- a/src/Cache/MemcachedCache.php +++ b/src/Cache/MemcachedCache.php @@ -88,6 +88,6 @@ public function delete($key) */ public function isInitialized() { - return $this->cache == null; + return $this->cache != null; } } diff --git a/tests/Cache/HashTraitTest.php b/tests/Cache/HashTraitTest.php index a12bc20..39a9413 100644 --- a/tests/Cache/HashTraitTest.php +++ b/tests/Cache/HashTraitTest.php @@ -40,6 +40,17 @@ public function testHashHeader() $this->assertNotEquals($hash1, $hash2); } + /** @group tttt */ + public function testHashLanguageHeader() + { + $mock = $this->getMockForTrait('\Bookboon\Api\Cache\HashTrait'); + + $hash1 = $mock->hash('/test', "WHATEVSID", array(Headers::HEADER_LANGUAGE => 'en, de', Headers::HEADER_BRANDING => 'branding-test')); + $hash2 = $mock->hash('/test', "WHATEVSID", array(Headers::HEADER_LANGUAGE => 'de, en', Headers::HEADER_BRANDING => 'branding-test')); + + $this->assertNotEquals($hash1, $hash2); + } + public function testRequestIsCacheable() { $mock = $this->getMockForTrait('\Bookboon\Api\Cache\HashTrait');