Skip to content

Commit

Permalink
[HttpFoundation] added some tests for the previous merge and removed …
Browse files Browse the repository at this point in the history
…dead code (closes #6037)
  • Loading branch information
fabpot committed Dec 11, 2012
1 parent 1ab4923 commit 47dfb9c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Symfony/Component/HttpFoundation/Response.php
Expand Up @@ -692,14 +692,8 @@ public function getMaxAge()
return $age; return $age;
} }


$expiry = $this->getExpires(); if (null !== $this->getExpires()) {

return $this->getExpires()->format('U') - $this->getDate()->format('U');
if (!$expiry instanceof \DateTime && (-1 == $expiry || 0 === $expiry)) {
return $expiry;
}

if (null !== $expiry) {
return $expiry->format('U') - $this->getDate()->format('U');
} }


return null; return null;
Expand Down
17 changes: 17 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
Expand Up @@ -351,6 +351,23 @@ public function testPrepareRemovesContentForHeadRequests()
$this->assertEquals('', $response->getContent()); $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() public function testSetCache()
{ {
$response = new Response(); $response = new Response();
Expand Down

0 comments on commit 47dfb9c

Please sign in to comment.