8000 [HttpFoundation] Compare cookie with null value as empty string in Re… · symfony/symfony@0cc7368 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cc7368

Browse files
committed
[HttpFoundation] Compare cookie with null value as empty string in ResponseCookieValueSame
1 parent ad0e25f commit 0cc7368

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/HttpFoundation/Test/Constraint/ResponseCookieValueSame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function matches($response): bool
5959
return false;
6060
}
6161

62-
return $this->value === $cookie->getValue();
62+
return $this->value === (string) $cookie->getValue();
6363
}
6464

6565
/**

src/Symfony/Component/HttpFoundation/Tests/Test/Constraint/ResponseCookieValueSameTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ public function testConstraint()
4141

4242
$this->fail();
4343
}
44+
45+
public function testCookieWithNullValueIsComparedAsEmptyString()
46+
{
47+
$response = new Response();
48+
$response->headers->setCookie(Cookie::create('foo', null, 0, '/path'));
49+
50+
$this->assertTrue((new ResponseCookieValueSame('foo', '', '/path'))->evaluate($response, '', true));
51+
}
4452
}

0 commit comments

Comments
 (0)
0