diff --git a/.php_cs.dist b/.php_cs.dist index 22f9216c..df850c87 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,7 +1,7 @@ diff --git a/README.md b/README.md index bb089f9a..820e1c28 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,34 @@ -

Panthère

+

Panther

**A browser testing and web scraping library for [PHP](https://php.net) and [Symfony](https://symfony.com)** -[![Build Status](https://travis-ci.org/symfony/panthere.svg?branch=master)](https://travis-ci.org/symfony/panthere) -[![Build status](https://ci.appveyor.com/api/projects/status/bunoc4ufud4oie45?svg=true)](https://ci.appveyor.com/project/fabpot/panthere) +[![Build Status](https://travis-ci.org/symfony/panther.svg?branch=master)](https://travis-ci.org/symfony/panther) +[![Build status](https://ci.appveyor.com/api/projects/status/bunoc4ufud4oie45?svg=true)](https://ci.appveyor.com/project/fabpot/panther) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/9ea7e78c-998a-4489-9815-7449ce8291ef/mini.png)](https://insight.sensiolabs.com/projects/9ea7e78c-998a-4489-9815-7449ce8291ef) -*Panthère* is a convenient standalone library to scrape websites and to run end-to-end tests **using real browsers**. +*Panther* is a convenient standalone library to scrape websites and to run end-to-end tests **using real browsers**. -Panthère is super powerful, it leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox. +Panther is super powerful, it leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox. -Panthère is very easy to use, because it implements the popular Symfony's [BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and +Panther is very easy to use, because it implements the popular Symfony's [BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and [DomCrawler](https://symfony.com/doc/current/components/dom_crawler.html) APIs, and contains all features you need to test your apps. It will sound familiar if you have ever created [a functional test for a Symfony app](https://symfony.com/doc/current/testing.html#functional-tests): as the API is exactly the same! -Keep in mind that Panthère can be used in every PHP project, it's a standalone library. +Keep in mind that Panther can be used in every PHP project, it's a standalone library. -Panthère automatically finds your local installation of Chrome and launches it (thanks to [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)), +Panther automatically finds your local installation of Chrome and launches it (thanks to [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)), so you don't need to install anything on your computer, neither Selenium server nor obscure driver. -In test mode, Panthère automatically starts your application using [the PHP built-in web-server](http://php.net/manual/en/features.commandline.webserver.php). -You can just focus on writing your tests or web-scraping scenario, Panthère takes care of everything else. +In test mode, Panther automatically starts your application using [the PHP built-in web-server](http://php.net/manual/en/features.commandline.webserver.php). +You can just focus on writing your tests or web-scraping scenario, Panther takes care of everything else. ## Install -Use [Composer](https://getcomposer.org/) to install Panthère in your project. You may want to use the --dev flag if you want to use Panthere for testing only and not for web scraping: +Use [Composer](https://getcomposer.org/) to install Panther in your project. You may want to use the --dev flag if you want to use Panther for testing only and not for web scraping: - composer req symfony/panthere:dev-master + composer req symfony/panther:dev-master - composer req --dev symfony/panthere:dev-master + composer req --dev symfony/panther:dev-master ## Basic Usage @@ -37,7 +37,7 @@ Use [Composer](https://getcomposer.org/) to install Panthère in your project. Y require __DIR__.'/vendor/autoload.php'; // Composer's autoloader -$client = \Symfony\Component\Panthere\Client::createChromeClient(); +$client = \Symfony\Component\Panther\Client::createChromeClient(); $crawler = $client->request('GET', 'http://api-platform.com'); // Yes, this website is 100% in JavaScript $link = $crawler->selectLink('Support')->link(); @@ -52,20 +52,20 @@ $client->takeScreenshot('screen.png'); // Yeah, screenshot! ## Testing Usage -The `PanthereTestCase` class allows you to easily write E2E tests. It automatically starts your app using the built-in PHP -web server and let you crawl it using Panthère. +The `PantherTestCase` class allows you to easily write E2E tests. It automatically starts your app using the built-in PHP +web server and let you crawl it using Panther. It extends [PHPUnit](https://phpunit.de/)'s `TestCase` and provide all testing tools you're used to. ```php request('GET', '/mypage'); $this->assertContains('My Title', $crawler->filter('title')->text()); // You can use any PHPUnit assertion @@ -79,13 +79,13 @@ To run this test: ### A Polymorph Feline -If you are testing a Symfony application, `PanthereTestCase` automatically extends the `WebTestCase` class. It means +If you are testing a Symfony application, `PantherTestCase` automatically extends the `WebTestCase` class. It means you can easily create functional tests, which can directly execute the kernel of your application and access all your existing -services. Unlike the Panthère's client, the Symfony's testing client doesn't support JavaScript and screenshots capturing, but +services. Unlike the Panther's client, the Symfony's testing client doesn't support JavaScript and screenshots capturing, but it is super-fast! -Alternatively (and even for non-Symfony apps), Panthère can also leverage the [Goutte](https://github.com/FriendsOfPHP/Goutte) -web scraping library, which is an intermediate between the Symfony's and the Panthère's test clients. Goutte sends real HTTP +Alternatively (and even for non-Symfony apps), Panther can also leverage the [Goutte](https://github.com/FriendsOfPHP/Goutte) +web scraping library, which is an intermediate between the Symfony's and the Panther's test clients. Goutte sends real HTTP requests, it is fast and is able to browse any webpage, not only the ones of the application under test. But Goutte doesn't support JavaScript and other advanced features because it is entirely written in PHP. @@ -96,17 +96,17 @@ to authenticate to an external SSO server, do I want to access the kernel of the ```php request('GET', '...') @@ -120,7 +120,7 @@ class E2eTest extends PanthereTestCase ## Features -Unlike testing and web scraping libraries you're used to, Panthère: +Unlike testing and web scraping libraries you're used to, Panther: * executes the JavaScript code contained in webpages * supports everything that Chrome (or Firefox) implements @@ -132,7 +132,7 @@ Unlike testing and web scraping libraries you're used to, Panthère: ## Documentation -Since Panthère implements the API of popular, it already has an extensive documentation: +Since Panther implements the API of popular libraries, it already has an extensive documentation: * For the `Client` class, read [the BrowserKit's documentation](https://symfony.com/doc/current/components/browser_kit.html) * For the `Crawler` class, read [the DomCrawler's documentation](https://symfony.com/doc/current/components/dom_crawler.html) @@ -140,22 +140,22 @@ Since Panthère implements the API of popular, it already has an extensive docum ## Environment Variables -The following environment variables can be set to change some Panthère behaviors: +The following environment variables can be set to change some Panther behaviors: -* `PANTHERE_NO_HEADLESS`: to disable browsers's headless mode (will display the testing window, useful to debug) -* `PANTHERE_NO_SANDBOX`: to disable [Chrome's sandboxing](https://chromium.googlesource.com/chromium/src/+/b4730a0c2773d8f6728946013eb812c6d3975bec/docs/design/sandbox.md) (unsafe, but allows to use Panthère in containers) -* `PANTHERE_WEB_SERVER_DIR`: to change the project's document root (default to `public/`) -* `PANTHERE_CHROME_DRIVER_BINARY`: to use another `chromedriver` binary, instead of relying on the ones already provided by Panthère +* `PANTHER_NO_HEADLESS`: to disable browsers's headless mode (will display the testing window, useful to debug) +* `PANTHER_NO_SANDBOX`: to disable [Chrome's sandboxing](https://chromium.googlesource.com/chromium/src/+/b4730a0c2773d8f6728946013eb812c6d3975bec/docs/design/sandbox.md) (unsafe, but allows to use Panther in containers) +* `PANTHER_WEB_SERVER_DIR`: to change the project's document root (default to `public/`) +* `PANTHER_CHROME_DRIVER_BINARY`: to use another `chromedriver` binary, instead of relying on the ones already provided by Panther ## Docker Integration -Here is a minimal Docker image that can run Panthère: +Here is a minimal Docker image that can run Panther: ``` FROM php:latest RUN apt-get update && apt-get install -y zlib1g-dev chromium && docker-php-ext-install zip -ENV PANTHERE_NO_SANDBOX 1 +ENV PANTHER_NO_SANDBOX 1 ``` Build it with `docker build . -t myproject` @@ -163,8 +163,8 @@ Run it with `docker run -it -v "$PWD":/srv/myproject -w /srv/myproject myproject ## Travis CI Integration -Panthère will work out of the box with Travis if you add the Chrome addon. Here is a minimal `.travis.yml` file to run -Panthère tests: +Panther will work out of the box with Travis if you add the Chrome addon. Here is a minimal `.travis.yml` file to run +Panther tests: ```yaml language: php @@ -179,8 +179,8 @@ script: ``` ## AppVeyor Integration -Panthère will work out of the box with AppVeyor as long as Google Chrome is installed. Here is a minimal `appveyor.yml` -file to run Panthère tests: +Panther will work out of the box with AppVeyor as long as Google Chrome is installed. Here is a minimal `appveyor.yml` +file to run Panther tests: ```yaml build: false diff --git a/appveyor.yml b/appveyor.yml index 9d67c983..462d6b8a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ build: false platform: x86 -clone_folder: c:\projects\symfony\panthere +clone_folder: c:\projects\symfony\panther cache: - '%LOCALAPPDATA%\Composer\files' diff --git a/composer.json b/composer.json index b55e1017..8d038d34 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "symfony/panthere", + "name": "symfony/panther", "type": "library", "description": "A browser testing and web scrapping library for PHP and Symfony.", "keywords": ["scrapping", "E2E", "testing", "webdriver", "selenium", "symfony"], @@ -26,10 +26,10 @@ "symfony/browser-kit": "4.1.0" }, "autoload": { - "psr-4": { "Symfony\\Component\\Panthere\\": "src/" } + "psr-4": { "Symfony\\Component\\Panther\\": "src/" } }, "autoload-dev": { - "psr-4": { "Symfony\\Component\\Panthere\\Tests\\": "tests/" } + "psr-4": { "Symfony\\Component\\Panther\\Tests\\": "tests/" } }, "extra": { "branch-alias": { diff --git a/examples/basic.php b/examples/basic.php index 5afc56f5..d1b278f0 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -1,7 +1,7 @@ * @@ -13,7 +13,7 @@ require __DIR__.'/../vendor/autoload.php'; // Composer's autoloader -$client = \Symfony\Component\Panthere\Client::createChromeClient(); +$client = \Symfony\Component\Panther\Client::createChromeClient(); $crawler = $client->request('GET', 'http://api-platform.com'); // Yes, this website is 100% in JavaScript $link = $crawler->selectLink('Support')->link(); diff --git a/panther.png b/panther.png new file mode 100644 index 00000000..d50c4889 Binary files /dev/null and b/panther.png differ diff --git a/panthere.png b/panthere.png deleted file mode 100644 index 04423b67..00000000 Binary files a/panthere.png and /dev/null differ diff --git a/phpstan.neon b/phpstan.neon index 5a7fde1e..a891f10d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,4 +3,4 @@ parameters: # https://github.com/symfony/symfony/pull/27849 - '/Parameter #1 \$value of method Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField::select\(\) expects string, array given\./' # Require a redesign of the underlying Symfony components - - '#Panthere\\[a-zA-Z\\]+::__construct\(\) does not call parent constructor from Symfony\\Component\\(BrowserKit|DomCrawler)\\[a-zA-Z]+\.#' + - '#Panther\\[a-zA-Z\\]+::__construct\(\) does not call parent constructor from Symfony\\Component\\(BrowserKit|DomCrawler)\\[a-zA-Z]+\.#' diff --git a/src/Client.php b/src/Client.php index 2b33736a..e3fdacc1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere; +namespace Symfony\Component\Panther; use Facebook\WebDriver\WebDriver; use Facebook\WebDriver\WebDriverBy; @@ -22,13 +22,13 @@ use Symfony\Component\BrowserKit\Response; use Symfony\Component\DomCrawler\Form; use Symfony\Component\DomCrawler\Link; -use Symfony\Component\Panthere\Cookie\CookieJar; -use Symfony\Component\Panthere\DomCrawler\Crawler; -use Symfony\Component\Panthere\DomCrawler\Form as PanthereForm; -use Symfony\Component\Panthere\DomCrawler\Link as PanthereLink; -use Symfony\Component\Panthere\ProcessManager\BrowserManagerInterface; -use Symfony\Component\Panthere\ProcessManager\ChromeManager; -use Symfony\Component\Panthere\ProcessManager\SeleniumManager; +use Symfony\Component\Panther\Cookie\CookieJar; +use Symfony\Component\Panther\DomCrawler\Crawler; +use Symfony\Component\Panther\DomCrawler\Form as PantherForm; +use Symfony\Component\Panther\DomCrawler\Link as PantherLink; +use Symfony\Component\Panther\ProcessManager\BrowserManagerInterface; +use Symfony\Component\Panther\ProcessManager\ChromeManager; +use Symfony\Component\Panther\ProcessManager\SeleniumManager; /** * @author Kévin Dunglas @@ -123,7 +123,7 @@ public function getServerParameter($key, $default = '') public function click(Link $link) { - if ($link instanceof PanthereLink) { + if ($link instanceof PantherLink) { $link->getElement()->click(); return $this->crawler = $this->createCrawler(); @@ -134,7 +134,7 @@ public function click(Link $link) public function submit(Form $form, array $values = []) { - if ($form instanceof PanthereForm) { + if ($form instanceof PantherForm) { $button = $form->getButton(); null === $button ? $form->getElement()->submit() : $button->click(); diff --git a/src/Cookie/CookieJar.php b/src/Cookie/CookieJar.php index 2a1ce06d..d8da5d53 100644 --- a/src/Cookie/CookieJar.php +++ b/src/Cookie/CookieJar.php @@ -1,7 +1,7 @@ * @@ -11,14 +11,14 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Cookie; +namespace Symfony\Component\Panther\Cookie; use Facebook\WebDriver\Cookie as WebDriverCookie; use Facebook\WebDriver\WebDriver; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\CookieJar as BaseCookieJar; use Symfony\Component\BrowserKit\Response; -use Symfony\Component\Panthere\ExceptionThrower; +use Symfony\Component\Panther\ExceptionThrower; /** * @author Kévin Dunglas diff --git a/src/DomCrawler/Crawler.php b/src/DomCrawler/Crawler.php index 63a1355d..bd2a7db0 100644 --- a/src/DomCrawler/Crawler.php +++ b/src/DomCrawler/Crawler.php @@ -1,7 +1,7 @@ * @@ -11,14 +11,14 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler; +namespace Symfony\Component\Panther\DomCrawler; use Facebook\WebDriver\Exception\NoSuchElementException; use Facebook\WebDriver\WebDriver; use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\WebDriverElement; use Symfony\Component\DomCrawler\Crawler as BaseCrawler; -use Symfony\Component\Panthere\ExceptionThrower; +use Symfony\Component\Panther\ExceptionThrower; /** * @author Kévin Dunglas diff --git a/src/DomCrawler/Field/ChoiceFormField.php b/src/DomCrawler/Field/ChoiceFormField.php index 59d73305..2c8a9eec 100644 --- a/src/DomCrawler/Field/ChoiceFormField.php +++ b/src/DomCrawler/Field/ChoiceFormField.php @@ -1,7 +1,7 @@ * @@ -11,12 +11,12 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler\Field; +namespace Symfony\Component\Panther\DomCrawler\Field; use Facebook\WebDriver\WebDriverSelect; use Facebook\WebDriver\WebDriverSelectInterface; use Symfony\Component\DomCrawler\Field\ChoiceFormField as BaseChoiceFormField; -use Symfony\Component\Panthere\WebDriver\WebDriverCheckbox; +use Symfony\Component\Panther\WebDriver\WebDriverCheckbox; /** * @author Kévin Dunglas diff --git a/src/DomCrawler/Field/FormFieldTrait.php b/src/DomCrawler/Field/FormFieldTrait.php index 4eeae2aa..852e87f7 100644 --- a/src/DomCrawler/Field/FormFieldTrait.php +++ b/src/DomCrawler/Field/FormFieldTrait.php @@ -1,7 +1,7 @@ * @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler\Field; +namespace Symfony\Component\Panther\DomCrawler\Field; use Facebook\WebDriver\WebDriverElement; -use Symfony\Component\Panthere\ExceptionThrower; +use Symfony\Component\Panther\ExceptionThrower; /** * @internal diff --git a/src/DomCrawler/Field/InputFormField.php b/src/DomCrawler/Field/InputFormField.php index 01c348f4..a745ea8e 100644 --- a/src/DomCrawler/Field/InputFormField.php +++ b/src/DomCrawler/Field/InputFormField.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler\Field; +namespace Symfony\Component\Panther\DomCrawler\Field; use Symfony\Component\DomCrawler\Field\InputFormField as BaseInputFormField; diff --git a/src/DomCrawler/Field/TextareaFormField.php b/src/DomCrawler/Field/TextareaFormField.php index 85462287..7d812756 100644 --- a/src/DomCrawler/Field/TextareaFormField.php +++ b/src/DomCrawler/Field/TextareaFormField.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler\Field; +namespace Symfony\Component\Panther\DomCrawler\Field; use Symfony\Component\DomCrawler\Field\TextareaFormField as BaseTextareaFormField; diff --git a/src/DomCrawler/Form.php b/src/DomCrawler/Form.php index 7dbfb323..0b6cf932 100644 --- a/src/DomCrawler/Form.php +++ b/src/DomCrawler/Form.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler; +namespace Symfony\Component\Panther\DomCrawler; use Facebook\WebDriver\Exception\NoSuchElementException; use Facebook\WebDriver\Support\XPathEscaper; @@ -22,11 +22,11 @@ use Facebook\WebDriver\WebDriverSelectInterface; use Symfony\Component\DomCrawler\Field\FormField; use Symfony\Component\DomCrawler\Form as BaseForm; -use Symfony\Component\Panthere\DomCrawler\Field\ChoiceFormField; -use Symfony\Component\Panthere\DomCrawler\Field\InputFormField; -use Symfony\Component\Panthere\DomCrawler\Field\TextareaFormField; -use Symfony\Component\Panthere\ExceptionThrower; -use Symfony\Component\Panthere\WebDriver\WebDriverCheckbox; +use Symfony\Component\Panther\DomCrawler\Field\ChoiceFormField; +use Symfony\Component\Panther\DomCrawler\Field\InputFormField; +use Symfony\Component\Panther\DomCrawler\Field\TextareaFormField; +use Symfony\Component\Panther\ExceptionThrower; +use Symfony\Component\Panther\WebDriver\WebDriverCheckbox; /** * @author Kévin Dunglas diff --git a/src/DomCrawler/Image.php b/src/DomCrawler/Image.php index a3472785..b1f51fca 100644 --- a/src/DomCrawler/Image.php +++ b/src/DomCrawler/Image.php @@ -1,7 +1,7 @@ * @@ -11,11 +11,11 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler; +namespace Symfony\Component\Panther\DomCrawler; use Facebook\WebDriver\WebDriverElement; use Symfony\Component\DomCrawler\Image as BaseImage; -use Symfony\Component\Panthere\ExceptionThrower; +use Symfony\Component\Panther\ExceptionThrower; /** * @author Kévin Dunglas diff --git a/src/DomCrawler/Link.php b/src/DomCrawler/Link.php index cbbbdcca..8111ce13 100644 --- a/src/DomCrawler/Link.php +++ b/src/DomCrawler/Link.php @@ -1,7 +1,7 @@ * @@ -11,11 +11,11 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\DomCrawler; +namespace Symfony\Component\Panther\DomCrawler; use Facebook\WebDriver\WebDriverElement; use Symfony\Component\DomCrawler\Link as BaseLink; -use Symfony\Component\Panthere\ExceptionThrower; +use Symfony\Component\Panther\ExceptionThrower; /** * @author Kévin Dunglas diff --git a/src/ExceptionThrower.php b/src/ExceptionThrower.php index 9d521361..b024fde7 100644 --- a/src/ExceptionThrower.php +++ b/src/ExceptionThrower.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere; +namespace Symfony\Component\Panther; /** * @internal diff --git a/src/PanthereTestCase.php b/src/PantherTestCase.php similarity index 58% rename from src/PanthereTestCase.php rename to src/PantherTestCase.php index 88ee10f6..acb4cf4b 100644 --- a/src/PanthereTestCase.php +++ b/src/PantherTestCase.php @@ -1,7 +1,7 @@ * @@ -11,19 +11,19 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere; +namespace Symfony\Component\Panther; use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; if (\class_exists(WebTestCase::class)) { - abstract class PanthereTestCase extends WebTestCase + abstract class PantherTestCase extends WebTestCase { - use PanthereTestCaseTrait; + use PantherTestCaseTrait; } } else { - abstract class PanthereTestCase extends TestCase + abstract class PantherTestCase extends TestCase { - use PanthereTestCaseTrait; + use PantherTestCaseTrait; } } diff --git a/src/PanthereTestCaseTrait.php b/src/PantherTestCaseTrait.php similarity index 72% rename from src/PanthereTestCaseTrait.php rename to src/PantherTestCaseTrait.php index cb6d5ed5..7ea19143 100644 --- a/src/PanthereTestCaseTrait.php +++ b/src/PantherTestCaseTrait.php @@ -1,7 +1,7 @@ * @@ -11,12 +11,12 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere; +namespace Symfony\Component\Panther; use Goutte\Client as GoutteClient; use GuzzleHttp\Client as GuzzleClient; -use Symfony\Component\Panthere\Client as PanthereClient; -use Symfony\Component\Panthere\ProcessManager\WebServerManager; +use Symfony\Component\Panther\Client as PantherClient; +use Symfony\Component\Panther\ProcessManager\WebServerManager; /** * Eases conditional class definition. @@ -25,7 +25,7 @@ * * @author Kévin Dunglas */ -trait PanthereTestCaseTrait +trait PantherTestCaseTrait { /** * @var string|null @@ -48,9 +48,9 @@ trait PanthereTestCaseTrait protected static $goutteClient; /** - * @var PanthereClient|null + * @var PantherClient|null */ - protected static $panthereClient; + protected static $pantherClient; public static function tearDownAfterClass() { @@ -59,9 +59,9 @@ public static function tearDownAfterClass() self::$webServerManager = null; } - if (null !== self::$panthereClient) { - self::$panthereClient->quit(); - self::$panthereClient = null; + if (null !== self::$pantherClient) { + self::$pantherClient->quit(); + self::$pantherClient = null; } if (null !== self::$goutteClient) { @@ -78,8 +78,8 @@ protected static function startWebServer(?string $webServerDir = null, string $h } if (null === $webServerDir) { - // Try the local $webServerDir property, or the PANTHERE_WEB_SERVER_DIR env var or default to the Flex directory structure - $webServerDir = static::$webServerDir ?? $_SERVER['PANTHERE_WEB_SERVER_DIR'] ?? __DIR__.'/../../../../public'; + // Try the local $webServerDir property, or the PANTHER_WEB_SERVER_DIR env var or default to the Flex directory structure + $webServerDir = static::$webServerDir ?? $_SERVER['PANTHER_WEB_SERVER_DIR'] ?? __DIR__.'/../../../../public'; } self::$webServerManager = new WebServerManager($webServerDir, $hostname, $port); @@ -88,14 +88,14 @@ protected static function startWebServer(?string $webServerDir = null, string $h self::$baseUri = "http://$hostname:$port"; } - protected static function createPanthereClient(string $hostname = '127.0.0.1', int $port = 9000): PanthereClient + protected static function createPantherClient(string $hostname = '127.0.0.1', int $port = 9000): PantherClient { self::startWebServer(null, $hostname, $port); - if (null === self::$panthereClient) { - self::$panthereClient = Client::createChromeClient(null, null, [], self::$baseUri); + if (null === self::$pantherClient) { + self::$pantherClient = Client::createChromeClient(null, null, [], self::$baseUri); } - return self::$panthereClient; + return self::$pantherClient; } protected static function createGoutteClient(): GoutteClient diff --git a/src/ProcessManager/BrowserManagerInterface.php b/src/ProcessManager/BrowserManagerInterface.php index 18f0c2d6..a490e2e1 100644 --- a/src/ProcessManager/BrowserManagerInterface.php +++ b/src/ProcessManager/BrowserManagerInterface.php @@ -1,7 +1,7 @@ * @@ -19,7 +19,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Panthere\ProcessManager; +namespace Symfony\Component\Panther\ProcessManager; use Facebook\WebDriver\WebDriver; diff --git a/src/ProcessManager/ChromeManager.php b/src/ProcessManager/ChromeManager.php index 15a614d9..f9f093e5 100644 --- a/src/ProcessManager/ChromeManager.php +++ b/src/ProcessManager/ChromeManager.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\ProcessManager; +namespace Symfony\Component\Panther\ProcessManager; use Facebook\WebDriver\Chrome\ChromeOptions; use Facebook\WebDriver\Remote\DesiredCapabilities; @@ -66,17 +66,15 @@ public function quit(): void private function findChromeDriverBinary(): string { - if ($binary = $_SERVER['PANTHERE_CHROME_DRIVER_BINARY'] ?? null) { + if ($binary = $_SERVER['PANTHER_CHROME_DRIVER_BINARY'] ?? null) { return $binary; } switch (PHP_OS_FAMILY) { case 'Windows': return __DIR__.'/../../chromedriver-bin/chromedriver.exe'; - break; case 'Darwin': return __DIR__.'/../../chromedriver-bin/chromedriver_mac64'; - break; default: return __DIR__.'/../../chromedriver-bin/chromedriver_linux64'; } @@ -84,11 +82,11 @@ private function findChromeDriverBinary(): string private function getDefaultArguments(): array { - // Enable the headless mode unless PANTHERE_NO_HEADLESS is defined - $args = ($_SERVER['PANTHERE_NO_HEADLESS'] ?? false) ? [] : ['--headless', 'window-size=1200,1100', '--disable-gpu']; + // Enable the headless mode unless PANTHER_NO_HEADLESS is defined + $args = ($_SERVER['PANTHER_NO_HEADLESS'] ?? false) ? [] : ['--headless', 'window-size=1200,1100', '--disable-gpu']; - // Disable Chrome's sandbox if PANTHERE_NO_SANDBOX is defined or if running in Travis - if ($_SERVER['PANTHERE_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false) { + // Disable Chrome's sandbox if PANTHER_NO_SANDBOX is defined or if running in Travis + if ($_SERVER['PANTHER_NO_SANDBOX'] ?? $_SERVER['HAS_JOSH_K_SEAL_OF_APPROVAL'] ?? false) { // Running in Travis, disabling the sandbox mode $args[] = '--no-sandbox'; } diff --git a/src/ProcessManager/SeleniumManager.php b/src/ProcessManager/SeleniumManager.php index d2899247..86231c65 100644 --- a/src/ProcessManager/SeleniumManager.php +++ b/src/ProcessManager/SeleniumManager.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\ProcessManager; +namespace Symfony\Component\Panther\ProcessManager; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; diff --git a/src/ProcessManager/WebServerManager.php b/src/ProcessManager/WebServerManager.php index fb161b35..86909709 100644 --- a/src/ProcessManager/WebServerManager.php +++ b/src/ProcessManager/WebServerManager.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\ProcessManager; +namespace Symfony\Component\Panther\ProcessManager; use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; diff --git a/src/ProcessManager/WebServerReadinessProbeTrait.php b/src/ProcessManager/WebServerReadinessProbeTrait.php index 344f00a2..abd542f0 100644 --- a/src/ProcessManager/WebServerReadinessProbeTrait.php +++ b/src/ProcessManager/WebServerReadinessProbeTrait.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\ProcessManager; +namespace Symfony\Component\Panther\ProcessManager; use Symfony\Component\Process\Process; diff --git a/src/WebDriver/WebDriverCheckbox.php b/src/WebDriver/WebDriverCheckbox.php index 42487c12..29622bd5 100644 --- a/src/WebDriver/WebDriverCheckbox.php +++ b/src/WebDriver/WebDriverCheckbox.php @@ -1,7 +1,7 @@ * @@ -11,7 +11,7 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\WebDriver; +namespace Symfony\Component\Panther\WebDriver; use Facebook\WebDriver\Exception\NoSuchElementException; use Facebook\WebDriver\Exception\UnexpectedTagNameException; diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 388bf1b3..2737e99f 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -1,7 +1,7 @@ * @@ -11,16 +11,16 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests; +namespace Symfony\Component\Panther\Tests; use Facebook\WebDriver\WebDriver; use Symfony\Component\BrowserKit\Client as BrowserKitClient; use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\CookieJar as BrowserKitCookieJar; use Symfony\Component\DomCrawler\Crawler as DomCrawlerCrawler; -use Symfony\Component\Panthere\Client; -use Symfony\Component\Panthere\Cookie\CookieJar; -use Symfony\Component\Panthere\DomCrawler\Crawler; +use Symfony\Component\Panther\Client; +use Symfony\Component\Panther\Cookie\CookieJar; +use Symfony\Component\Panther\DomCrawler\Crawler; /** * @author Kévin Dunglas @@ -29,7 +29,7 @@ class ClientTest extends TestCase { public function testCreateClient() { - $client = self::createPanthereClient(); + $client = self::createPantherClient(); $this->assertInstanceOf(BrowserKitClient::class, $client); $this->assertInstanceOf(WebDriver::class, $client); } diff --git a/tests/DomCrawler/CrawlerTest.php b/tests/DomCrawler/CrawlerTest.php index 3c997d75..6672d0b6 100644 --- a/tests/DomCrawler/CrawlerTest.php +++ b/tests/DomCrawler/CrawlerTest.php @@ -1,7 +1,7 @@ * @@ -11,14 +11,14 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\DomCrawler; +namespace Symfony\Component\Panther\Tests\DomCrawler; use Facebook\WebDriver\WebDriverElement; use Symfony\Component\DomCrawler\Crawler; -use Symfony\Component\Panthere\Client; -use Symfony\Component\Panthere\DomCrawler\Image; -use Symfony\Component\Panthere\DomCrawler\Link; -use Symfony\Component\Panthere\Tests\TestCase; +use Symfony\Component\Panther\Client; +use Symfony\Component\Panther\DomCrawler\Image; +use Symfony\Component\Panther\DomCrawler\Link; +use Symfony\Component\Panther\Tests\TestCase; /** * @author Kévin Dunglas @@ -27,7 +27,7 @@ class CrawlerTest extends TestCase { public function testCreateCrawler(): void { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/basic.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/basic.html'); $this->assertInstanceOf(Crawler::class, $crawler); $this->assertInstanceOf(WebDriverElement::class, $crawler); } diff --git a/tests/DomCrawler/FormTest.php b/tests/DomCrawler/FormTest.php index 3a96198d..cd602a47 100644 --- a/tests/DomCrawler/FormTest.php +++ b/tests/DomCrawler/FormTest.php @@ -1,7 +1,7 @@ * @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\DomCrawler; +namespace Symfony\Component\Panther\Tests\DomCrawler; use Symfony\Component\DomCrawler\Field\ChoiceFormField; -use Symfony\Component\Panthere\Tests\TestCase; +use Symfony\Component\Panther\Tests\TestCase; /** * @author Kévin Dunglas diff --git a/tests/ProcessManager/ChromeManagerTest.php b/tests/ProcessManager/ChromeManagerTest.php index 677458b0..7cf0d6bf 100644 --- a/tests/ProcessManager/ChromeManagerTest.php +++ b/tests/ProcessManager/ChromeManagerTest.php @@ -1,7 +1,7 @@ * @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\ProcessManager; +namespace Symfony\Component\Panther\Tests\ProcessManager; use PHPUnit\Framework\TestCase; -use Symfony\Component\Panthere\ProcessManager\ChromeManager; +use Symfony\Component\Panther\ProcessManager\ChromeManager; /** * @author Kévin Dunglas diff --git a/tests/ProcessManager/SeleniumManagerTest.php b/tests/ProcessManager/SeleniumManagerTest.php index 7f4fc086..6233924c 100644 --- a/tests/ProcessManager/SeleniumManagerTest.php +++ b/tests/ProcessManager/SeleniumManagerTest.php @@ -1,7 +1,7 @@ * @@ -11,12 +11,12 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\ProcessManager; +namespace Symfony\Component\Panther\Tests\ProcessManager; use Facebook\WebDriver\Chrome\ChromeOptions; use PHPUnit\Framework\TestCase; -use Symfony\Component\Panthere\ProcessManager\ChromeManager; -use Symfony\Component\Panthere\ProcessManager\SeleniumManager; +use Symfony\Component\Panther\ProcessManager\ChromeManager; +use Symfony\Component\Panther\ProcessManager\SeleniumManager; /** * @author Dmitry Kuzmin diff --git a/tests/ProcessManager/WebServerManagerTest.php b/tests/ProcessManager/WebServerManagerTest.php index a543d1d3..8dd10f42 100644 --- a/tests/ProcessManager/WebServerManagerTest.php +++ b/tests/ProcessManager/WebServerManagerTest.php @@ -1,7 +1,7 @@ * @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\ProcessManager; +namespace Symfony\Component\Panther\Tests\ProcessManager; use PHPUnit\Framework\TestCase; -use Symfony\Component\Panthere\ProcessManager\WebServerManager; +use Symfony\Component\Panther\ProcessManager\WebServerManager; /** * @author Kévin Dunglas diff --git a/tests/TestCase.php b/tests/TestCase.php index 9c4b87cb..348a270a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,7 +1,7 @@ * @@ -11,26 +11,26 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests; +namespace Symfony\Component\Panther\Tests; use Goutte\Client as GoutteClient; use Symfony\Component\DomCrawler\Crawler; -use Symfony\Component\Panthere\Client as PanthereClient; -use Symfony\Component\Panthere\PanthereTestCase; +use Symfony\Component\Panther\Client as PantherClient; +use Symfony\Component\Panther\PantherTestCase; /** * @author Kévin Dunglas */ -abstract class TestCase extends PanthereTestCase +abstract class TestCase extends PantherTestCase { protected static $webServerDir = __DIR__.'/fixtures'; public function clientFactoryProvider(): array { - // Tests must pass with both Panthere and Goutte + // Tests must pass with both Panther and Goutte return [ [[static::class, 'createGoutteClient'], GoutteClient::class], - [[static::class, 'createPanthereClient'], PanthereClient::class], + [[static::class, 'createPantherClient'], PantherClient::class], ]; } diff --git a/tests/WebDriver/WebDriverCheckBoxTest.php b/tests/WebDriver/WebDriverCheckBoxTest.php index 3e9962b8..5a8b2a84 100644 --- a/tests/WebDriver/WebDriverCheckBoxTest.php +++ b/tests/WebDriver/WebDriverCheckBoxTest.php @@ -1,7 +1,7 @@ * @@ -11,10 +11,10 @@ declare(strict_types=1); -namespace Symfony\Component\Panthere\Tests\WebDriver; +namespace Symfony\Component\Panther\Tests\WebDriver; -use Symfony\Component\Panthere\Tests\TestCase; -use Symfony\Component\Panthere\WebDriver\WebDriverCheckbox; +use Symfony\Component\Panther\Tests\TestCase; +use Symfony\Component\Panther\WebDriver\WebDriverCheckbox; /** * @author Kévin Dunglas @@ -23,7 +23,7 @@ class WebDriverCheckBoxTest extends TestCase { public function testWebDriverCheckboxIsMultiple() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $checkboxElement = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($checkboxElement); @@ -39,7 +39,7 @@ public function testWebDriverCheckboxIsMultiple() */ public function testWebDriverCheckboxGetOptions(string $type, array $options) { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath("//input[@type='$type']")->getElement(0); $c = new WebDriverCheckbox($element); @@ -61,7 +61,7 @@ public function getOptionsDataProvider() public function testWebDriverCheckboxGetFirstSelectedOption() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $checkboxElement = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($checkboxElement); @@ -79,7 +79,7 @@ public function testWebDriverCheckboxGetFirstSelectedOption() */ public function testWebDriverCheckboxSelectByValue(string $type, array $selectedOptions) { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath("//input[@type='$type']")->getElement(0); $c = new WebDriverCheckbox($element); @@ -107,7 +107,7 @@ public function selectByValueDataProvider() */ public function testWebDriverCheckboxSelectByValueInvalid() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -119,7 +119,7 @@ public function testWebDriverCheckboxSelectByValueInvalid() */ public function testWebDriverCheckboxSelectByIndex(string $type, array $selectedOptions) { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath("//input[@type='$type']")->getElement(0); $c = new WebDriverCheckbox($element); @@ -147,7 +147,7 @@ public function selectByIndexDataProvider() */ public function testWebDriverCheckboxSelectByIndexInvalid() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -159,7 +159,7 @@ public function testWebDriverCheckboxSelectByIndexInvalid() */ public function testWebDriverCheckboxSelectByVisibleText(string $type, string $text, string $value) { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath("//input[@type='$type']")->getElement(0); $c = new WebDriverCheckbox($element); @@ -182,7 +182,7 @@ public function selectByVisibleTextDataProvider() */ public function testWebDriverCheckboxSelectByVisiblePartialText(string $type, string $text, string $value) { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath("//input[@type='$type']")->getElement(0); $c = new WebDriverCheckbox($element); @@ -202,7 +202,7 @@ public function selectByVisiblePartialTextDataProvider() public function testWebDriverCheckboxDeselectAll() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -214,7 +214,7 @@ public function testWebDriverCheckboxDeselectAll() public function testWebDriverCheckboxDeselectByIndex() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -226,7 +226,7 @@ public function testWebDriverCheckboxDeselectByIndex() public function testWebDriverCheckboxDeselectByValue() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -238,7 +238,7 @@ public function testWebDriverCheckboxDeselectByValue() public function testWebDriverCheckboxDeselectByVisibleText() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -250,7 +250,7 @@ public function testWebDriverCheckboxDeselectByVisibleText() public function testWebDriverCheckboxDeselectByVisiblePartialText() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="checkbox"]')->getElement(0); $c = new WebDriverCheckbox($element); @@ -265,7 +265,7 @@ public function testWebDriverCheckboxDeselectByVisiblePartialText() */ public function testWebDriverCheckboxDeselectAllRadio() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="radio"]')->getElement(0); $c = new WebDriverCheckbox($element); $c->deselectAll(); @@ -276,7 +276,7 @@ public function testWebDriverCheckboxDeselectAllRadio() */ public function testWebDriverCheckboxDeselectByIndexRadio() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="radio"]')->getElement(0); $c = new WebDriverCheckbox($element); $c->deselectByIndex(0); @@ -287,7 +287,7 @@ public function testWebDriverCheckboxDeselectByIndexRadio() */ public function testWebDriverCheckboxDeselectByValueRadio() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="radio"]')->getElement(0); $c = new WebDriverCheckbox($element); $c->deselectByValue('val'); @@ -298,7 +298,7 @@ public function testWebDriverCheckboxDeselectByValueRadio() */ public function testWebDriverCheckboxDeselectByVisibleTextRadio() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="radio"]')->getElement(0); $c = new WebDriverCheckbox($element); $c->deselectByVisibleText('AB'); @@ -309,7 +309,7 @@ public function testWebDriverCheckboxDeselectByVisibleTextRadio() */ public function testWebDriverCheckboxDeselectByVisiblePartialTextRadio() { - $crawler = self::createPanthereClient()->request('GET', self::$baseUri.'/form.html'); + $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); $element = $crawler->filterXPath('//input[@type="radio"]')->getElement(0); $c = new WebDriverCheckbox($element); $c->deselectByVisiblePartialText('AB');