Add the Behat recipe

This commit is contained in:
Samuel ROZE
2017-06-05 19:14:00 +01:00
parent 5eacde060f
commit d31e56a20a
6 changed files with 80 additions and 0 deletions
@@ -0,0 +1,13 @@
default:
suites:
default:
contexts:
- FeatureContext:
kernel: '@kernel'
extensions:
Behat\Symfony2Extension:
kernel:
bootstrap: features/bootstrap/bootstrap.php
path: src/Kernel.php
class: App\Kernel
@@ -0,0 +1,40 @@
<?php
use Behat\Behat\Context\Context;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
class FeatureContext implements Context
{
/**
* @var KernelInterface
*/
private $kernel;
/**
* @var Response|null
*/
private $response;
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* @When this is a demo scenario that sends a request to :path
*/
public function thisIsADemoScenarioThatSendsARequestTo(string $path)
{
$this->response = $this->kernel->handle(Request::create($path, 'GET'));
}
/**
* @Then the response should be received
*/
public function theResponseShouldBeReceived()
{
assert($this->response !== null);
}
}
@@ -0,0 +1,10 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require __DIR__.'/../../vendor/autoload.php';
// The check is to ensure we don't use .env in production
if (!getenv('APP_ENV')) {
(new Dotenv())->load(__DIR__.'/../../.env');
}
@@ -0,0 +1,8 @@
Feature:
In order to proves that the Behat Symfony extension is correctly installed
As a user
I want to have a demo scenario
Scenario: It receives a response from Symfony's kernel
When this is a demo scenario that sends a request to "/"
Then the response should be received
@@ -0,0 +1,7 @@
{
"copy-from-recipe": {
"behat.yml.dist": "behat.yml.dist",
"features/": "features/"
},
"aliases": ["behat"]
}
@@ -0,0 +1,2 @@
<bg=blue;fg=white> Next for Behat/SymfonyExtension </>
Run <comment>vendor/bin/behat</> to run the demo tests.