Skip to content

Instantly share code, notes, and snippets.

@tentacode
Last active December 19, 2015 05:59
Show Gist options
  • Save tentacode/5907802 to your computer and use it in GitHub Desktop.
Save tentacode/5907802 to your computer and use it in GitHub Desktop.
How to install a working behat (bin only) on a Symfony project
default:
formatter:
name: pretty
paths:
features: features
context:
class: Context\FeatureContext
extensions:
Behat\MinkExtension\Extension:
default_session: symfony2
show_cmd: 'open -a Firefox.app %s'
base_url: http://myproject.dev
Behat\Symfony2Extension\Extension: ~
{
"autoload": {
"psr-0": {
"": "src/",
"Context": "features/" /*don't forget this*/
}
},
"require": {
...
"behat/behat": "2.4.*@stable",
"behat/mink-extension": "*",
"behat/symfony2-extension": "*",
"behat/mink-browserkit-driver": "*"
},
}
<?php
//this file is in "features/Context/FeatureContext.php"
namespace Context;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Symfony\Component\HttpKernel\KernelInterface;
class FeatureContext extends MinkContext implements KernelAwareInterface
{
private $kernel;
public function __construct()
{
//add sub contexts here
}
/**
* Sets Kernel instance.
*
* @param KernelInterface $kernel HttpKernel instance
*/
public function setKernel(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* Returns Container instance.
*
* @return ContainerInterface
*/
private function getContainer()
{
return $this->kernel->getContainer();
}
}
@homepage
Feature: Homepage working as expected (file is in features/homepage.feature)
Scenario: Homepage login
When I go to "/"
Then I should see "Bienvenue"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment