示例#1
0
文件: mail.php 项目: xihewang/atoum
 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();
 }
示例#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);
 }
示例#3
0
文件: mail.php 项目: xihewang/atoum
 public function testWriteAsynchronousReport()
 {
     $this->if($mailer = new atoum\mailers\mail())->and($writer = new \mock\mageekguy\atoum\writers\mail($mailer, $locale = new \mock\mageekguy\atoum\locale(), $adapter = new atoum\test\adapter()))->and($writer->getMockController()->write = $writer)->and($adapter->date = function ($arg) {
         return $arg;
     })->then->object($writer->writeAsynchronousReport($report = new \mock\mageekguy\atoum\reports\asynchronous()))->isIdenticalTo($writer)->mock($writer)->call('write')->withArguments((string) $report)->once()->string($mailer->getSubject())->isEqualTo('Unit tests report, the Y-m-d at H:i:s')->mock($locale)->call('_')->withArguments('Unit tests report, the %1$s at %2$s')->once()->call('_')->withArguments('Y-m-d')->once()->call('_')->withArguments('H:i:s')->once()->if($mailer = new atoum\mailers\mail())->and($writer = new \mock\mageekguy\atoum\writers\mail($mailer, $locale = new \mock\mageekguy\atoum\locale(), $adapter = new atoum\test\adapter()))->and($writer->getMockController()->write = $writer)->then->object($writer->writeAsynchronousReport($report->setTitle($title = uniqid())))->isIdenticalTo($writer)->mock($writer)->call('write')->withArguments((string) $report)->once()->string($mailer->getSubject())->isEqualTo($title)->mock($locale)->call('_')->never()->if($mailer->setSubject($mailerSubject = uniqid()))->and($this->resetMock($writer))->then->object($writer->writeAsynchronousReport($report))->isIdenticalTo($writer)->mock($writer)->call('write')->withArguments((string) $report)->once()->string($mailer->getSubject())->isEqualTo($mailerSubject);
 }