8000 [Mime] Fix EmailHeaderSame to make use of decoded value by evertharmeling · Pull Request #37583 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mime] Fix EmailHeaderSame to make use of decoded value #37583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix EmailHeaderSame to make use of decoded value
Fixes #35062
  • Loading branch information
evertharmeling committed Jul 22, 2020
commit 8a3f50746daea247a4ed21f4d9b0e7fc42fc0ad1
12 changes: 10 additions & 2 deletions src/Symfony/Component/Mime/Test/Constraint/EmailHeaderSame.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Mime\Test\Constraint;

use PHPUnit\Framework\Constraint\Constraint;
use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\RawMessage;

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

return $this->expectedValue === $message->getHeaders()->get($this->headerName)->getBodyAsString();
return $this->expectedValue === $this->getHeaderValue($message);
}

/**
Expand All @@ -54,6 +55,13 @@ protected function matches($message): bool
*/
protected function failureDescription($message): string
{
return sprintf('the Email %s (value is %s)', $this->toString(), $message->getHeaders()->get($this->headerName)->getBodyAsString());
return sprintf('the Email %s (value is %s)', $this->toString(), $this->getHeaderValue($message));
}

private function getHeaderValue($message): string
{
$header = $message->getHeaders()->get($this->headerName);

return $header instanceof UnstructuredHeader ? $header->getValue() : $header->getBodyAsString();
}
}
0