Skip to content

Commit

Permalink
Add example of using DoctrineFixturesContext to README
Browse files Browse the repository at this point in the history
  • Loading branch information
fre5h committed Dec 25, 2012
1 parent 1f5d84a commit e57be2b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -26,7 +26,38 @@ class FeatureContext extends BehatContext
{ {
public function __construct() public function __construct()
{ {
// To use SymfonyMailerContext in your steps
$this->useContext('symfony_extra', new SymfonyMailerContext()); $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);
} }
} }


Expand Down

0 comments on commit e57be2b

Please sign in to comment.