【发布时间】:2022-08-16 13:33:24
【问题描述】:
测试我的电子邮件发送逻辑,不会捕获发送到 mailhog 的电子邮件。
// Both ways don\'t work
$this->assertEmailCount(1, \'smtp://mailhog:1025\');
$this->assertEmailCount(1);
我得到的两个错误:
断言传输 smtp://mailhog:1025 已发送“1”电子邮件(已发送 0)失败。
断言传输已发送“1”电子邮件(已发送 0)失败。
电子邮件已发送。我在mailhog中看到它。每次我运行测试。
private function getMailer(array $mailConfig): MailerInterface { $dsn = match (strtolower($mailConfig[\'transport\'])) { \'sendgrid\' => \'smtp://mailhog:1025\', \'mailchimp\' => \'smtp://mailhog:1025\', default => \'smtp://mailhog:1025\' }; $transport = Transport::fromDsn($dsn); return new Mailer($transport); }也发布发送功能,但认为何时发送电子邮件并不重要。用 mailhog 测试时有什么特别的吗?
-
你检查过不同的环境配置吗?
标签: symfony phpunit integration-testing mailhog