File tree 1 file changed +45
-0
lines changed
features/dependency_injection
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -131,3 +131,48 @@ 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
+ {
153
+ private $client;
154
+
155
+ public function __construct(AbstractBrowser $client) { $this->client = $client; }
156
+
157
+ /** @Then the client should be passed */
158
+ public function clientShouldBePassed(): void
159
+ {
160
+ assert(is_object($this->client));
161
+ assert($this->client instanceof AbstractBrowser);
162
+ }
163
+ }
164
+ """
165
+ And a YAML services file containing:
166
+ """
167
+ services:
168
+ _defaults:
169
+ autowire: true
170
+ autoconfigure: true
171
+ bind:
172
+ $client: '@test.client'
173
+
174
+ App\Tests\:
175
+ resource: '../tests/*'
176
+ """
177
+ When I run Behat
178
+ Then it should pass
You can’t perform that action at this time.
0 commit comments