From 01f458149eb8354b10ba1b6e509597ee7bef2a27 Mon Sep 17 00:00:00 2001 From: Kamil Kokot Date: Thu, 10 Jan 2019 23:22:06 +0100 Subject: [PATCH] Test default kernel configuration --- .../configuring_application_kernel.feature | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 features/configuration/configuring_application_kernel.feature diff --git a/features/configuration/configuring_application_kernel.feature b/features/configuration/configuring_application_kernel.feature new file mode 100644 index 0000000..fea4bc1 --- /dev/null +++ b/features/configuration/configuring_application_kernel.feature @@ -0,0 +1,59 @@ +Feature: Configuring application kernel + + Background: + Given a working Symfony application with SymfonyExtension configured + And a Behat configuration containing: + """ + default: + suites: + default: + contexts: + - App\Tests\SomeContext + """ + And a context file "tests/SomeContext.php" containing: + """ + kernel = $kernel; } + + /** @Then the application kernel should have environment :environment */ + public function kernelEnvironmentShouldBe(string $environment): void { assert($this->kernel->getEnvironment() === $environment); } + + /** @Then the application kernel should have debug :state*/ + public function kernelDebugShouldBe(string $state): void + { + $map = ['enabled' => true, 'disabled' => false]; + + if (!array_key_exists($state, $map)) { throw new \Exception('Invalid state passed!'); } + + assert($this->kernel->isDebug() === $map[$state]); + } + } + """ + And a YAML services file containing: + """ + services: + App\Tests\SomeContext: + public: true + arguments: + - "@kernel" + """ + + Scenario: Using test environment with debug enabled by default + Given a feature file containing: + """ + Feature: + Scenario: + Then the application kernel should have environment "test" + And the application kernel should have debug enabled + """ + When I run Behat + Then it should pass