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