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.
精彩评论