-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mime] Fix body validity check in
Email
when using `Message::setBod…
…y()`
- Loading branch information
1 parent
ea87c88
commit 917d779
Showing
2 changed files
with
57 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -695,4 +695,60 @@ public function testEmailsWithAttachmentsWhichAreAFileInstanceCanBeUnserialized( | |
$this->assertCount(1, $attachments); | ||
$this->assertStringContainsString('foo_bar_xyz_123', $attachments[0]->getBody()); | ||
} | ||
|
||
public function testInvalidBodyWithEmptyEmail() | ||
{ | ||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('A message must have a text or an HTML part or attachments.'); | ||
|
||
(new Email())->ensureValidity(); | ||
} | ||
|
||
public function testBodyWithTextIsValid() | ||
{ | ||
$email = new Email(); | ||
$email->to('[email protected]') | ||
->from('[email protected]') | ||
->text('foo'); | ||
|
||
$email->ensureValidity(); | ||
|
||
$this->expectNotToPerformAssertions(); | ||
} | ||
|
||
public function testBodyWithHtmlIsValid() | ||
{ | ||
$email = new Email(); | ||
$email->to('[email protected]') | ||
->from('[email protected]') | ||
->html('foo'); | ||
|
||
$email->ensureValidity(); | ||
|
||
$this->expectNotToPerformAssertions(); | ||
} | ||
|
||
public function testEmptyBodyWithAttachmentsIsValid() | ||
{ | ||
$email = new Email(); | ||
$email->to('[email protected]') | ||
->from('[email protected]') | ||
->addPart(new DataPart('foo')); | ||
|
||
$email->ensureValidity(); | ||
|
||
$this->expectNotToPerformAssertions(); | ||
} | ||
|
||
public function testSetBodyIsValid() | ||
{ | ||
$email = new Email(); | ||
$email->to('[email protected]') | ||
->from('[email protected]') | ||
->setBody(new TextPart('foo')); | ||
|
||
$email->ensureValidity(); | ||
|
||
$this->expectNotToPerformAssertions(); | ||
} | ||
} |