Skip to content

Instantly share code, notes, and snippets.

@marijn
Created January 28, 2013 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marijn/4655089 to your computer and use it in GitHub Desktop.
Save marijn/4655089 to your computer and use it in GitHub Desktop.
Example organization of context files in Behat.
<?php
use Behat\Behat\Context\BehatContext;
final class CustomerContext extends BehatContext
{
// ... your step definitions related to customer
}
<?php
require_once "PHPUnit/Framework/Assert/Functions.php";
use Behat\Behat\Context\BehatContext;
final class FeatureContext extends BehatContext
{
public function __construct(array $parameters = array())
{
// customer context contains all the step definitions related to customer role
$this->useContext('customer', new CustomerContext());
// merchant context contains all the step definitions related to merchant role
$this->useContext('merchant', new MerchantContext($parameters['merchant_id']));
}
}
<?php
use Behat\Behat\Context\BehatContext;
final class MerchantContext extends BehatContext
{
private $merchantId;
public function __construct($merchantId)
{
$this->merchantId = $merchantId;
}
// ... your step definitions related to merchant
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment