Skip to content

Commit 761ad92

Browse files
committed
fix: correction des tests en fonction de la mise a jour des composant
1 parent 029626b commit 761ad92

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

spec/system/cache/ResponseCache.spec.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
$request = Double::instance([
3535
'implements' => [ServerRequestInterface::class],
36-
'stubMethods' => ['getUri' => $uri]
36+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST']
3737
]);
3838

3939
$cache = Double::instance([
@@ -44,7 +44,7 @@
4444

4545
$key = $responseCache->generateCacheKey($request);
4646

47-
expect($key)->toBe(md5('https://example.com/test'));
47+
expect($key)->toBe(md5('POST:https://example.com/test'));
4848
expect(strlen($key))->toBe(32);
4949
});
5050

@@ -61,7 +61,7 @@
6161

6262
$request = Double::instance([
6363
'implements' => [ServerRequestInterface::class],
64-
'stubMethods' => ['getUri' => $uri],
64+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST'],
6565
]);
6666

6767
$cache = Double::instance([
@@ -72,7 +72,7 @@
7272

7373
$key = $responseCache->generateCacheKey($request);
7474

75-
expect($key)->toBe(md5('https://example.com/test?param=value'));
75+
expect($key)->toBe(md5('POST:https://example.com/test?param=value'));
7676
});
7777
});
7878

@@ -128,7 +128,7 @@
128128

129129
$request = Double::instance([
130130
'implements' => [ServerRequestInterface::class],
131-
'stubMethods' => ['getUri' => $uri],
131+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'POST'],
132132
]);
133133
$body = Double::instance([
134134
'implements' => [\Psr\Http\Message\StreamInterface::class],
@@ -141,6 +141,8 @@
141141
'stubMethods' => [
142142
'getBody' => $body,
143143
'getHeaders' => ['Content-Type' => ['application/json']],
144+
'getStatusCode' => 200,
145+
'getReasonPhrase' => 'Ok',
144146
],
145147
]);
146148
allow($response)->toReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json');
@@ -177,7 +179,7 @@
177179

178180
$request = Double::instance([
179181
'implements' => [ServerRequestInterface::class],
180-
'stubMethods' => ['getUri' => $uri],
182+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'],
181183
]);
182184
$body = Double::instance([
183185
'implements' => [\Psr\Http\Message\StreamInterface::class],
@@ -190,6 +192,8 @@
190192
'stubMethods' => [
191193
'getBody' => $body,
192194
'getHeaders' => ['Content-Type' => ['application/json']],
195+
'getStatusCode' => 200,
196+
'getReasonPhrase' => 'Ok',
193197
],
194198
]);
195199
allow($response)->toReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json');
@@ -222,14 +226,15 @@
222226

223227
$request = Double::instance([
224228
'implements' => [ServerRequestInterface::class],
225-
'stubMethods' => ['getUri' => $uri],
229+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'],
226230
]);
227231

228232
$newResponse = Double::instance([
229233
'implements' => [ResponseInterface::class],
230234
]);
231235
allow($newResponse)->toReceive('withHeader')->with('X-Custom', 'value')->andReturn($newResponse);
232236
allow($newResponse)->toReceive('withBody')->andReturn($newResponse);
237+
allow($newResponse)->toReceive('withStatus')->andReturn($newResponse);
233238

234239
$response = Double::instance([
235240
'implements' => [ResponseInterface::class],
@@ -267,7 +272,7 @@
267272

268273
$request = Double::instance([
269274
'implements' => [ServerRequestInterface::class],
270-
'stubMethods' => ['getUri' => $uri],
275+
'stubMethods' => ['getUri' => $uri, 'getMethod' => 'GET'],
271276
]);
272277

273278
$response = Double::instance([

spec/system/framework/Middlewares/PageCache.spec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function get(string $key, mixed $default = null): mixed
4242
$uri->shouldReceive('withQuery')->andReturn($uri);
4343
$uri->shouldReceive('getQuery')->andReturn('');
4444

45-
$request = Mockery::mock(Request::class);
45+
$request = Mockery::mock(Request::class, ['getMethod' => 'GET']);
4646
$request->shouldReceive('getUri')->andReturn($uri);
4747

4848
return $request;

0 commit comments

Comments
 (0)