maxage: '15',
smaxage: '15',
vary:
['foobar'
],
lastModified: 'Fri, 24 Aug 2013 00:00:00 GMT',
etag: '"12345"',
));
$response =
new Response();
$response->
setEtag('"54321"'
);
$response->
setLastModified(new \
DateTimeImmutable('Fri, 23 Aug 2014 00:00:00 GMT'
));
$response->
setExpires(new \
DateTimeImmutable('Fri, 24 Aug 2014 00:00:00 GMT'
));
$response->
setSharedMaxAge(30
);
$response->
setMaxAge(30
);
$response->
setVary(['foobaz'
]);
$listener =
new CacheAttributeListener();
$responseEvent =
new ResponseEvent($this->
getKernel(),
$request, HttpKernelInterface::MAIN_REQUEST,
$response);
$listener->
onKernelResponse($responseEvent);
$this->
assertSame('"54321"',
$response->
getEtag());
$this->
assertEquals(new \
DateTimeImmutable('Fri, 23 Aug 2014 00:00:00 GMT'
),
$response->
getLastModified());
$this->
assertEquals(new \
DateTimeImmutable('Fri, 24 Aug 2014 00:00:00 GMT'
),
$response->
getExpires());
$this->
assertSame('30',
$response->headers->
getCacheControlDirective('s-maxage'
));