Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with Symfony 5 #108

Merged
merged 1 commit into from Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -15,10 +15,6 @@ jobs:
-
php: '7.1'
env: SYMFONY_VERSION=5.0.*
allow_failures:
-
env: SYMFONY_VERSION=5.0.*
fast_finish: true

cache:
directories:
Expand All @@ -31,10 +27,14 @@ install:
- composer require symfony/dependency-injection:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require symfony/http-kernel:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require symfony/proxy-manager-bridge:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist

- composer require --dev symfony/browser-kit:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require --dev symfony/framework-bundle:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require --dev symfony/process:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require --dev symfony/yaml:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist

- if [ "$SYMFONY_VERSION" = "5.0.*" ]; then composer require --dev behat/behat:dev-master --no-update --no-scripts --prefer-dist; fi

- composer update --prefer-dist

script:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -18,9 +18,9 @@
"symfony/proxy-manager-bridge": "^3.4|^4.4|^5.0"
},
"require-dev": {
"behat/mink": "^1.7",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"friends-of-behat/mink": "^1.7",
"friends-of-behat/mink-browserkit-driver": "^1.3",
"friends-of-behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/page-object-extension": "^0.3.1",
"friends-of-behat/service-container-extension": "^1.0",
Expand Down
Expand Up @@ -31,12 +31,14 @@ Feature: BrowserKit integration
use Behat\Behat\Context\Context;
use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters;
use Psr\Container\ContainerInterface;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Client;

final class SomeContext implements Context {
/** @var Client|AbstractBrowser */
private $client;

public function __construct(Client $client)
public function __construct($client)
{
$this->client = $client;
}
Expand Down Expand Up @@ -75,6 +77,9 @@ Feature: BrowserKit integration
autowire: true
autoconfigure: true

bind:
$client: "@test.client"

App\Tests\SomeContext: ~
"""
When I run Behat
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Expand Up @@ -7,3 +7,6 @@ parameters:
- '/Cannot call method [a-zA-Z0-9]+\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null\./'
- '/Method FriendsOfBehat\\SymfonyExtension\\Context\\Environment\\InitializedSymfonyExtensionEnvironment::bindCallee\(\) should return callable/'
- '/Strict comparison using === between 0\|1 and 2 will always evaluate to false\./'
- '/Class Symfony\\Component\\BrowserKit\\Client not found\./'
- '/Class Symfony\\Component\\BrowserKit\\AbstractBrowser not found\./'
- '/Parameter \#1 \$client of method Behat\\Mink\\Driver\\BrowserKitDriver::__construct\(\) expects/'
6 changes: 4 additions & 2 deletions src/Driver/SymfonyDriver.php
Expand Up @@ -5,6 +5,7 @@
namespace FriendsOfBehat\SymfonyExtension\Driver;

use Behat\Mink\Driver\BrowserKitDriver;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Client;
use Symfony\Component\HttpKernel\KernelInterface;

Expand All @@ -25,10 +26,11 @@ public function __construct(KernelInterface $kernel, ?string $baseUrl)
/** @var object $testClient */
$testClient = $kernel->getContainer()->get('test.client');

if (!$testClient instanceof Client) {
if (!$testClient instanceof Client && !$testClient instanceof AbstractBrowser) {
throw new \RuntimeException(sprintf(
'Service "test.client" should be an instance of "%s", "%s" given.',
'Service "test.client" should be an instance of "%s" or "%s", "%s" given.',
Client::class,
AbstractBrowser::class,
get_class($testClient)
));
}
Expand Down