Fix constant accessor

This commit is contained in:
Dries Vints 2020-04-07 19:49:21 +02:00 committed by Fabien Potencier
parent 2d6327ff9d
commit 633ff5b214
2 changed files with 7 additions and 1 deletions

View File

@ -949,7 +949,7 @@ class Response
*/
public function setCache(array $options): object
{
if ($diff = array_diff(array_keys($options), array_keys(static::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
if ($diff = array_diff(array_keys($options), array_keys(self::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
}

View File

@ -672,6 +672,12 @@ class ResponseTest extends ResponseTestCase
$this->assertFalse($response->headers->hasCacheControlDirective(str_replace('_', '-', $directive)));
}
$response = new DefaultResponse();
$options = ['etag' => '"whatever"'];
$response->setCache($options);
$this->assertSame($response->getEtag(), '"whatever"');
}
public function testSendContent()