Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created June 19, 2012 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathaningram/2952919 to your computer and use it in GitHub Desktop.
Save jonathaningram/2952919 to your computer and use it in GitHub Desktop.
default:
extensions:
Behat\Symfony2Extension\Extension: ~
Behat\MinkExtension\Extension:
base_url: 'http://localadmin.example.com'
selenium2: ~
sahi: ~
goutte: ~
default_session: goutte
javascript_session: sahi
<?php
use Behat\Behat\Context\ClosuredContextInterface;
use Behat\Behat\Context\TranslatedContextInterface;
use Behat\Behat\Context\BehatContext;
use Behat\Behat\Context\Step;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Mink\Mink;
use Behat\MinkExtension\Context\MinkContext;
use Behat\MinkExtension\Context\MinkAwareInterface;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\CommonContexts\SymfonyDoctrineContext;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';
/**
* Features context.
*/
class FeatureContext extends BehatContext implements MinkAwareInterface, KernelAwareInterface
{
private $mink;
private $minkParameters;
/**
* @var KernelInterface $kernel
*/
private $kernel;
/**
* Initializes context.
*/
public function __construct()
{
$this->useContext('symfony_doctrine', new SymfonyDoctrineContext());
$this->useContext('mink', new MinkContext());
}
/**
* {@inheritdoc}
*/
public function setMink(Mink $mink)
{
$this->mink = $mink;
}
/**
* {@inheritdoc}
*/
public function setMinkParameters(array $parameters)
{
$this->minkParameters = $parameters;
}
/**
* {@inheritdoc}
*/
public function setKernel(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* Returns the kernel's service container.
*
* @return ContainerInterface
*/
public function getContainer()
{
return $this->kernel->getContainer();
}
}
@jonathaningram
Copy link
Author

@everzet wow that's such a comprehensive reply! Thanks! Hopefully you can transform it into a doc article or cookbook entry.

  1. I suppose it's common for a Symfony2 application to put it in a bundle, however, I am trying to avoid having too much code in a bundle (remember your tweet about difference between Components, Bundles and Bridges) so I might try and go with 2.

Just tried it out and 2. seems to be working, so thanks very much for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment