mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 16:36:07 +03:00
Added tests and method for adding content with string (#797)
This commit is contained in:
parent
d926ba72fd
commit
4db9d9bb63
@ -278,6 +278,20 @@ class MessageBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addStringAttachment(string $attachmentContent, string $attachmentName = null): self
|
||||||
|
{
|
||||||
|
if (!isset($this->message['attachment'])) {
|
||||||
|
$this->message['attachment'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->message['attachment'][] = [
|
||||||
|
'fileContent' => $attachmentContent,
|
||||||
|
'filename' => $attachmentName,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function addInlineImage(string $inlineImagePath, string $inlineImageName = null): self
|
public function addInlineImage(string $inlineImagePath, string $inlineImageName = null): self
|
||||||
{
|
{
|
||||||
if (!isset($this->message['inline'])) {
|
if (!isset($this->message['inline'])) {
|
||||||
|
@ -161,6 +161,26 @@ class MessageBuilderTest extends MailgunTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAddStringAttachment()
|
||||||
|
{
|
||||||
|
$this->messageBuilder->addStringAttachment('12345');
|
||||||
|
$this->messageBuilder->addStringAttachment('test');
|
||||||
|
$message = $this->messageBuilder->getMessage();
|
||||||
|
$this->assertEquals(
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'fileContent' => '12345',
|
||||||
|
'filename' => null,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'fileContent' => 'test',
|
||||||
|
'filename' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
$message['attachment']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddInlineImages()
|
public function testAddInlineImages()
|
||||||
{
|
{
|
||||||
$this->messageBuilder->addInlineImage('@../TestAssets/mailgun_icon.png');
|
$this->messageBuilder->addInlineImage('@../TestAssets/mailgun_icon.png');
|
||||||
|
Loading…
Reference in New Issue
Block a user