forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 7.1: Revert "fix PHP 7 compatibility" fix PHP 7 compatibility [Mime] Fixed `Mime\Message::ensureValidity()` when a required header is set, but has an empty body
- Loading branch information
Showing
2 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,4 +276,71 @@ public function testSymfonySerialize() | |
$serialized = $serializer->serialize($e, 'json'); | ||
$this->assertStringMatchesFormat($expectedJson, json_encode(json_decode($serialized), \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); | ||
} | ||
|
||
/** | ||
* @dataProvider ensureValidityProvider | ||
*/ | ||
public function testEnsureValidity(array $headers, ?string $exceptionClass, ?string $exceptionMessage) | ||
{ | ||
if ($exceptionClass) { | ||
$this->expectException($exceptionClass); | ||
$this->expectExceptionMessage($exceptionMessage); | ||
} else { | ||
$this->expectNotToPerformAssertions(); | ||
} | ||
|
||
$m = new Message(); | ||
foreach ($headers as $headerName => $headerValue) { | ||
$m->getHeaders()->addMailboxListHeader($headerName, $headerValue); | ||
} | ||
$m->ensureValidity(); | ||
} | ||
|
||
public function ensureValidityProvider() | ||
{ | ||
return [ | ||
'Valid address fields' => [ | ||
[ | ||
'To' => ['[email protected]'], | ||
'From' => ['[email protected]'], | ||
], | ||
null, | ||
null, | ||
], | ||
|
||
'No destination address fields' => [ | ||
[ | ||
'From' => ['[email protected]'], | ||
], | ||
LogicException::class, | ||
'An email must have a "To", "Cc", or "Bcc" header.', | ||
], | ||
|
||
'Empty destination address fields' => [ | ||
[ | ||
'To' => [], | ||
'From' => ['[email protected]'], | ||
], | ||
LogicException::class, | ||
'An email must have a "To", "Cc", or "Bcc" header.', | ||
], | ||
|
||
'No originator fields' => [ | ||
[ | ||
'To' => ['[email protected]'], | ||
], | ||
LogicException::class, | ||
'An email must have a "From" or a "Sender" header.', | ||
], | ||
|
||
'Empty originator fields' => [ | ||
[ | ||
'To' => ['[email protected]'], | ||
'From' => [], | ||
], | ||
LogicException::class, | ||
'An email must have a "From" or a "Sender" header.', | ||
], | ||
]; | ||
} | ||
} |