|
18 | 18 | use Symfony\Component\Cache\Adapter\RedisAdapter; |
19 | 19 | use Symfony\Component\Cache\Adapter\TagAwareAdapter; |
20 | 20 | use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; |
| 21 | +use Symfony\Component\HttpFoundation\Cookie; |
21 | 22 | use Symfony\Component\HttpFoundation\Request; |
22 | 23 | use Symfony\Component\HttpFoundation\Response; |
23 | 24 | use Symfony\Component\Lock\Exception\LockReleasingException; |
@@ -334,6 +335,26 @@ public function testRegularLookup() |
334 | 335 | $this->assertSame('whatever', $result->headers->get('Foobar')); |
335 | 336 | } |
336 | 337 |
|
| 338 | + public function testLookupWithVaryOnCookies() |
| 339 | + { |
| 340 | + // Cookies match |
| 341 | + $request = Request::create('https://foobar.com/', 'GET', [], ['Foo' => 'Bar'], [], ['HTTP_COOKIE' => 'Foo=Bar']); |
| 342 | + $response = new Response('hello world', 200, ['Vary' => 'Cookie']); |
| 343 | + $response->headers->setCookie(Cookie::create('Foo', 'Bar')); |
| 344 | + |
| 345 | + $this->store->write($request, $response); |
| 346 | + |
| 347 | + $result = $this->store->lookup($request); |
| 348 | + $this->assertInstanceOf(Response::class, $result); |
| 349 | + |
| 350 | + // Cookies do not match (manually removed on request) |
| 351 | + $request = Request::create('https://foobar.com/', 'GET', [], ['Foo' => 'Bar'], [], ['HTTP_COOKIE' => 'Foo=Bar']); |
| 352 | + $request->cookies->remove('Foo'); |
| 353 | + |
| 354 | + $result = $this->store->lookup($request); |
| 355 | + $this->assertNull($result); |
| 356 | + } |
| 357 | + |
337 | 358 | public function testLookupWithEmptyCache() |
338 | 359 | { |
339 | 360 | $request = Request::create('https://foobar.com/'); |
|
0 commit comments