diff --git a/tests/unit/framework/mail/BaseMailerTest.php b/tests/unit/framework/mail/BaseMailerTest.php index 1c3ee22..54a7952 100644 --- a/tests/unit/framework/mail/BaseMailerTest.php +++ b/tests/unit/framework/mail/BaseMailerTest.php @@ -230,6 +230,17 @@ class BaseMailerTest extends TestCase $this->assertTrue(is_file($file)); $this->assertEquals($message->toString(), file_get_contents($file)); } + + public function testBeforeSendEvent() + { + $message = new Message(); + + $mailerMock = $this->getMockBuilder('yiiunit\framework\mail\Mailer')->setMethods(['beforeSend','afterSend'])->getMock(); + $mailerMock->expects($this->once())->method('beforeSend')->with($message)->will($this->returnValue(true)); + $mailerMock->expects($this->once())->method('afterSend')->with($message,true); + $mailerMock->send($message); + } + } /** @@ -243,6 +254,7 @@ class Mailer extends BaseMailer protected function sendMessage($message) { $this->sentMessages[] = $message; + return true; } }