/** * Test if e-mail-service adds attachment * * @test * @return void */ public function sendEmailMessageWithValidEmailsAddsAttachments() { $sender = '*****@*****.**'; $recipient = '*****@*****.**'; $subject = 'A subject'; $body = 'A body'; $senderName = 'Sender name'; $attachments = [GeneralUtility::getFileAbsFileName('EXT:sf_event_mgt/Tests/Unit/Fixtures/Attachment.txt')]; $mailer = $this->getMock('TYPO3\\CMS\\Core\\Mail\\MailMessage', [], [], '', false); $mailer->expects($this->once())->method('setFrom')->with($this->equalTo($sender), $this->equalTo($senderName)); $mailer->expects($this->once())->method('setSubject')->with($subject); $mailer->expects($this->once())->method('setBody')->with($this->equalTo($body), $this->equalTo('text/html')); $mailer->expects($this->once())->method('setTo')->with($recipient); $mailer->expects($this->once())->method('attach'); $mailer->expects($this->once())->method('send'); $mailer->expects($this->once())->method('isSent')->will($this->returnValue(true)); $this->subject->_set('mailer', $mailer); $result = $this->subject->sendEmailMessage($sender, $recipient, $subject, $body, $senderName, $attachments); $this->assertTrue($result); }
/** * Test if e-mail-service sends mails, if e-mails are valid * * @test * @return void */ public function sendEmailMessageWithValidEmailsTest() { $sender = '*****@*****.**'; $recipient = '*****@*****.**'; $subject = 'A subject'; $body = 'A body'; $senderName = 'Sender name'; $mailer = $this->getMock('TYPO3\\CMS\\Core\\Mail\\MailMessage', array(), array(), '', FALSE); $mailer->expects($this->once())->method('setFrom')->with($this->equalTo($sender), $this->equalTo($senderName)); $mailer->expects($this->once())->method('setSubject')->with($subject); $mailer->expects($this->once())->method('setBody')->with($this->equalTo($body), $this->equalTo('text/html')); $mailer->expects($this->once())->method('setTo')->with($recipient); $mailer->expects($this->once())->method('send'); $mailer->expects($this->once())->method('isSent')->will($this->returnValue(TRUE)); $this->subject->_set('mailer', $mailer); $result = $this->subject->sendEmailMessage($sender, $recipient, $subject, $body, $senderName); $this->assertTrue($result); }