我需要将Mailable类型添加到我的模拟ActivationMail中。也许你最好嘲笑我的ActivationMail
课程?
经过测试的课程:
class MailService
{
public function sendActivationEmail(User $user): void
{
$this->sendEmail(new ActivationMail($user));
}
//content
protected function sendEmail(Mailable $mailable): void
{
//content
}
}
ActivationMail:
class ActivationMail extends Mailable{}
你知道我该怎么测试呢? 我的测试:
public function test_sendActivationEmail()
{
$user = Mockery::mock(User::class);
$mailable = Mockery::mock(Mailable::class);
Mockery::mock('overload:App\Mail\ActivationMail');
$mailService = new MailService();
$mailService->sendActivationEmail($user);
}
我的错误:
TypeError:参数1传递给App \ Services \ MailService :: sendEmail() 必须是Illuminate \ Mail \ Mailable的实例,实例 给出了App \ Mail \ ActivationMail