Skip to content
Open
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
1 change: 0 additions & 1 deletion .symfony.insight.yaml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG-0.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
##---------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
16 changes: 16 additions & 0 deletions rector.yaml
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 6 additions & 5 deletions src/Driver/PantherDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
);
Expand Down
4 changes: 4 additions & 0 deletions src/Extension/PantherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function configure(ArrayNodeDefinition $builder)
->scalarNode('screenshots_path')
->defaultValue('')->end()
->end()
->scalarNode('ajax_tracking')
->defaultValue(false)
->end()
->end()
;
}
Expand All @@ -68,6 +71,7 @@ public function buildDriver(array $config)
['config' => [
'selenium' => $config['selenium'],
]],
$config['ajax_tracking'],
]);
}
}
1 change: 1 addition & 0 deletions tests/Driver/Helper/CookieHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
46 changes: 46 additions & 0 deletions tests/Driver/Helper/OptionsHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Tests\Driver\Helper;

use PantherExtension\Driver\PantherDriver;
use PHPUnit\Framework\TestCase;

/**
* @author Guillaume LOULIER <contact@guillaumeloulier.fr>
*/
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());
}
}
13 changes: 13 additions & 0 deletions tests/Driver/PantherDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down