Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8a3f507

Browse filesBrowse files
Fix EmailHeaderSame to make use of decoded value
Fixes #35062
1 parent f617380 commit 8a3f507
Copy full SHA for 8a3f507

File tree

Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed

‎src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Mime\Test\Constraint;
1313

1414
use PHPUnit\Framework\Constraint\Constraint;
15+
use Symfony\Component\Mime\Header\UnstructuredHeader;
1516
use Symfony\Component\Mime\RawMessage;
1617

1718
final class EmailHeaderSame extends Constraint
@@ -44,7 +45,7 @@ protected function matches($message): bool
4445
throw new \LogicException('Unable to test a message header on a RawMessage instance.');
4546
}
4647

47-
return $this->expectedValue === $message->getHeaders()->get($this->headerName)->getBodyAsString();
48+
return $this->expectedValue === $this->getHeaderValue($message);
4849
}
4950

5051
/**
@@ -54,6 +55,13 @@ protected function matches($message): bool
5455
*/
5556
protected function failureDescription($message): string
5657
{
57-
return sprintf('the Email %s (value is %s)', $this->toString(), $message->getHeaders()->get($this->headerName)->getBodyAsString());
58+
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message));
59+
}
60+
61+
private function getHeaderValue($message): string
62+
{
63+
$header = $message->getHeaders()->get($this->headerName);
64+
65+
return $header instanceof UnstructuredHeader ? $header->getValue() : $header->getBodyAsString();
5866
}
5967
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.