diff --git a/features/autowiring_contexts.feature b/features/autowiring_contexts.feature new file mode 100644 index 0000000..bcc2418 --- /dev/null +++ b/features/autowiring_contexts.feature @@ -0,0 +1,91 @@ +Feature: Autowiring contexts + + Background: + Given a working Symfony application with SymfonyExtension configured + And a Behat configuration containing: + """ + default: + suites: + default: + contexts: + - App\Tests\SomeContext + """ + + Scenario: Autowiring a context with a service + Given a feature file containing: + """ + Feature: + Scenario: + Then the container should be passed + """ + And a context file "tests/SomeContext.php" containing: + """ + container = $container; } + + /** @Then the container should be passed */ + public function containerShouldBePassed(): void + { + assert(is_object($this->container)); + assert($this->container instanceof ContainerInterface); + } + } + """ + And a YAML services file containing: + """ + services: + _defaults: + autowire: true + + App\Tests\SomeContext: + public: true + """ + When I run Behat + Then it should pass + + Scenario: Autowiring a context with a binding + Given a feature file containing: + """ + Feature: + Scenario: + Then the passed argument should be "KrzysztofKrawczyk" + """ + And a context file "tests/SomeContext.php" containing: + """ + argument = $argument; } + + /** @Then the passed argument should be :expected */ + public function passedArgumentShouldBe(string $expected): void { assert($this->argument === $expected); } + } + """ + And a YAML services file containing: + """ + services: + _defaults: + autowire: true + bind: + $argument: KrzysztofKrawczyk + + App\Tests\SomeContext: + public: true + """ + When I run Behat + Then it should pass