diff options
Diffstat (limited to 'tests/Unit/Mail/EngelsystemMailerTest.php')
-rw-r--r-- | tests/Unit/Mail/EngelsystemMailerTest.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Unit/Mail/EngelsystemMailerTest.php b/tests/Unit/Mail/EngelsystemMailerTest.php new file mode 100644 index 00000000..aae6e267 --- /dev/null +++ b/tests/Unit/Mail/EngelsystemMailerTest.php @@ -0,0 +1,40 @@ +<?php + +namespace Engelsystem\Test\Unit\Mail; + +use Engelsystem\Mail\EngelsystemMailer; +use Engelsystem\Renderer\Renderer; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Swift_Mailer as SwiftMailer; + +class EngelsystemMailerTest extends TestCase +{ + /** + * @covers \Engelsystem\Mail\EngelsystemMailer::__construct + * @covers \Engelsystem\Mail\EngelsystemMailer::sendView + */ + public function testSendView() + { + /** @var Renderer|MockObject $view */ + $view = $this->createMock(Renderer::class); + /** @var SwiftMailer|MockObject $swiftMailer */ + $swiftMailer = $this->createMock(SwiftMailer::class); + /** @var EngelsystemMailer|MockObject $mailer */ + $mailer = $this->getMockBuilder(EngelsystemMailer::class) + ->setConstructorArgs(['mailer' => $swiftMailer, 'view' => $view]) + ->setMethods(['send']) + ->getMock(); + $mailer->expects($this->once()) + ->method('send') + ->with('foo@bar.baz', 'Lorem dolor', 'Rendered Stuff!') + ->willReturn(1); + $view->expects($this->once()) + ->method('render') + ->with('test/template.tpl', ['dev' => true]) + ->willReturn('Rendered Stuff!'); + + $return = $mailer->sendView('foo@bar.baz', 'Lorem dolor', 'test/template.tpl', ['dev' => true]); + $this->equalTo(1, $return); + } +} |