[2.0][http-foundation] Fix Response::getDate method

This commit is contained in:
Benjamin Grandfond 2012-09-30 10:47:54 +02:00 committed by Fabien Potencier
parent 5984dee719
commit 1a53b121aa
3 changed files with 8 additions and 2 deletions

View File

@ -226,7 +226,9 @@ class HeaderBag
* @param string $key The parameter key
* @param \DateTime $default The default value
*
* @return \DateTime The filtered value
* @return null|\DateTime The filtered value
*
* @throws \RuntimeException When the HTTP header is not parseable
*
* @api
*/

View File

@ -430,7 +430,7 @@ class Response
*/
public function getDate()
{
return $this->headers->getDate('Date');
return $this->headers->getDate('Date', new \DateTime());
}
/**

View File

@ -40,6 +40,10 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
$now = $this->createDateTimeNow();
$response->headers->set('Date', $now->format(DATE_RFC2822));
$this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified');
$response = new Response('', 200);
$response->headers->remove('Date');
$this->assertInstanceOf('\DateTime', $response->getDate());
}
public function testGetMaxAge()