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 driver factory and extension #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
"php": ">=7.4",
"ext-json": "*",
"behat/mink": "^1.11@dev",
"php-webdriver/webdriver": "^1.14"
"php-webdriver/webdriver": "^1.14",
"behat/mink-extension": "^2.3"
},
"require-dev": {
"mink/driver-testsuite": "dev-master",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.6.8",
"symfony/error-handler": "^5.4 || ^6.0",
"jetbrains/phpstorm-attributes": "^1.0"
"jetbrains/phpstorm-attributes": "^1.0",
"friends-of-behat/mink-extension": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down
36 changes: 36 additions & 0 deletions src/WebdriverClassicExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Mink\WebdriverClassDriver;

use Behat\MinkExtension\ServiceContainer\MinkExtension;
use Behat\Testwork\ServiceContainer\Extension;
use Behat\Testwork\ServiceContainer\ExtensionManager;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class WebdriverClassicExtension implements Extension
{
public function getConfigKey(): string

Check warning on line 13 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L13

Added line #L13 was not covered by tests
{
return 'webdriver-classic';

Check warning on line 15 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L15

Added line #L15 was not covered by tests
}

public function initialize(ExtensionManager $extensionManager): void

Check warning on line 18 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L18

Added line #L18 was not covered by tests
{
/** @var MinkExtension $extension */
$extension = $extensionManager->getExtension(MinkExtension::MINK_ID);
$extension->registerDriverFactory(new WebdriverClassicFactory());

Check warning on line 22 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L21-L22

Added lines #L21 - L22 were not covered by tests
}

public function process(ContainerBuilder $container): void

Check warning on line 25 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L25

Added line #L25 was not covered by tests
{
}

public function configure(ArrayNodeDefinition $builder): void

Check warning on line 29 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L29

Added line #L29 was not covered by tests
{
}

public function load(ContainerBuilder $container, array $config): void

Check warning on line 33 in src/WebdriverClassicExtension.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicExtension.php#L33

Added line #L33 was not covered by tests
{
}
}
23 changes: 23 additions & 0 deletions src/WebdriverClassicFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Mink\WebdriverClassDriver;

use Behat\MinkExtension\ServiceContainer\Driver\Selenium2Factory;
use Symfony\Component\DependencyInjection\Definition;

class WebdriverClassicFactory extends Selenium2Factory
{
public function getDriverName(): string

Check warning on line 10 in src/WebdriverClassicFactory.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicFactory.php#L10

Added line #L10 was not covered by tests
{
return 'webdriver-classic';

Check warning on line 12 in src/WebdriverClassicFactory.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicFactory.php#L12

Added line #L12 was not covered by tests
}

public function buildDriver(array $config): Definition

Check warning on line 15 in src/WebdriverClassicFactory.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicFactory.php#L15

Added line #L15 was not covered by tests
{
return new Definition(WebdriverClassicDriver::class, [
$config['browser'],
$config['capabilities'],
$config['wd_host'],
]);

Check warning on line 21 in src/WebdriverClassicFactory.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicFactory.php#L17-L21

Added lines #L17 - L21 were not covered by tests
}
}