Skip to content

Commit 58b9f67

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

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

features/dependency_injection/autowiring_contexts.feature

+21
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,24 @@ 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 YAML services file containing:
143+
"""
144+
services:
145+
_defaults:
146+
autowire: true
147+
bind:
148+
$client: '@test.client'
149+
150+
Tests\Behat\Context\:
151+
resource: '../../../tests/Behat/Context/TestClientInjectionContext.php'
152+
"""
153+
When I run Behat
154+
Then it should pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Behat\Context;
6+
7+
use Behat\Behat\Context\Context;
8+
use Symfony\Component\BrowserKit\AbstractBrowser;
9+
10+
final class TestClientInjectionContext implements Context
11+
{
12+
private $client;
13+
14+
public function __construct(AbstractBrowser $client)
15+
{
16+
$this->client = $client;
17+
}
18+
19+
/** @Then the client should be passed */
20+
public function clientShouldBePassed(): void
21+
{
22+
assert(is_object($this->client));
23+
assert($this->client instanceof AbstractBrowser);
24+
}
25+
}

0 commit comments

Comments
 (0)