summaryrefslogtreecommitdiff
path: root/tests/Unit/Mail/EngelsystemMailerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Mail/EngelsystemMailerTest.php')
-rw-r--r--tests/Unit/Mail/EngelsystemMailerTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/Unit/Mail/EngelsystemMailerTest.php b/tests/Unit/Mail/EngelsystemMailerTest.php
index aae6e267..0f60ff3b 100644
--- a/tests/Unit/Mail/EngelsystemMailerTest.php
+++ b/tests/Unit/Mail/EngelsystemMailerTest.php
@@ -7,6 +7,7 @@ use Engelsystem\Renderer\Renderer;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Swift_Mailer as SwiftMailer;
+use Swift_Message as SwiftMessage;
class EngelsystemMailerTest extends TestCase
{
@@ -37,4 +38,53 @@ class EngelsystemMailerTest extends TestCase
$return = $mailer->sendView('foo@bar.baz', 'Lorem dolor', 'test/template.tpl', ['dev' => true]);
$this->equalTo(1, $return);
}
+
+ /**
+ * @covers \Engelsystem\Mail\EngelsystemMailer::send
+ * @covers \Engelsystem\Mail\EngelsystemMailer::setSubjectPrefix
+ * @covers \Engelsystem\Mail\EngelsystemMailer::getSubjectPrefix
+ */
+ public function testSend()
+ {
+ /** @var SwiftMessage|MockObject $message */
+ $message = $this->createMock(SwiftMessage::class);
+ /** @var SwiftMailer|MockObject $swiftMailer */
+ $swiftMailer = $this->createMock(SwiftMailer::class);
+ $swiftMailer->expects($this->once())
+ ->method('createMessage')
+ ->willReturn($message);
+ $swiftMailer->expects($this->once())
+ ->method('send')
+ ->willReturn(1);
+
+ $message->expects($this->once())
+ ->method('setTo')
+ ->with(['to@xam.pel'])
+ ->willReturn($message);
+
+ $message->expects($this->once())
+ ->method('setFrom')
+ ->with('foo@bar.baz', 'Lorem Ipsum')
+ ->willReturn($message);
+
+ $message->expects($this->once())
+ ->method('setSubject')
+ ->with('[Mail test] Foo Bar')
+ ->willReturn($message);
+
+ $message->expects($this->once())
+ ->method('setBody')
+ ->with('Lorem Ipsum!')
+ ->willReturn($message);
+
+ $mailer = new EngelsystemMailer($swiftMailer);
+ $mailer->setFromAddress('foo@bar.baz');
+ $mailer->setFromName('Lorem Ipsum');
+ $mailer->setSubjectPrefix('Mail test');
+
+ $this->assertEquals('Mail test', $mailer->getSubjectPrefix());
+
+ $return = $mailer->send('to@xam.pel', 'Foo Bar', 'Lorem Ipsum!');
+ $this->equalTo(1, $return);
+ }
}