|
33 | 33 |
|
34 | 34 | $request = Double::instance([ |
35 | 35 | 'implements' => [ServerRequestInterface::class], |
36 | | - 'stubMethods' => ['getUri' => $uri] |
| 36 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST'] |
37 | 37 | ]); |
38 | 38 |
|
39 | 39 | $cache = Double::instance([ |
|
44 | 44 |
|
45 | 45 | $key = $responseCache->generateCacheKey($request); |
46 | 46 |
|
47 | | - expect($key)->toBe(md5('https://example.com/test')); |
| 47 | + expect($key)->toBe(md5('POST:https://example.com/test')); |
48 | 48 | expect(strlen($key))->toBe(32); |
49 | 49 | }); |
50 | 50 |
|
|
61 | 61 |
|
62 | 62 | $request = Double::instance([ |
63 | 63 | 'implements' => [ServerRequestInterface::class], |
64 | | - 'stubMethods' => ['getUri' => $uri], |
| 64 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST'], |
65 | 65 | ]); |
66 | 66 |
|
67 | 67 | $cache = Double::instance([ |
|
72 | 72 |
|
73 | 73 | $key = $responseCache->generateCacheKey($request); |
74 | 74 |
|
75 | | - expect($key)->toBe(md5('https://example.com/test?param=value')); |
| 75 | + expect($key)->toBe(md5('POST:https://example.com/test?param=value')); |
76 | 76 | }); |
77 | 77 | }); |
78 | 78 |
|
|
128 | 128 |
|
129 | 129 | $request = Double::instance([ |
130 | 130 | 'implements' => [ServerRequestInterface::class], |
131 | | - 'stubMethods' => ['getUri' => $uri], |
| 131 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST'], |
132 | 132 | ]); |
133 | 133 | $body = Double::instance([ |
134 | 134 | 'implements' => [\Psr\Http\Message\StreamInterface::class], |
|
141 | 141 | 'stubMethods' => [ |
142 | 142 | 'getBody' => $body, |
143 | 143 | 'getHeaders' => ['Content-Type' => ['application/json']], |
| 144 | + 'getStatusCode' => 200, |
| 145 | + 'getReasonPhrase' => 'Ok', |
144 | 146 | ], |
145 | 147 | ]); |
146 | 148 | allow($response)->toReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json'); |
|
177 | 179 |
|
178 | 180 | $request = Double::instance([ |
179 | 181 | 'implements' => [ServerRequestInterface::class], |
180 | | - 'stubMethods' => ['getUri' => $uri], |
| 182 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'], |
181 | 183 | ]); |
182 | 184 | $body = Double::instance([ |
183 | 185 | 'implements' => [\Psr\Http\Message\StreamInterface::class], |
|
190 | 192 | 'stubMethods' => [ |
191 | 193 | 'getBody' => $body, |
192 | 194 | 'getHeaders' => ['Content-Type' => ['application/json']], |
| 195 | + 'getStatusCode' => 200, |
| 196 | + 'getReasonPhrase' => 'Ok', |
193 | 197 | ], |
194 | 198 | ]); |
195 | 199 | allow($response)->toReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json'); |
|
222 | 226 |
|
223 | 227 | $request = Double::instance([ |
224 | 228 | 'implements' => [ServerRequestInterface::class], |
225 | | - 'stubMethods' => ['getUri' => $uri], |
| 229 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'], |
226 | 230 | ]); |
227 | 231 |
|
228 | 232 | $newResponse = Double::instance([ |
229 | 233 | 'implements' => [ResponseInterface::class], |
230 | 234 | ]); |
231 | 235 | allow($newResponse)->toReceive('withHeader')->with('X-Custom', 'value')->andReturn($newResponse); |
232 | 236 | allow($newResponse)->toReceive('withBody')->andReturn($newResponse); |
| 237 | + allow($newResponse)->toReceive('withStatus')->andReturn($newResponse); |
233 | 238 |
|
234 | 239 | $response = Double::instance([ |
235 | 240 | 'implements' => [ResponseInterface::class], |
|
267 | 272 |
|
268 | 273 | $request = Double::instance([ |
269 | 274 | 'implements' => [ServerRequestInterface::class], |
270 | | - 'stubMethods' => ['getUri' => $uri], |
| 275 | + 'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'], |
271 | 276 | ]); |
272 | 277 |
|
273 | 278 | $response = Double::instance([ |
|
0 commit comments