Skip to content

Commit

Permalink
Creating a failing test for FriendsOfBehat#88
Browse files Browse the repository at this point in the history
  • Loading branch information
DonCallisto committed Jun 18, 2020
1 parent 8d0cec7 commit 58b9f67
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions features/dependency_injection/autowiring_contexts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,24 @@ Feature: Autowiring contexts
"""
When I run Behat
Then it should pass

Scenario: Autowiring a context with test client
Given a feature file containing:
"""
Feature:
Scenario:
Then the client should be passed
"""
And a YAML services file containing:
"""
services:
_defaults:
autowire: true
bind:
$client: '@test.client'
Tests\Behat\Context\:
resource: '../../../tests/Behat/Context/TestClientInjectionContext.php'
"""
When I run Behat
Then it should pass
25 changes: 25 additions & 0 deletions tests/Behat/Context/TestClientInjectionContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Tests\Behat\Context;

use Behat\Behat\Context\Context;
use Symfony\Component\BrowserKit\AbstractBrowser;

final class TestClientInjectionContext implements Context
{
private $client;

public function __construct(AbstractBrowser $client)
{
$this->client = $client;
}

/** @Then the client should be passed */
public function clientShouldBePassed(): void
{
assert(is_object($this->client));
assert($this->client instanceof AbstractBrowser);
}
}

0 comments on commit 58b9f67

Please sign in to comment.