Skip to content

Commit

Permalink
Remove support for deprecated features (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas authored Feb 3, 2021
1 parent 1883612 commit a4d4227
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 204 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG
=========

1.0.0
-----

* Add type hints
* Remove the deprecated PHPUnit listener, use the PHPUnit extension instead
* Remove deprecated support for Goutte, use `HttpBrowser` instead
* Remove deprecated support for `PANTHER_CHROME_DRIVER_BINARY` and `PANTHER_GECKO_DRIVER_BINARY` environment variables, add the binaries in your `PATH` instead

0.9.0
-----

Expand Down
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,6 @@ Without the extension, the web server used by Panther to serve the application u
stopped when `tearDownAfterClass()` is called.
On the other hand, when the extension is registered, the web server will be stopped only after the very last test.

To use the Panther extension, PHPUnit 7.3+ is required. Nonetheless, a listener is provided for older versions:

```xml
<!-- phpunit.xml.dist -->
<listeners>
<listener class="Symfony\Component\Panther\ServerListener" />
</listeners>
```

This listener will start the web server on demand like previously, but it will stop it after each test suite.

### Basic Usage

```php
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
"sort-packages": true
},
"require-dev": {
"fabpot/goutte": "^3.2.3",
"guzzlehttp/guzzle": "^6.3",
"symfony/css-selector": "^4.4 || ^5.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/mime": "^4.4 || ^5.0",
Expand Down
40 changes: 0 additions & 40 deletions src/PantherTestCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

namespace Symfony\Component\Panther;

use Goutte\Client as GoutteClient;
use GuzzleHttp\Client as GuzzleClient;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\BrowserKit\HttpBrowser as HttpBrowserClient;
use Symfony\Component\HttpClient\HttpClient;
Expand Down Expand Up @@ -50,13 +48,6 @@ trait PantherTestCaseTrait
*/
protected static $baseUri;

/**
* @var GoutteClient|null
*
* @deprecated since Panther 0.7
*/
protected static $goutteClient;

/**
* @var HttpBrowserClient|null
*/
Expand Down Expand Up @@ -110,10 +101,6 @@ public static function stopWebServer(): void
self::$pantherClients = [];
}

if (null !== self::$goutteClient) {
self::$goutteClient = null;
}

if (null !== self::$httpBrowserClient) {
self::$httpBrowserClient = null;
}
Expand Down Expand Up @@ -207,33 +194,6 @@ protected static function createAdditionalPantherClient(): PantherClient
return self::$pantherClient;
}

/**
* @param array $options see {@see $defaultOptions}
*
* @deprecated since Panther 0.7, use createHttpBrowserClient instead
*/
protected static function createGoutteClient(array $options = [], array $kernelOptions = []): GoutteClient
{
if (!\class_exists(GoutteClient::class)) {
throw new \RuntimeException('Goutte is not installed. Run "composer req fabpot/goutte".');
}

self::startWebServer($options);
if (null === self::$goutteClient) {
$goutteClient = new GoutteClient();
$goutteClient->setClient(new GuzzleClient(['base_uri' => self::$baseUri]));

self::$goutteClient = $goutteClient;
}

if (\is_a(self::class, KernelTestCase::class, true)) {
static::bootKernel($kernelOptions); // @phpstan-ignore-line
}

// It's not possible to use assertions with Goutte yet, https://github.com/FriendsOfPHP/Goutte/pull/382 needed
return self::$goutteClient;
}

/**
* @param array $options see {@see $defaultOptions}
*/
Expand Down
6 changes: 0 additions & 6 deletions src/ProcessManager/ChromeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ public function quit(): void
*/
private function findChromeDriverBinary(): string
{
if ($binary = $_SERVER['PANTHER_CHROME_DRIVER_BINARY'] ?? null) {
@trigger_error('The "PANTHER_CHROME_DRIVER_BINARY" environment variable is deprecated since Panther 0.9, add ChromeDriver to your PATH instead.', \E_USER_DEPRECATED);

return $binary;
}

if ($binary = (new ExecutableFinder())->find('chromedriver', null, ['./drivers'])) {
return $binary;
}
Expand Down
6 changes: 0 additions & 6 deletions src/ProcessManager/FirefoxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ public function quit(): void
*/
private function findGeckodriverBinary(): string
{
if ($binary = $_SERVER['PANTHER_GECKO_DRIVER_BINARY'] ?? null) {
@trigger_error('The "PANTHER_GECKO_DRIVER_BINARY" environment variable is deprecated since Panther 0.9, add geckodriver to your PATH instead.', \E_USER_DEPRECATED);

return $binary;
}

if ($binary = (new ExecutableFinder())->find('geckodriver', null, ['./drivers'])) {
return $binary;
}
Expand Down
6 changes: 0 additions & 6 deletions src/ProcessManager/WebServerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ public function __construct(string $documentRoot, string $hostname, int $port, s
null
);
$this->process->disableOutput();

// Symfony Process 3.4 BC: In newer versions env variables always inherit,
// but in 4.4 inheritEnvironmentVariables is deprecated, but setOptions was removed
if (\is_callable([$this->process, 'inheritEnvironmentVariables']) && \is_callable([$this->process, 'setOptions'])) {
$this->process->inheritEnvironmentVariables(true);
}
}

public function start(): void
Expand Down
54 changes: 0 additions & 54 deletions src/ServerListener.php

This file was deleted.

77 changes: 0 additions & 77 deletions tests/ServerListenerTest.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Symfony\Component\Panther\Tests;

use Goutte\Client as GoutteClient;
use Symfony\Component\BrowserKit\HttpBrowser as HttpBrowserClient;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Panther\Client as PantherClient;
Expand All @@ -31,7 +30,6 @@ abstract class TestCase extends PantherTestCase
public function clientFactoryProvider(): iterable
{
// Tests must pass with both Panther and HttpBrowser
yield 'Goutte' => [[static::class, 'createGoutteClient'], GoutteClient::class];
yield 'HttpBrowser' => [[static::class, 'createHttpBrowserClient'], HttpBrowserClient::class];
yield 'Panther' => [[static::class, 'createPantherClient'], PantherClient::class];

Expand Down

0 comments on commit a4d4227

Please sign in to comment.