summaryrefslogtreecommitdiffstats
path: root/php-guzzle-Guzzle-doctrine-cache-gte-1-6-0.patch
blob: b1c81c6797932da78e6ddaa9ae6b584cff2f02f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
From b19a1edb61244df53e532cade85bd3e16fef338d Mon Sep 17 00:00:00 2001
From: Shawn Iwinski <siwinski@redhat.com>
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?= <david@tilapin.org>
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?= <david@tilapin.org>
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 <siwinski@redhat.com>
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 <siwinski@redhat.com>
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",