mirror of
https://github.com/symfony/recipes.git
synced 2026-09-20 03:26:23 +03:00
181 lines
8.7 KiB
JSON
181 lines
8.7 KiB
JSON
{
|
|
"manifests": {
|
|
"behat/symfony2-extension": {
|
|
"manifest": {
|
|
"copy-from-recipe": {
|
|
"behat.yml.dist": "behat.yml.dist",
|
|
"features/": "features/",
|
|
"src/": "%SRC_DIR%/"
|
|
},
|
|
"gitignore": [
|
|
"behat.yml"
|
|
],
|
|
"post-install-output": [
|
|
"<bg=blue;fg=white> Next for Behat/SymfonyExtension </>",
|
|
" Run <comment>vendor/bin/behat</> to run the demo tests."
|
|
]
|
|
},
|
|
"files": {
|
|
"behat.yml.dist": {
|
|
"contents": [
|
|
"default:",
|
|
" suites:",
|
|
" default:",
|
|
" contexts:",
|
|
" - FeatureContext:",
|
|
" kernel: '@kernel'",
|
|
"",
|
|
" extensions:",
|
|
" Behat\\Symfony2Extension:",
|
|
" kernel:",
|
|
" bootstrap: features/bootstrap/bootstrap.php",
|
|
" class: App\\Kernel",
|
|
""
|
|
],
|
|
"executable": false
|
|
},
|
|
"features/bootstrap/FeatureContext.php": {
|
|
"contents": [
|
|
"<?php",
|
|
"",
|
|
"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",
|
|
" */",
|
|
"class FeatureContext 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)",
|
|
" {",
|
|
" $this->response = $this->kernel->handle(Request::create($path, 'GET'));",
|
|
" }",
|
|
"",
|
|
" /**",
|
|
" * @Then the response should be received",
|
|
" */",
|
|
" public function theResponseShouldBeReceived()",
|
|
" {",
|
|
" if ($this->response === null) {",
|
|
" throw new \\RuntimeException('No response received');",
|
|
" }",
|
|
" }",
|
|
"}",
|
|
""
|
|
],
|
|
"executable": false
|
|
},
|
|
"features/bootstrap/bootstrap.php": {
|
|
"contents": [
|
|
"<?php",
|
|
"",
|
|
"putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'test');",
|
|
"require dirname(__DIR__, 2).'/src/.bootstrap.php';",
|
|
""
|
|
],
|
|
"executable": false
|
|
},
|
|
"features/demo.feature": {
|
|
"contents": [
|
|
"# 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",
|
|
""
|
|
],
|
|
"executable": false
|
|
},
|
|
"src/.bootstrap.php": {
|
|
"contents": [
|
|
"<?php",
|
|
"",
|
|
"use Symfony\\Component\\Dotenv\\Dotenv;",
|
|
"",
|
|
"require dirname(__DIR__).'/vendor/autoload.php';",
|
|
"",
|
|
"if (!array_key_exists('APP_ENV', $_SERVER)) {",
|
|
" $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;",
|
|
"}",
|
|
"",
|
|
"if ('prod' !== $_SERVER['APP_ENV']) {",
|
|
" if (!class_exists(Dotenv::class)) {",
|
|
" throw new RuntimeException('The \"APP_ENV\" environment variable is not set to \"prod\". Please run \"composer require symfony/dotenv\" to load the \".env\" files configuring the application.');",
|
|
" }",
|
|
"",
|
|
" $path = dirname(__DIR__).'/.env';",
|
|
" $dotenv = new Dotenv();",
|
|
"",
|
|
" if (method_exists($dotenv, 'loadEnv')) {",
|
|
" $dotenv->loadEnv($path);",
|
|
" } else {",
|
|
" // fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)",
|
|
"",
|
|
" if (file_exists($path) || !file_exists($p = \"$path.dist\")) {",
|
|
" $dotenv->load($path);",
|
|
" } else {",
|
|
" $dotenv->load($p);",
|
|
" }",
|
|
"",
|
|
" if (null === $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) {",
|
|
" $dotenv->populate(array('APP_ENV' => $env = 'dev'));",
|
|
" }",
|
|
"",
|
|
" if ('test' !== $env && file_exists($p = \"$path.local\")) {",
|
|
" $dotenv->load($p);",
|
|
" $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env;",
|
|
" }",
|
|
"",
|
|
" if (file_exists($p = \"$path.$env\")) {",
|
|
" $dotenv->load($p);",
|
|
" }",
|
|
"",
|
|
" if (file_exists($p = \"$path.$env.local\")) {",
|
|
" $dotenv->load($p);",
|
|
" }",
|
|
" }",
|
|
"}",
|
|
"",
|
|
"$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';",
|
|
"$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];",
|
|
"$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';",
|
|
""
|
|
],
|
|
"executable": false
|
|
}
|
|
},
|
|
"ref": "ec8e855d4dae5e2627ea6ec5d8e8cfb7ed9e0c10"
|
|
}
|
|
}
|
|
}
|