[HttpFoundation] added some tests for the previous merge and removed dead code (closes #6037)

This commit is contained in:
Fabien Potencier 2012-12-11 10:29:04 +01:00
parent 1ab492394c
commit 47dfb9cb6a
2 changed files with 19 additions and 8 deletions

View File

@ -692,14 +692,8 @@ class Response
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 File

@ -351,6 +351,23 @@ class ResponseTest extends \PHPUnit_Framework_TestCase
$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();