Example #1
0
 public function testSend()
 {
     $this->if($adapter = new atoum\test\adapter())->and($adapter->mail = function () {
     })->and($mail = new mailers\mail($adapter))->then->exception(function () use($mail) {
         $mail->send(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('To is undefined')->if($mail->addTo($to = uniqid()))->then->exception(function () use($mail) {
         $mail->send(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Subject is undefined')->if($mail->setSubject($subject = uniqid()))->then->exception(function () use($mail) {
         $mail->send(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('From is undefined')->if($mail->setFrom($from = uniqid()))->then->exception(function () use($mail) {
         $mail->send(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('Reply to is undefined')->if($mail->setReplyTo($replyTo = uniqid()))->then->exception(function () use($mail) {
         $mail->send(uniqid());
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime')->hasMessage('X-mailer is undefined')->if($mail->setXMailer($mailer = uniqid()))->then->object($mail->send($message = uniqid()))->isIdenticalTo($mail)->adapter($adapter)->call('mail')->withArguments($mail->getTo(), $mail->getSubject(), $message, 'From: ' . $from . "\r\n" . 'Reply-To: ' . $replyTo . "\r\n" . 'X-Mailer: ' . $mailer)->once()->assert->if($mail->setContentType($type = uniqid(), $charset = uniqid()))->then->object($mail->send($message = uniqid()))->isIdenticalTo($mail)->adapter($adapter)->call('mail')->withArguments($mail->getTo(), $mail->getSubject(), $message, 'From: ' . $from . "\r\n" . 'Reply-To: ' . $replyTo . "\r\n" . 'X-Mailer: ' . $mailer . "\r\n" . 'Content-Type: ' . $type . '; charset="' . $charset . '"')->once();
 }
Example #2
0
 public function test__construct()
 {
     $mail = new mailers\mail();
     $this->assert->variable($mail->getTo())->isNull()->variable($mail->getFrom())->isNull()->variable($mail->getSubject())->isNull()->variable($mail->getReplyTo())->isNull()->variable($mail->getXMailer())->isNull();
     $adapter = new atoum\test\adapter();
     $mail = new mailers\mail($adapter);
     $this->assert->object($mail->getAdapter())->isIdenticalTo($adapter);
 }