Permalink
Browse files

merged branch benja-M-1/hotfix-response (PR #5633)

This PR was squashed before being merged into the 2.0 branch (closes #5633).

Commits
-------

5c60a65 [2.0][http-foundation] Update phpdoc
c17462f [2.0][http-foundation] Fix response getDate method

Discussion
----------

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

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

Reference #5588, #5629
  • Loading branch information...
2 parents 5984dee + 1a53b12 commit 302c0e4647100402185d160a814b32e14ac9b37b @fabpot fabpot committed Sep 30, 2012
@@ -226,7 +226,9 @@ public function remove($key)
* @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 @@ public function mustRevalidate()
*/
public function getDate()
{
- return $this->headers->getDate('Date');
+ return $this->headers->getDate('Date', new \DateTime());
}
/**
@@ -40,6 +40,10 @@ public function testGetDate()
$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()

0 comments on commit 302c0e4

Please sign in to comment.