File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Filter options
src/Symfony/Component/Mime/Test/Constraint Expand file tree Collapse file tree 1 file changed +10
-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 \UnstructuredHeader ;
15
16
use Symfony \Component \Mime \RawMessage ;
16
17
17
18
final class EmailHeaderSame extends Constraint
@@ -44,7 +45,7 @@ protected function matches($message): bool
44
45
throw new \LogicException ('Unable to test a message header on a RawMessage instance. ' );
45
46
}
46
47
47
- return $ this ->expectedValue === $ message -> getHeaders ()-> get ( $ this ->headerName )-> getBodyAsString ( );
48
+ return $ this ->expectedValue === $ this ->getHeaderValue ( $ message );
48
49
}
49
50
50
51
/**
@@ -54,6 +55,13 @@ protected function matches($message): bool
54
55
*/
55
56
protected function failureDescription ($ message ): string
56
57
{
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 ();
58
66
}
59
67
}
You can’t perform that action at this time.
0 commit comments