Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions src/Symfony/Component/HttpKernel/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient;

/**
* @group time-sensitive
*/
class ClientTest extends \PHPUnit_Framework_TestCase
{
public function testDoRequest()
Expand Down Expand Up @@ -56,22 +59,38 @@ public function testFilterResponseConvertsCookies()
$m = $r->getMethod('filterResponse');
$m->setAccessible(true);

$expected = array(
$expected31 = array(
'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly',
'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly',
);
$expected33 = array(
'foo=bar; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly',
'foo1=bar1; expires=Sun, 15-Feb-2009 20:00:00 GMT; max-age='.(strtotime('Sun, 15-Feb-2009 20:00:00 GMT') - time()).'; path=/foo; domain=http://example.com; secure; httponly',
);

$response = new Response();
$response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$domResponse = $m->invoke($client, $response);
$this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie'));
try {
$this->assertEquals($expected31[0], $domResponse->getHeader('Set-Cookie'));
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertEquals($expected33[0], $domResponse->getHeader('Set-Cookie'));
}

$response = new Response();
$response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$domResponse = $m->invoke($client, $response);
$this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie'));
$this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false));
try {
$this->assertEquals($expected31[0], $domResponse->getHeader('Set-Cookie'));
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertEquals($expected33[0], $domResponse->getHeader('Set-Cookie'));
}
try {
$this->assertEquals($expected31, $domResponse->getHeader('Set-Cookie', false));
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
$this->assertEquals($expected33, $domResponse->getHeader('Set-Cookie', false));
}
}

public function testFilterResponseSupportsStreamedResponses()
Expand Down