Permalink
Browse files

Add example of using DoctrineFixturesContext to README

  • Loading branch information...
1 parent 1f5d84a commit e57be2bafcdc0daf670b4c8bd50adafdb65f22de @fre5h fre5h committed Dec 25, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0 README.md
View
@@ -26,7 +26,38 @@ class FeatureContext extends BehatContext
{
public function __construct()
{
+ // To use SymfonyMailerContext in your steps
$this->useContext('symfony_extra', new SymfonyMailerContext());
+
+ // To use DoctrineFixturesContext in your steps
+ $this->useContext('doctrine_fixtures_context', new DoctrineFixturesContext());
+ }
+
+ /**
+ * Example of using DoctrineFixturesContext in BeforeScenario hook
+ *
+ * @BeforeScenario
+ */
+ public function beforeScen()
+ {
+ $loader = new Loader();
+
+ $this->getMainContext()
+ ->getSubcontext('doctrine_fixtures_context')
+ ->loadFixtureClasses($loader, array(
+ 'Acme\Bundle\DefaultBundle\DataFixtures\ORM\LoadNewsData',
+ 'Acme\Bundle\DefaultBundle\DataFixtures\ORM\LoadPagesData',
+ 'Acme\Bundle\DefaultBundle\DataFixtures\ORM\LoadReviewData',
+ 'Acme\Bundle\DefaultBundle\DataFixtures\ORM\LoadTicketData',
+ ));
+
+ /** @var $em \Doctrine\ORM\EntityManager */
+ $em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
+
+ $purger = new ORMPurger();
+ $executor = new ORMExecutor($em, $purger);
+ $executor->purge();
+ $executor->execute($loader->getFixtures(), true);
}
}

0 comments on commit e57be2b

Please sign in to comment.