From b19a1edb61244df53e532cade85bd3e16fef338d Mon Sep 17 00:00:00 2001 From: Shawn Iwinski Date: Mon, 21 Mar 2016 11:53:07 -0400 Subject: [PATCH 1/5] Update tests to allow for Doctrine Cache >= 1.6.0 internal changes --- .../Tests/Plugin/Cache/DefaultCacheStorageTest.php | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php b/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php index 701a015..987c4a3 100644 --- a/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php +++ b/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php @@ -14,6 +14,21 @@ */ class DefaultCacheStorageTest extends \Guzzle\Tests\GuzzleTestCase { + /** + * As of Doctrine Cache 1.6.0 its' private "data" attribute + * values are arrays that contain the cached value and the + * cached value's lifetime instead of just the cached value + * itself. + */ + protected static $doctrine_cache_gte_1_6_0; + + public static function setUpBeforeClass() + { + static::$doctrine_cache_gte_1_6_0 = + class_exists('Doctrine\Common\Cache\Version') + && version_compare(\Doctrine\Common\Cache\Version::VERSION, '1.6.0', '>='); + } + protected function getCache() { $a = new ArrayCache(); @@ -50,6 +65,11 @@ public function testCachesRequests() $cache = $this->getCache(); $foundRequest = $foundBody = $bodyKey = false; foreach ($this->readAttribute($cache['cache'], 'data') as $key => $v) { + // Doctrine Cache >= 1.6.0 + if (static::$doctrine_cache_gte_1_6_0) { + $v = array_shift($v); + } + if (strpos($v, 'foo.com')) { $foundRequest = true; $data = unserialize($v); @@ -93,6 +113,11 @@ public function testCachesMultipleRequestsWithVary() $cache['storage']->cache($cache['request'], $response); $data = $this->readAttribute($cache['cache'], 'data'); foreach ($data as $v) { + // Doctrine Cache >= 1.6.0 + if (static::$doctrine_cache_gte_1_6_0) { + $v = array_shift($v); + } + if (strpos($v, 'foo.com')) { $u = unserialize($v); $this->assertEquals(2, count($u)); @@ -146,6 +171,12 @@ public function testEnsuresResponseIsStillPresent() { $cache = $this->getCache(); $data = $this->readAttribute($cache['cache'], 'data'); + // Doctrine Cache >= 1.6.0 + if (static::$doctrine_cache_gte_1_6_0) { + array_walk($data, function (&$value) { + $value = array_shift($value); + }); + } $key = array_search('test', $data); $cache['cache']->delete(substr($key, 1, -4)); $this->assertNull($cache['storage']->fetch($cache['request'])); @@ -174,6 +205,11 @@ public function testUsesStaleTimeDirectiveForTtd($request, $response) $cache['storage']->cache($request, $response); $data = $this->readAttribute($cache['cache'], 'data'); foreach ($data as $v) { + // Doctrine Cache >= 1.6.0 + if (static::$doctrine_cache_gte_1_6_0) { + $v = array_shift($v); + } + if (strpos($v, 'foo.com')) { $u = unserialize($v); $this->assertGreaterThan($u[1][4], $u[0][4]); From 9312343b4cd020a57f73ca985828ecb4e360b410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pr=C3=A9vot?= Date: Thu, 26 Nov 2015 14:07:41 -0400 Subject: [PATCH 2/5] Match latest (>= 1.4.3) Doctrine Cache behaviour Bug: https://github.com/guzzle/guzzle3/issues/67 Bug-Debian: https://bugs.debian.org/804583 --- tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php b/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php index 987c4a3..dbfd810 100644 --- a/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php +++ b/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php @@ -142,7 +142,7 @@ public function testPurgeRemovesAllMethodCaches() $this->assertFalse(in_array('test', $this->readAttribute($cache['cache'], 'data'))); $this->assertFalse(in_array($cache['serialized'], $this->readAttribute($cache['cache'], 'data'))); $this->assertEquals( - array('DoctrineNamespaceCacheKey[]'), + array(), array_keys($this->readAttribute($cache['cache'], 'data')) ); } From f3041fb232862b4c449a23497cc70225574bfcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pr=C3=A9vot?= Date: Thu, 26 Nov 2015 14:17:15 -0400 Subject: [PATCH 3/5] Bump doctrine/cache version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 59424b3..f2040cf 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ }, "require-dev": { - "doctrine/cache": "~1.3", + "doctrine/cache": "~1.4.3", "symfony/class-loader": "~2.1", "monolog/monolog": "~1.0", "psr/log": "~1.0", From ad90c2d4471aaf9a591df207c3cdbe5c531371e2 Mon Sep 17 00:00:00 2001 From: Shawn Iwinski Date: Thu, 24 Mar 2016 08:19:05 -0400 Subject: [PATCH 4/5] Modify doctrine/cache dependency from ~1.4.3 to ~1.4 per #69 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f2040cf..f0bfdb6 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ }, "require-dev": { - "doctrine/cache": "~1.4.3", + "doctrine/cache": "~1.4", "symfony/class-loader": "~2.1", "monolog/monolog": "~1.0", "psr/log": "~1.0", From 2ddcdd7646fc7756468fd63b71d7d0d9545dc76e Mon Sep 17 00:00:00 2001 From: Shawn Iwinski Date: Thu, 24 Mar 2016 14:17:56 -0400 Subject: [PATCH 5/5] Modify doctrine/cache dependency from ~1.4 to ~1.4,>=1.4.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f0bfdb6..ebf5dde 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,7 @@ }, "require-dev": { - "doctrine/cache": "~1.4", + "doctrine/cache": "~1.4,>=1.4.3", "symfony/class-loader": "~2.1", "monolog/monolog": "~1.0", "psr/log": "~1.0",