1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace Symfony\Component\HttpKernel\Tests\HttpCache;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\HttpKernel\HttpCache\ResponseCacheStrategy;
- class ResponseCacheStrategyTest extends \PHPUnit_Framework_TestCase
- {
- public function testMinimumSharedMaxAgeWins()
- {
- $cacheStrategy = new ResponseCacheStrategy();
- $response1 = new Response();
- $response1->setSharedMaxAge(60);
- $cacheStrategy->add($response1);
- $response2 = new Response();
- $response2->setSharedMaxAge(3600);
- $cacheStrategy->add($response2);
- $response = new Response();
- $response->setSharedMaxAge(86400);
- $cacheStrategy->update($response);
- $this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
- }
- public function testSharedMaxAgeNotSetIfNotSetInAnyEmbeddedRequest()
- {
- $cacheStrategy = new ResponseCacheStrategy();
- $response1 = new Response();
- $response1->setSharedMaxAge(60);
- $cacheStrategy->add($response1);
- $response2 = new Response();
- $cacheStrategy->add($response2);
- $response = new Response();
- $response->setSharedMaxAge(86400);
- $cacheStrategy->update($response);
- $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
- }
- public function testSharedMaxAgeNotSetIfNotSetInMasterRequest()
- {
- $cacheStrategy = new ResponseCacheStrategy();
- $response1 = new Response();
- $response1->setSharedMaxAge(60);
- $cacheStrategy->add($response1);
- $response2 = new Response();
- $response2->setSharedMaxAge(3600);
- $cacheStrategy->add($response2);
- $response = new Response();
- $cacheStrategy->update($response);
- $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
- }
- }
|