且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Symfony 2 中从功能测试中加载固定装置

更新时间:2023-11-26 20:48:16

您可以在测试的 setUp() 方法中加载固定装置,如 这个问题.p>

您可以使用问题中的代码,但需要将 --append 附加到 doctrine:fixtures:load 命令以避免被夹具确认-捆绑.

更好的解决方案是查看 LiipFunctionalTestBundle,它可以更轻松地使用数据夹具.

My DoctrineFixturesBundle is installed and I can load fixture trough the command-line but , how can I load fixtures from my functional test ?

You can load the fixtures in your test's setUp() method as you can see in this question.

You can use the code in the question but need to append --appendto the doctrine:fixtures:load command in order to avoid the confirmation by the fixtures-bundle.

The better solution is to have a look at the LiipFunctionalTestBundle which makes using data-fixtures easier.