mirror of
https://github.com/symfony/recipes-contrib.git
synced 2026-03-24 00:32:17 +01:00
Provide basic recipe for FriendsOfBehat/SymfonyExtension v2
This commit is contained in:
8
friends-of-behat/symfony-extension/2.0/behat.yml.dist
Normal file
8
friends-of-behat/symfony-extension/2.0/behat.yml.dist
Normal file
@@ -0,0 +1,8 @@
|
||||
default:
|
||||
suites:
|
||||
default:
|
||||
contexts:
|
||||
- App\Tests\Behat\DemoContext
|
||||
|
||||
extensions:
|
||||
FriendsOfBehat\SymfonyExtension: ~
|
||||
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
App\Tests\Behat\:
|
||||
resource: '../tests/Behat/*'
|
||||
12
friends-of-behat/symfony-extension/2.0/features/demo.feature
Normal file
12
friends-of-behat/symfony-extension/2.0/features/demo.feature
Normal file
@@ -0,0 +1,12 @@
|
||||
# This file contains a user story for demonstration only.
|
||||
# Learn how to get started with Behat and BDD on Behat's website:
|
||||
# http://behat.org/en/latest/quick_start.html
|
||||
|
||||
Feature:
|
||||
In order to prove 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 a demo scenario sends a request to "/"
|
||||
Then the response should be received
|
||||
12
friends-of-behat/symfony-extension/2.0/manifest.json
Normal file
12
friends-of-behat/symfony-extension/2.0/manifest.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"bundles": {
|
||||
"FriendsOfBehat\\SymfonyExtension\\Bundle\\FriendsOfBehatSymfonyExtensionBundle": ["test"]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"behat.yml.dist": "behat.yml.dist",
|
||||
"config/": "%CONFIG_DIR%/",
|
||||
"features/": "features/",
|
||||
"tests/": "tests/"
|
||||
},
|
||||
"gitignore": ["/behat.yml"]
|
||||
}
|
||||
2
friends-of-behat/symfony-extension/2.0/post-install.txt
Normal file
2
friends-of-behat/symfony-extension/2.0/post-install.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
<bg=blue;fg=white> Next for FriendsOfBehat/SymfonyExtension </>
|
||||
Run <comment>vendor/bin/behat</> to run the demo tests.
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Behat;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* This context class contains the definitions of the steps used by the demo
|
||||
* feature file. Learn how to get started with Behat and BDD on Behat's website.
|
||||
*
|
||||
* @see http://behat.org/en/latest/quick_start.html
|
||||
*/
|
||||
final class DemoContext implements Context
|
||||
{
|
||||
/** @var KernelInterface */
|
||||
private $kernel;
|
||||
|
||||
/** @var Response|null */
|
||||
private $response;
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @When a demo scenario sends a request to :path
|
||||
*/
|
||||
public function aDemoScenarioSendsARequestTo(string $path): void
|
||||
{
|
||||
$this->response = $this->kernel->handle(Request::create($path, 'GET'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the response should be received
|
||||
*/
|
||||
public function theResponseShouldBeReceived(): void
|
||||
{
|
||||
if ($this->response === null) {
|
||||
throw new \RuntimeException('No response received');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user