Skip to content

Commit 9df2ebb

Browse files
committed
Creating a failing test for FriendsOfBehat#88
1 parent 8d0cec7 commit 9df2ebb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

features/dependency_injection/autowiring_contexts.feature

+43
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,46 @@ 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 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

0 commit comments

Comments
 (0)