The age is determined either by an explicitly set Age header or by the
difference between Date and "now".
Note that, according to RFC 2616 / 13.2.3, the presence of an Age header implies
that the response is not first-hand. You should therefore only explicitly set
an Age header if this is the case.
/** * @test */ public function getAgeReturnsTimeSpecifiedInAgeHeaderIfExists() { $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 GMT'); $response = new Response(); $response->setNow($now); $response->setHeader('Age', 123); $this->assertSame(123, $response->getAge()); }