From 8158cab0cef1ac322bfa873119d742de53a73bb9 Mon Sep 17 00:00:00 2001 From: robertfausk Date: Sun, 28 Apr 2019 13:52:36 +0200 Subject: [PATCH] Initial release :heart: --- .gitignore | 5 +- .travis.yml | 31 +++++++++ README.md | 21 +++++- composer.json | 39 +++++++++++ .../Driver/PantherFactory.php | 67 +++++++++++++++++++ .../ServiceContainer/PantherExtension.php | 61 +++++++++++++++++ 6 files changed, 219 insertions(+), 5 deletions(-) create mode 100644 .travis.yml create mode 100644 composer.json create mode 100644 src/Robertfausk/Behat/PantherExtension/ServiceContainer/Driver/PantherFactory.php create mode 100644 src/Robertfausk/Behat/PantherExtension/ServiceContainer/PantherExtension.php diff --git a/.gitignore b/.gitignore index a67d42b..fde868e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ composer.phar +composer.lock /vendor/ - -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3411523 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: php + +addons: + chrome: stable + +sudo: false + +php: [7.1, 7.2, 7.3] + +matrix: + allow_failures: + - env: DEPENDENCIES='dev' + - php: 7.3 + fast_finish: true + include: + # Test against dev versions of dependencies + - php: 7.3 + env: DEPENDENCIES='dev' +cache: + directories: + - $HOME/.composer/cache/files + +before_install: + - if [ "$DEPENDENCIES" = "dev" ]; then composer config minimum-stability dev; fi; + +install: + - composer install --no-progress + +script: + - vendor/bin/phpspec run -f pretty + - vendor/bin/behat -fprogress --strict diff --git a/README.md b/README.md index f841e96..b85a854 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ -# behat-panther-extension +# BehatPantherExtension + +[![Latest Stable Version](https://poser.pugx.org/robertfausk/behat-panther-extension/v/stable.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension) +[![Latest Unstable Version](https://poser.pugx.org/robertfausk/behat-panther-extension/v/unstable.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension) +[![Total Downloads](https://poser.pugx.org/robertfausk/behat-panther-extension/downloads.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension) +[![License](https://poser.pugx.org/robertfausk/behat-panther-extension/license.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension) + + Symfony Panther extension for Behat + +## Install + +```BASH +composer require --dev robertfausk/behat-panther-extension +``` + +## Credits + +Created by Robert Freigang [robertfausk](https://github.com/robertfausk). + +MinkPantherDriver is built on top of [Panther](https://github.com/symfony/panther) and for usage with [Behat and Mink](http://behat.org/en/latest/cookbooks/integrating_symfony2_with_behat.html#initialising-behat). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..24318cc --- /dev/null +++ b/composer.json @@ -0,0 +1,39 @@ +{ + "name": "robertfausk/behat-panther-extension", + "type": "behat-extension", + "description": "Symfony Panther extension for Behat", + "keywords": [ + "behat", + "symfony", + "panther", + "web", + "test", + "browser", + "gui" + ], + "license": "MIT", + "authors": [ + { + "name": "Robert Freigang", + "email": "robertfreigang@gmx.de" + } + ], + "require": { + "php": ">=7.1", + "behat/behat": "^3.0.5", + "behat/mink-extension": "^2.0", + "symfony/config": "^3.4|^4.0" + }, + "require-dev": { + }, + "autoload": { + "psr-0": { + "Robertfausk\\BehatPantherExtension": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/src/Robertfausk/Behat/PantherExtension/ServiceContainer/Driver/PantherFactory.php b/src/Robertfausk/Behat/PantherExtension/ServiceContainer/Driver/PantherFactory.php new file mode 100644 index 0000000..0ba981d --- /dev/null +++ b/src/Robertfausk/Behat/PantherExtension/ServiceContainer/Driver/PantherFactory.php @@ -0,0 +1,67 @@ + + */ +class PantherFactory implements DriverFactory +{ + /** + * {@inheritdoc} + */ + public function getDriverName() + { + return 'panther'; + } + + /** + * {@inheritdoc} + */ + public function supportsJavascript() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function configure(ArrayNodeDefinition $builder) + { + $builder + ->children() + ->arrayNode('options') + ->useAttributeAsKey('key') + ->prototype('variable')->end() + ->info( + "These are the options passed as first argument to PantherTestcaseTrait::createPantherClient client constructor." + ) + ->end() + ->end() + ; + } + + /** + * {@inheritdoc} + */ + public function buildDriver(array $config) + { + if (!class_exists('Behat\Mink\Driver\PantherDriver')) { + throw new \RuntimeException( + 'Install MinkPantherDriver in order to use panther driver.' + ); + } + + return new Definition( + 'Behat\Mink\Driver\PantherDriver', + array( + $config['options'] + ) + ); + } +} diff --git a/src/Robertfausk/Behat/PantherExtension/ServiceContainer/PantherExtension.php b/src/Robertfausk/Behat/PantherExtension/ServiceContainer/PantherExtension.php new file mode 100644 index 0000000..c7d49fa --- /dev/null +++ b/src/Robertfausk/Behat/PantherExtension/ServiceContainer/PantherExtension.php @@ -0,0 +1,61 @@ + + */ +final class PantherExtension implements ExtensionInterface +{ + /** + * @inheritdoc + */ + public function process(ContainerBuilder $container): void + { + } + + /** + * @inheritdoc + */ + public function getConfigKey(): string + { + return 'panther'; + } + + /** + * @inheritdoc + */ + public function initialize(ExtensionManager $extensionManager): void + { + /** @var MinkExtension|null $minkExtension */ + $minkExtension = $extensionManager->getExtension('mink'); + + if ($minkExtension === null) { + return; + } + + $minkExtension->registerDriverFactory(new PantherFactory()); + } + + /** + * @inheritdoc + */ + public function configure(ArrayNodeDefinition $builder): void + { + } + + /** + * @inheritdoc + */ + public function load(ContainerBuilder $container, array $config): void + { + } +}