开发者

Fixtures organization

How do you organize your fixtures inside a Symfony2 project. Is there a standard you can respect so that when you use t开发者_高级运维he doctrine:fixtures:load --env=environment command, only fixtures related to the environment environment are used ? This could be useful because fixtures for production are very likely to be different from fixtures for test.


Make your fixture implement ContainerAwareInterface and inside its load method, you can get the environment with:

$this->container->get('kernel')->getEnvironment();


The current fixtures bundle does not handle this. If you want to load only certain fixtures, you must specify them using the --fixtures repeatable option:

./app/console doctrine:fixtures:load --fixtures=/path/to/fixtures1 --fixtures=/path/to/fixtures2

Anyway, in your tests, I advise you to load your fixtures eagerly, reseting your database before each test.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜