Browse files

[HttpFoundation] added some tests for the previous merge and removed …

…dead code (closes #6037)
  • Loading branch information...
1 parent 1ab4923 commit 47dfb9cb6a44526dd882614f05df8242eb2d9ce2 @fabpot fabpot committed Dec 11, 2012
View
10 src/Symfony/Component/HttpFoundation/Response.php
@@ -692,14 +692,8 @@ public function getMaxAge()
return $age;
}
- $expiry = $this->getExpires();
-
- if (!$expiry instanceof \DateTime && (-1 == $expiry || 0 === $expiry)) {
- return $expiry;
- }
-
- if (null !== $expiry) {
- return $expiry->format('U') - $this->getDate()->format('U');
+ if (null !== $this->getExpires()) {
+ return $this->getExpires()->format('U') - $this->getDate()->format('U');
}
return null;
View
17 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -351,6 +351,23 @@ public function testPrepareRemovesContentForHeadRequests()
$this->assertEquals('', $response->getContent());
}
+ public function testPrepareSetsPragmaOnHttp10Only()
+ {
+ $request = Request::create('/', 'GET');
+ $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0');
+
+ $response = new Response('foo');
+ $response->prepare($request);
+ $this->assertEquals('no-cache', $response->headers->get('pragma'));
+ $this->assertEquals('-1', $response->headers->get('expires'));
+
+ $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
+ $response = new Response('foo');
+ $response->prepare($request);
+ $this->assertFalse($response->headers->has('pragma'));
+ $this->assertFalse($response->headers->has('expires'));
+ }
+
public function testSetCache()
{
$response = new Response();

0 comments on commit 47dfb9c

Please sign in to comment.