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/TransportTest.php | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/Unit/Mail/Transport/TransportTest.php (limited to 'tests/Unit/Mail/Transport/TransportTest.php') diff --git a/tests/Unit/Mail/Transport/TransportTest.php b/tests/Unit/Mail/Transport/TransportTest.php new file mode 100644 index 00000000..60f2079d --- /dev/null +++ b/tests/Unit/Mail/Transport/TransportTest.php @@ -0,0 +1,83 @@ +assertTrue($transport->isStarted()); + $this->assertTrue($transport->ping()); + } + + /** + * @covers \Engelsystem\Mail\Transport\Transport::allRecipients + */ + public function testAllRecipients() + { + /** @var SimpleMessage|MockObject $message */ + $message = $this->createMock(SimpleMessage::class); + $transport = new TransportImplementation(); + $message->expects($this->once()) + ->method('getTo') + ->willReturn([ + 'foo@bar.batz' => 'Foo Bar', + 'lorem@ipsum.dolor' => null, + ]); + $message->expects($this->once()) + ->method('getCc') + ->willReturn([ + 'to@bar.batz' => null, + ]); + $message->expects($this->once()) + ->method('getBcc') + ->willReturn([ + 'secret@bar.batz' => 'I\'m secret!', + ]); + + $this->assertEquals( + [ + 'foo@bar.batz' => 'Foo Bar', + 'lorem@ipsum.dolor' => null, + 'to@bar.batz' => null, + 'secret@bar.batz' => 'I\'m secret!', + ], + $transport->getAllRecipients($message) + ); + } + + /** + * @covers \Engelsystem\Mail\Transport\Transport::getTo + * @covers \Engelsystem\Mail\Transport\Transport::formatTo + */ + public function testGetTo() + { + /** @var SimpleMessage|MockObject $message */ + $message = $this->createMock(SimpleMessage::class); + /** @var TransportImplementation|MockObject $transport */ + $transport = $this->getMockBuilder(TransportImplementation::class) + ->setMethods(['allRecipients']) + ->getMock(); + $transport->expects($this->once()) + ->method('allRecipients') + ->with($message) + ->willReturn([ + 'foo@bar.batz' => null, + 'lorem@ipsum.dolor' => 'Developer', + ]); + + $return = $transport->getGetTo($message); + $this->assertEquals('foo@bar.batz,Developer ', $return); + } +} -- cgit v1.2.3-70-g09d2