0
也许我已经过度复杂化了,但我有一个电子邮件对象被另一个类调用,而Email类使用Swift Mailer的一个实例。PHPUnit测试SwiftMail发送方法参数
$email = Email::instance();
$mailer = $this->getMock('Swift_Mailer', array('send'), array(new \Swift_NullTransport()));
$email->setTransport($mailer);
$mailer->expects($this->once())
->method('send');
$model->sendEmail('[email protected]');
正如上面我可以很容易地测试,如果发送方法被调用,并正确地确认该邮件被发送,但是,我需要测试从正在与发送的雨燕梅勒信息的主题邮件。
$email = Email::instance();
$mailer = $this->getMock('Swift_Mailer', array('send'), array(new \Swift_NullTransport()));
$email->setTransport($mailer);
$mailer->expects($this->once())
->method('send')
->with($this->equalTo('new email subject'));
很明显,这不起作用,并引发了很多错误。
任何想法,我怎么可以测试这个?