AddEmbeddedImageTest: split off "missing name" test

The test case when a file was attached without explicitly adding a filename wasn't actually being tested at all as no assertion was used.

This commit:
* Moves that particular test case to a separate test method.
* Adds relevant assertions to actually test the test case.
This commit is contained in:
jrfnl 2021-07-04 17:17:43 +02:00
parent e5b07ba3c3
commit d034bef136
1 changed files with 15 additions and 2 deletions

View File

@ -51,9 +51,22 @@ final class AddEmbeddedImageTest extends PreSendTestCase
$this->buildBody();
self::assertTrue($this->Mail->preSend(), $this->Mail->ErrorInfo);
$this->Mail->clearAttachments();
}
//For code coverage
$this->Mail->addEmbeddedImage(__FILE__, '123'); //Missing name
/**
* Test adding an image without explicitly adding a name for the image will set the name as the existing file name.
*/
public function testAddingImageWithoutExplicitName()
{
$result = $this->Mail->addEmbeddedImage(__FILE__, '123');
self::assertTrue($result, 'File failed to attach');
self::assertTrue($this->Mail->inlineImageExists(), 'Inline image not present in attachments array');
$attachments = $this->Mail->getAttachments();
self::assertIsArray($attachments, 'Attachments is not an array');
self::assertArrayHasKey(0, $attachments, 'Attachments does not have the expected array entry');
self::assertSame($attachments[0][1], $attachments[0][2], 'Name is not the same as filename');
}
/**