From 01e9c22695a3e495f07ab445750221af72e09fe4 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 5 Sep 2018 13:40:03 +0200 Subject: Implemented mailing abstraction Closes #434 --- tests/Unit/Mail/Transport/LogTransportTest.php | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/Unit/Mail/Transport/LogTransportTest.php (limited to 'tests/Unit/Mail/Transport/LogTransportTest.php') diff --git a/tests/Unit/Mail/Transport/LogTransportTest.php b/tests/Unit/Mail/Transport/LogTransportTest.php new file mode 100644 index 00000000..5eb3a667 --- /dev/null +++ b/tests/Unit/Mail/Transport/LogTransportTest.php @@ -0,0 +1,60 @@ +getMockForAbstractClass(LoggerInterface::class); + /** @var SimpleMessage|MockObject $message */ + $message = $this->createMock(SimpleMessage::class); + + $message->expects($this->once()) + ->method('getSubject') + ->willReturn('Some subject'); + $message->expects($this->once()) + ->method('getHeaders') + ->willReturn('Head: er'); + $message->expects($this->once()) + ->method('toString') + ->willReturn('Message body'); + + $logger->expects($this->once()) + ->method('debug') + ->willReturnCallback(function ($message, $context = []) { + foreach (array_keys($context) as $key) { + $this->assertContains(sprintf('{%s}', $key), $message); + } + + $this->assertEquals('Some subject', $context['title']); + $this->assertEquals('foo@bar.batz,Lorem Ipsum ', $context['recipients']); + $this->assertContains('Head: er', $context['content']); + $this->assertContains('Message body', $context['content']); + }); + + /** @var LogTransport|MockObject $transport */ + $transport = $this->getMockBuilder(LogTransport::class) + ->setConstructorArgs(['logger' => $logger]) + ->setMethods(['allRecipients']) + ->getMock(); + $transport->expects($this->exactly(2)) + ->method('allRecipients') + ->with($message) + ->willReturn(['foo@bar.batz' => null, 'lor@em.ips' => 'Lorem Ipsum']); + + $return = $transport->send($message); + $this->equalTo(2, $return); + } +} -- cgit v1.2.3-54-g00ecf