feature #108 Add compatibility with Symfony 5 (pamil)

This PR was merged into the 2.1-dev branch.

Discussion
----------

Fixes #103.

Commits
-------

019557e8e3 Try to run tests with Behat @ dev-master
This commit is contained in:
Kamil Kokot
2020-01-15 19:00:15 +01:00
committed by GitHub
5 changed files with 20 additions and 10 deletions

View File

@@ -15,10 +15,6 @@ jobs:
- -
php: '7.1' php: '7.1'
env: SYMFONY_VERSION=5.0.* env: SYMFONY_VERSION=5.0.*
allow_failures:
-
env: SYMFONY_VERSION=5.0.*
fast_finish: true
cache: cache:
directories: directories:
@@ -31,10 +27,14 @@ install:
- composer require symfony/dependency-injection:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist - 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/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 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/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/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/process:${SYMFONY_VERSION} --no-update --no-scripts --prefer-dist
- composer require --dev symfony/yaml:${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 - composer update --prefer-dist
script: script:

View File

@@ -18,9 +18,9 @@
"symfony/proxy-manager-bridge": "^3.4|^4.4|^5.0" "symfony/proxy-manager-bridge": "^3.4|^4.4|^5.0"
}, },
"require-dev": { "require-dev": {
"behat/mink": "^1.7", "friends-of-behat/mink": "^1.7",
"behat/mink-browserkit-driver": "^1.3", "friends-of-behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2", "friends-of-behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3", "behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/page-object-extension": "^0.3.1", "friends-of-behat/page-object-extension": "^0.3.1",
"friends-of-behat/service-container-extension": "^1.0", "friends-of-behat/service-container-extension": "^1.0",

View File

@@ -31,12 +31,14 @@ Feature: BrowserKit integration
use Behat\Behat\Context\Context; use Behat\Behat\Context\Context;
use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters; use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\Client;
final class SomeContext implements Context { final class SomeContext implements Context {
/** @var Client|AbstractBrowser */
private $client; private $client;
public function __construct(Client $client) public function __construct($client)
{ {
$this->client = $client; $this->client = $client;
} }
@@ -75,6 +77,9 @@ Feature: BrowserKit integration
autowire: true autowire: true
autoconfigure: true autoconfigure: true
bind:
$client: "@test.client"
App\Tests\SomeContext: ~ App\Tests\SomeContext: ~
""" """
When I run Behat When I run Behat

View File

@@ -7,3 +7,6 @@ parameters:
- '/Cannot call method [a-zA-Z0-9]+\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null\./' - '/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/' - '/Method FriendsOfBehat\\SymfonyExtension\\Context\\Environment\\InitializedSymfonyExtensionEnvironment::bindCallee\(\) should return callable/'
- '/Strict comparison using === between 0\|1 and 2 will always evaluate to false\./' - '/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/'

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace FriendsOfBehat\SymfonyExtension\Driver; namespace FriendsOfBehat\SymfonyExtension\Driver;
use Behat\Mink\Driver\BrowserKitDriver; use Behat\Mink\Driver\BrowserKitDriver;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Client; use Symfony\Component\BrowserKit\Client;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
@@ -25,10 +26,11 @@ final class SymfonyDriver extends BrowserKitDriver
/** @var object $testClient */ /** @var object $testClient */
$testClient = $kernel->getContainer()->get('test.client'); $testClient = $kernel->getContainer()->get('test.client');
if (!$testClient instanceof Client) { if (!$testClient instanceof Client && !$testClient instanceof AbstractBrowser) {
throw new \RuntimeException(sprintf( 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, Client::class,
AbstractBrowser::class,
get_class($testClient) get_class($testClient)
)); ));
} }