diff --git a/.travis.yml b/.travis.yml index b114031..015a227 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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: diff --git a/composer.json b/composer.json index bb70207..d4f1189 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/features/browserkit_integration/browserkit_integration.feature b/features/browserkit_integration/browserkit_integration.feature index 39a1077..2e0a040 100644 --- a/features/browserkit_integration/browserkit_integration.feature +++ b/features/browserkit_integration/browserkit_integration.feature @@ -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; } @@ -75,6 +77,9 @@ Feature: BrowserKit integration autowire: true autoconfigure: true + bind: + $client: "@test.client" + App\Tests\SomeContext: ~ """ When I run Behat diff --git a/phpstan.neon b/phpstan.neon index 64c7cba..b282061 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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/' diff --git a/src/Driver/SymfonyDriver.php b/src/Driver/SymfonyDriver.php index fa3ae08..da12586 100644 --- a/src/Driver/SymfonyDriver.php +++ b/src/Driver/SymfonyDriver.php @@ -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; @@ -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) )); }