2017 © Pedro Peláez
 

library common-contexts

Commonly used contexts for Behat

image

behat/common-contexts

Commonly used contexts for Behat

  • Thursday, April 7, 2016
  • by everzet
  • Repository
  • 8 Watchers
  • 124 Stars
  • 1,162,767 Installations
  • PHP
  • 12 Dependents
  • 0 Suggesters
  • 33 Forks
  • 12 Open issues
  • 6 Versions
  • 2 % Grown

The README.md

THIS PROJECT IS ABANDONED

This project is effectively abandoned. If you want to take ownership or contribute to it, contact @everzet., (*1)

Extra Contexts for Behat

This additional contexts could be used as your feature suite's submodules, giving you extra steps and hooks right out of the box., (*2)

How to use them

To use those contexts, you should simply instantiate them with needed arguments (see constructor arguments) and pass them into useContext() function like that:, (*3)

``` php <?php, (*4)

namespace Acme\DemoBundle\Features\Context;, (*5)

use Behat\Behat\Context\BehatContext; use Behat\CommonContexts\SymfonyMailerContext; use Behat\CommonContexts\DoctrineFixturesContext;, (*6)

/** * Feature context. */ class FeatureContext extends BehatContext { public function __construct() { // To use SymfonyMailerContext in your steps $this->useContext('symfony_extra', new SymfonyMailerContext());, (*7)

    // 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);
}

}, (*8)



### Example: Using SymfonyDoctrineContext to reset Doctrine database schema in Symfony framework before scenario starts ``` php <?php namespace Acme\DemoBundle\Features\Context; use Behat\Behat\Context\BehatContext; use Behat\CommonContexts\SymfonyDoctrineContext; /** * Feature context. */ class FeatureContext extends BehatContext { public function __construct() { // Connects SymfonyDoctrineContext $this->useContext('symfony_doctrine_context', new SymfonyDoctrineContext); } /** * Clean database before scenario starts * * @BeforeScenario */ public function beforeScenario($event) { // Asks subcontext SymfonyDoctrineContext to rebuild database schema $this ->getMainContext() ->getSubcontext('symfony_doctrine_context') ->buildSchema($event); } }

The Versions

07/04 2016

dev-master

9999999-dev http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context

09/04 2013

v1.2.0

1.2.0.0 http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context

11/05 2012

v1.1.1

1.1.1.0 http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context

18/01 2012

v1.1.0

1.1.0.0 http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context

04/01 2012

v1.0.0

1.0.0.0 http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context

04/01 2012

dev-mink_subcontext

dev-mink_subcontext http://behat.org/

Commonly used contexts for Behat

  Sources   Download

MIT

The Requires

 

bdd symfony2 behat context