LogicException:缺少Symfony \ Bundle \ SwiftmailerBundle \ DataCollector \ MessageDataCollector中的默认数据 [英] LogicException: Missing default data in Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector

查看:118
本文介绍了LogicException:缺少Symfony \ Bundle \ SwiftmailerBundle \ DataCollector \ MessageDataCollector中的默认数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在带有Swiftmailer 5.3.0的Symfony 2.5.5中获得此异常.我正在严格按照烹饪书示例进行操作.调用MessageDataCollector#getMessages()时抛出错误:

Getting this exception in Symfony 2.5.5 with Swiftmailer 5.3.0. I'm following the cookbook example exactly. The error is thrown when calling MessageDataCollector#getMessages():

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

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

消息计数声明也失败,值为零.

The message count assertion is also failing with a value of zero.

据我所知,收集器在操作中没有进行任何实际的收集.有什么想法吗?

As far as I can tell the collector is failing to do any actual collecting in the action. Any ideas?

推荐答案

应用

I encountered the same problem after I applied kriswallsmith's test optimization trick. I could see the result of the mail sending in the web profiler when running the development version, but couldn't get the data in the testing environment.

在应用了Kris的技巧之后,我注意到 swiftmailer.mailer.default.plugin.messagelogger 服务在测试过程中未在容器中注册,因此 collect()方法 MessageDataCollector类的"strong"没有记录用于发送邮件的数据.这就是为什么无法从swiftmailer收集器中检索信息的原因.

After applying Kris' trick I noticed that the swiftmailer.mailer.default.plugin.messagelogger service was not registered with the container during the test, so the collect() method of the MessageDataCollector class did not log the data for the mail sending. This is why it wasn't possible to retrieve information from the swiftmailer collector.

解决方案是不覆盖 AppKernel.php 中的 initializeContainer()方法,或者覆盖它,但是确保 messagelogger 服务可用于发送邮件的测试用例.

The solution is either not to overrride the initializeContainer() method in AppKernel.php or to override it, but making sure messagelogger service is available for test cases that send mails.

这篇关于LogicException:缺少Symfony \ Bundle \ SwiftmailerBundle \ DataCollector \ MessageDataCollector中的默认数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆