diff --git a/.symfony.insight.yaml b/.symfony.insight.yaml deleted file mode 100644 index 02b90a6..0000000 --- a/.symfony.insight.yaml +++ /dev/null @@ -1 +0,0 @@ -php_version: 7.1 diff --git a/CHANGELOG-0.5.md b/CHANGELOG-0.5.md new file mode 100644 index 0000000..825c32f --- /dev/null +++ b/CHANGELOG-0.5.md @@ -0,0 +1 @@ +# Changelog diff --git a/Makefile b/Makefile index 2397c1a..6ac6dd0 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,14 @@ phpstan: ## Run PHPStan against a specific DIRECTORY (a specific LEVEL can be de phpstan: $(PHP) vendor/bin/phpstan analyse $(DIRECTORY) --level $(or $(LEVEL), 8) +rector-dry: ## Run Rector in --dry-run mode +rector-dry: + $(DOCKER) run -v $(PWD):/project rector/rector process /project --config /project/rector.yaml --dry-run + +rector: ## Run Rector +rector: + $(DOCKER) run -v $(PWD):/project rector/rector process /project --config /project/rector.yaml --dry-run + ## ## Tests ##--------------------------------------------------------------------------- diff --git a/README.md b/README.md index f6530a2..348d42e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ Panther Mink Extension ====================== +![PantherExtension CI](https://github.com/Guikingone/panther-extension/workflows/PantherExtension%20CI/badge.svg?branch=master) +![PantherExtension CI - Config](https://github.com/Guikingone/panther-extension/workflows/PantherExtension%20CI%20-%20Config/badge.svg?branch=master) + Mink extension for controlling `Chrome | Firefox | Selenium` thanks to [Symfony Panther](https://github.com/symfony/panther). ## Foreword: diff --git a/rector.yaml b/rector.yaml new file mode 100644 index 0000000..42f9a80 --- /dev/null +++ b/rector.yaml @@ -0,0 +1,16 @@ +parameters: + php_version_features: '7.1' + auto_import_names: true + autoload_paths: + - 'vendor/autoload.php' + paths: + - 'src' + - 'tests' + exclude_paths: + - 'vendor' + sets: + - 'Php71' + - 'DeadCode' + - 'Performance' + - 'Privatization' + - 'SOLID' diff --git a/src/Driver/PantherDriver.php b/src/Driver/PantherDriver.php index 0138610..7961f7c 100644 --- a/src/Driver/PantherDriver.php +++ b/src/Driver/PantherDriver.php @@ -146,6 +146,10 @@ public function stop() $this->client->quit(); self::stopWebServer(); $this->started = false; + $this->capabilitiesHelper = null; + $this->cookieHelper = null; + $this->optionsHelper = null; + $this->waitHelper = null; } catch (\LogicException $exception) { throw new DriverException( sprintf('The driver cannot be stopped, error message "%s"', $exception->getMessage()) @@ -181,6 +185,7 @@ public function reset() try { $this->additionalClients = []; $this->getWebDriver()->manage()->deleteAllCookies(); + $this->client->quit(); } catch (\LogicException $exception) { throw new DriverException( sprintf('The driver cannot reset the current session, error message "%s"', $exception->getMessage()) @@ -397,11 +402,7 @@ public function takeScreenshot(string $path): void { try { $this->client->takeScreenshot($path); - } catch (\InvalidArgumentException $exception) { - throw new DriverException( - sprintf('The %s:%s() method encounter an error. Error message: %s', self::class, __METHOD__, $exception->getMessage()) - ); - } catch (\LogicException $exception) { + } catch (\InvalidArgumentException|\LogicException $exception) { throw new DriverException( sprintf('The %s:%s() method encounter an error. Error message: %s', self::class, __METHOD__, $exception->getMessage()) ); diff --git a/src/Extension/PantherFactory.php b/src/Extension/PantherFactory.php index 9ccf406..26e9d14 100644 --- a/src/Extension/PantherFactory.php +++ b/src/Extension/PantherFactory.php @@ -50,6 +50,9 @@ public function configure(ArrayNodeDefinition $builder) ->scalarNode('screenshots_path') ->defaultValue('')->end() ->end() + ->scalarNode('ajax_tracking') + ->defaultValue(false) + ->end() ->end() ; } @@ -68,6 +71,7 @@ public function buildDriver(array $config) ['config' => [ 'selenium' => $config['selenium'], ]], + $config['ajax_tracking'], ]); } } diff --git a/tests/Driver/Helper/CookieHelperTest.php b/tests/Driver/Helper/CookieHelperTest.php index f0c8d7f..8e8ca67 100644 --- a/tests/Driver/Helper/CookieHelperTest.php +++ b/tests/Driver/Helper/CookieHelperTest.php @@ -47,6 +47,7 @@ public function testCookieCanBeAccessed(): void { $this->driver->start(); $this->driver->getClient()->getCookieJar()->clear(); + $this->driver->visit('/cookie.php'); $cookie = $this->driver->getSpecificCookie('barcelona', '/cookie.php', '127.0.0.1'); diff --git a/tests/Driver/Helper/OptionsHelperTest.php b/tests/Driver/Helper/OptionsHelperTest.php new file mode 100644 index 0000000..a915ca6 --- /dev/null +++ b/tests/Driver/Helper/OptionsHelperTest.php @@ -0,0 +1,46 @@ + + */ +final class OptionsHelperTest extends TestCase +{ + /** + * @var PantherDriver + */ + private $driver; + + /** + * {@inheritdoc} + */ + protected function setUp(): void + { + $this->driver = new PantherDriver('chrome', ['webServerDir' => __DIR__.'/../../fixtures']); + } + + /** + * {@inheritdoc} + */ + protected function tearDown(): void + { + $this->driver->stop(); + } + + public function testWindowCanBeResized(): void + { + $this->driver->start(); + $this->driver->resizeWindow(100, 100); + + $currentDimensions = $this->driver->getClient()->manage()->window()->getSize(); + + static::assertSame(100, $currentDimensions->getWidth()); + static::assertSame(100, $currentDimensions->getHeight()); + } +} diff --git a/tests/Driver/PantherDriverTest.php b/tests/Driver/PantherDriverTest.php index b14b53f..573ca4f 100644 --- a/tests/Driver/PantherDriverTest.php +++ b/tests/Driver/PantherDriverTest.php @@ -94,6 +94,19 @@ public function testDriverCanBeStopped(): void static::assertFalse($this->driver->isStarted()); } + public function testDriverCanRestartMultipleTimes(): void + { + $this->driver->start(); + $this->driver->visit('/basic.html'); + $this->driver->stop(); + static::assertFalse($this->driver->isStarted()); + + $this->driver->start(); + $this->driver->visit('/basic.html'); + $this->driver->stop(); + static::assertFalse($this->driver->isStarted()); + } + public function testDriverCanBeReset(): void { $this->driver->start();