【问题标题】:Where is the documentation what $mailable string of is Mail::assertNotQueued()?Mail::assertNotQueued() 的 $mailable 字符串在哪里?
【发布时间】:2020-03-03 23:22:24
【问题描述】:

我今天早上在 Laravel 中做了一些邮件测试,结果很有效。

现在想测试队列,看到Mail::assertNotQueued(...)

就像Laravel Docs 中所说的那样。该方法需要一个 $mailable 字符串。详情见here。但是我查看了文档,没有找到任何说明这个“可邮寄字符串”是什么的内容......

执行Mail::assertNotQueued(new WorkflowEMail());,显然失败了,因为 class != string。

这是我的测试类:

class WorkflowEmailTest extends TestCase
{
use DatabaseMigrations;

/** @test **/
public function an_workflow_email_is_send()
{

    //$this->markTestSkipped('must be revisited.');
    $this->withoutExceptionHandling();

    Mail::fake();

    Mail::assertNotQueued(new WorkflowEMail());

    Mail::to('test@apitest.test')->send(new WorkflowEMail());

    Mail::assertQueued(WorkflowEMail::class,1);

}

谁能指出我的文档或告诉我如何正确测试它?

【问题讨论】:

    标签: laravel email mocking phpunit


    【解决方案1】:

    所有的模拟方法都需要一个 class 字符串传递给它,docs

    Mail::assertNotQueued(WorkflowEMail::class);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 1970-01-01
      • 2013-10-08
      • 2023-03-11
      • 2018-05-30
      • 2016-09-18
      • 1970-01-01
      相关资源
      最近更新 更多