You are here

public function ResponseTest::testExpire in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/ResponseTest.php \Symfony\Component\HttpFoundation\Tests\ResponseTest::testExpire()

File

vendor/symfony/http-foundation/Tests/ResponseTest.php, line 327

Class

ResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

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');
  $response = new Response();
  $response->headers
    ->set('Expires', -1);
  $response
    ->expire();
  $this
    ->assertNull($response->headers
    ->get('Age'), '->expire() does not set the Age when the response is expired');
}