File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
features/dependency_injection Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -131,3 +131,50 @@ Feature: Autowiring contexts
131131 """
132132 When I run Behat
133133 Then it should pass
134+
135+ Scenario : Autowiring a context with test client
136+ Given a working Symfony application with SymfonyExtension configured
137+ And an environment variable "APP_ENV" set to "test"
138+ And a feature file containing:
139+ """
140+ Feature:
141+ Scenario:
142+ Then the client should be passed
143+ """
144+ And a context file "tests/SomeContext.php" containing:
145+ """
146+ <?php
147+
148+ namespace App\Tests;
149+
150+ use Behat\Behat\Context\Context;
151+ use Symfony\Component\BrowserKit\AbstractBrowser;
152+
153+ final class SomeContext implements Context
154+ {
155+ private $client;
156+
157+ public function __construct(AbstractBrowser $client) { $this->client = $client; }
158+
159+ /** @Then the client should be passed */
160+ public function clientShouldBePassed(): void
161+ {
162+ assert(is_object($this->client));
163+ assert($this->client instanceof AbstractBrowser);
164+ }
165+ }
166+ """
167+ And a YAML services file containing:
168+ """
169+ services:
170+ _defaults:
171+ autowire: true
172+ autoconfigure: true
173+ bind:
174+ $client: '@test.client'
175+
176+ App\Tests\:
177+ resource: '../tests/*'
178+ """
179+ When I run Behat
180+ Then it should pass
You can’t perform that action at this time.
0 commit comments