minor #20983 [HttpKernel] Fix ClientTest cookie format assertions (nicolas-grekas)
This PR was merged into the 3.1 branch.
Discussion
----------
[HttpKernel] Fix ClientTest cookie format assertions
| Q | A
| ------------- | ---
| Branch? | 3.1
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
20190c3
[HttpKernel] Fix ClientTest cookie format assertions
This commit is contained in:
commit
6ba0414cc0
@ -18,6 +18,9 @@ use Symfony\Component\HttpFoundation\Cookie;
|
||||
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()
|
||||
@ -56,22 +59,38 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$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()
|
||||
|
Reference in New Issue
Block a user