[HttpFoundation] added some unit tests
This commit is contained in:
parent
b6a6791f97
commit
1017d83260
@ -991,10 +991,9 @@ class Response
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach ($vary as $item) {
|
foreach ($vary as $item) {
|
||||||
$ret = array_merge($ret, preg_split('/[\s,]+/', $item));
|
$ret = array_merge($ret, preg_split('/[\s,]+/', $item));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@ -285,15 +285,15 @@ class ResponseTest extends ResponseTestCase
|
|||||||
$response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo');
|
$response->headers->set('Vary', 'Accept-Language,User-Agent, X-Foo');
|
||||||
$this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas');
|
$this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->getVary() parses multiple header name values separated by commas');
|
||||||
|
|
||||||
$response = new Response();
|
$vary = array('Accept-Language', 'User-Agent', 'X-foo');
|
||||||
$vary = array(
|
|
||||||
'Accept-Language',
|
|
||||||
'User-Agent',
|
|
||||||
'X-foo',
|
|
||||||
);
|
|
||||||
$response->headers->set('Vary', $vary);
|
|
||||||
$this->assertEquals($response->headers->get('Vary', NULL, FALSE) , $response->getVary(), '->getVary() parses multiple header name values in arrays');
|
|
||||||
|
|
||||||
|
$response = new Response();
|
||||||
|
$response->headers->set('Vary', $vary);
|
||||||
|
$this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays');
|
||||||
|
|
||||||
|
$response = new Response();
|
||||||
|
$response->headers->set('Vary', 'Accept-Language, User-Agent, X-foo');
|
||||||
|
$this->assertEquals($vary, $response->getVary(), '->getVary() parses multiple header name values in arrays');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetVary()
|
public function testSetVary()
|
||||||
@ -306,9 +306,7 @@ class ResponseTest extends ResponseTestCase
|
|||||||
$this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default');
|
$this->assertEquals(array('Accept-Language', 'User-Agent'), $response->getVary(), '->setVary() replace the vary header by default');
|
||||||
|
|
||||||
$response->setVary('X-Foo', false);
|
$response->setVary('X-Foo', false);
|
||||||
$this->assertTrue(in_array('Accept-Language', $response->getVary()), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false');
|
$this->assertEquals(array('Accept-Language', 'User-Agent', 'X-Foo'), $response->getVary(), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false');
|
||||||
$this->assertTrue(in_array('User-Agent', $response->getVary()), '->setVary() doesn\'t wipe out earlier Vary headers if replace is set to false');
|
|
||||||
$this->assertTrue(in_array('X-Foo', $response->getVary()), '->setVary() adds new Vary headers when replace is set to false');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefaultContentType()
|
public function testDefaultContentType()
|
||||||
|
Reference in New Issue
Block a user