Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0752ee5

Browse files
committed
Replace empty() check, test correct body
1 parent ec890f6 commit 0752ee5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/Symfony/Component/Mime/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function getBody(): AbstractPart
424424
private function generateBody(): AbstractPart
425425
{
426426
[$htmlPart, $attachmentParts, $inlineParts] = $this->prepareParts();
427-
if (null === $this->text && null === $this->html && empty($attachmentParts)) {
427+
if (null === $this->text && null === $this->html && !$attachmentParts) {
428428
throw new LogicException('A message must have a text or an HTML part or attachments.');
429429
}
430430

src/Symfony/Component/Mime/Tests/EmailTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,6 @@ public function testGenerateBodyThrowsWhenEmptyBody()
238238
(new Email())->getBody();
239239
}
240240

241-
public function testGenerateBodyDoesNotThrowWhenAttachmentsPresent()
242-
{
243-
$body = (new Email())->attachFromPath(__FILE__)->getBody();
244-
$this->assertNotEmpty($body);
245-
}
246-
247241
public function testGetBody()
248242
{
249243
$e = new Email();
@@ -290,6 +284,10 @@ public function testGenerateBody()
290284
$e->html('html content');
291285
$this->assertEquals(new MixedPart($html, $att), $e->getBody());
292286

287+
$e = new Email();
288+
$e->attach($file);
289+
$this->assertEquals(new MixedPart($att), $e->getBody());
290+
293291
$e = new Email();
294292
$e->html('html content');
295293
$e->text('text content');

0 commit comments

Comments
 (0)