File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/Symfony/Component/Mime/Test/Constraint Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Mime \Test \Constraint ;
13
13
14
14
use PHPUnit \Framework \Constraint \Constraint ;
15
+ use Symfony \Component \Mime \Header \HeaderInterface ;
16
+ use Symfony \Component \Mime \Header \UnstructuredHeader ;
15
17
use Symfony \Component \Mime \RawMessage ;
16
18
17
19
final class EmailHeaderSame extends Constraint
@@ -44,7 +46,9 @@ protected function matches($message): bool
44
46
throw new \LogicException ('Unable to test a message header on a RawMessage instance. ' );
45
47
}
46
48
47
- return $ this ->expectedValue === $ message ->getHeaders ()->get ($ this ->headerName )->getBodyAsString ();
49
+ $ header = $ message ->getHeaders ()->get ($ this ->headerName );
50
+
51
+ return $ this ->expectedValue === self ::getHeaderValue ($ header );
48
52
}
49
53
50
54
/**
@@ -54,6 +58,13 @@ protected function matches($message): bool
54
58
*/
55
59
protected function failureDescription ($ message ): string
56
60
{
57
- return sprintf ('the Email %s (value is %s) ' , $ this ->toString (), $ message ->getHeaders ()->get ($ this ->headerName )->getBodyAsString ());
61
+ $ header = $ message ->getHeaders ()->get ($ this ->headerName );
62
+
63
+ return sprintf ('the Email %s (value is %s) ' , $ this ->toString (), self ::getHeaderValue ($ header ));
64
+ }
65
+
66
+ private static function getHeaderValue (HeaderInterface $ header ): string
67
+ {
68
+ return $ header instanceof UnstructuredHeader ? $ header ->getValue () : $ header ->getBodyAsString ();
58
69
}
59
70
}
You can’t perform that action at this time.
0 commit comments