LogicException:Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector 中缺少默认数据

2024-02-07

在 Symfony 2.5.5 和 Swiftmailer 5.3.0 中出现此异常。我正在关注食谱示例 http://symfony.com/doc/current/cookbook/email/testing.html确切地。调用时抛出错误MessageDataCollector#getMessages():

// Check that an e-mail was sent
$this->assertEquals(1, $mailCollector->getMessageCount());

$collectedMessages = $mailCollector->getMessages();
$message = $collectedMessages[0]; 

消息计数断言也失败,值为零。

据我所知,收集者没有在行动中进行任何实际的收集。有任何想法吗?


我申请后也遇到同样的问题克里斯沃尔史密斯的测试优化技巧 http://kriswallsmith.net/post/27979797907/get-fast-an-easy-symfony2-phpunit-optimization。运行开发版本时,我可以在Web Profiler中看到邮件发送的结果,但在测试环境中无法获取数据。

应用克里斯的技巧后,我注意到swiftmailer.mailer.default.plugin.messagelogger测试期间服务未注册到容器中,因此收集()方法 of the 消息数据收集器类没有记录邮件发送的数据。这就是无法从 swiftmailer 收集器检索信息的原因。

解决方案是要么不覆盖初始化容器()中的方法应用程序内核.php或覆盖它,但要确保消息记录器服务可用于发送邮件的测试用例。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

LogicException:Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector 中缺少默认数据 的相关文章

随机推荐