Skip to content

Commit adafb8b

Browse files
committed
try to work around the LogicalNot(ResponseHeaderSame) behaviour
1 parent f9660cc commit adafb8b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/BrowserKitAssertionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function assertResponseHeaderSame(string $headerName, string $expe
7979

8080
public static function assertResponseHeaderNotSame(string $headerName, string $expectedValue, string $message = ''): void
8181
{
82-
self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue)), $message);
82+
self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue, true)), $message);
8383
}
8484

8585
public static function assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ final class ResponseHeaderSame extends Constraint
1818
{
1919
private string $headerName;
2020
private string $expectedValue;
21+
private bool $logicalNot;
2122
private ?string $actualValue = null;
2223

23-
public function __construct(string $headerName, string $expectedValue)
24+
public function __construct(string $headerName, string $expectedValue, bool $logicalNot = false)
2425
{
2526
$this->headerName = $headerName;
2627
$this->expectedValue = $expectedValue;
28+
$this->logicalNot = $logicalNot;
2729
}
2830

2931
public function toString(): string
@@ -34,7 +36,7 @@ public function toString(): string
3436
$output .= sprintf(', header "%s" is not set', $this->headerName);
3537
}
3638

37-
if (null !== $this->actualValue) {
39+
if (null !== $this->actualValue && !$this->logicalNot) {
3840
$output .= sprintf(', value of header "%s" is "%s"', $this->headerName, $this->actualValue);
3941
}
4042

0 commit comments

Comments
 (0)