我有一些发送电子邮件的代码:
class Mailer extends Component implements SenderContract
{
const EVENT_SEND = 'send';
public function init(){
$this->on(self::EVENT_SEND, [$this, 'send']);
}
public function send(MessageContract $event)
{
\Yii::$app->mailer->compose(['html' => 'layouts/html'],
['content' => $event->getMessage()])
->setFrom([\Yii::$app->params['adminEmail'] => 'theme message'])
->setTo($event->getSender())
->setSubject('new message')
->send();
}
}
我使用代码单元测试。我如何模拟send()方法?