Last active
December 19, 2015 05:59
-
-
Save tentacode/5907802 to your computer and use it in GitHub Desktop.
How to install a working behat (bin only) on a Symfony project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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": "*" | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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