예제 #1
0
 public function testExpire()
 {
     $response = new Response();
     $response->headers->set('Cache-Control', 'max-age=100');
     $response->expire();
     $this->assertEquals(100, $response->headers->get('Age'), '->expire() sets the Age to max-age when present');
     $response = new Response();
     $response->headers->set('Cache-Control', 'max-age=100, s-maxage=500');
     $response->expire();
     $this->assertEquals(500, $response->headers->get('Age'), '->expire() sets the Age to s-maxage when both max-age and s-maxage are present');
     $response = new Response();
     $response->headers->set('Cache-Control', 'max-age=5, s-maxage=500');
     $response->headers->set('Age', '1000');
     $response->expire();
     $this->assertEquals(1000, $response->headers->get('Age'), '->expire() does nothing when the response is already stale/expired');
     $response = new Response();
     $response->expire();
     $this->assertFalse($response->headers->has('Age'), '->expire() does nothing when the response does not include freshness information');
 }