[2.0][http-foundation] Fix Response::getDate method
This commit is contained in:
parent
5984dee719
commit
1a53b121aa
@ -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
|
||||
*/
|
||||
|
@ -430,7 +430,7 @@ class Response
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->headers->getDate('Date');
|
||||
return $this->headers->getDate('Date', new \DateTime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user