Skip to content

Commit

Permalink
Merge branch 'symfony:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
JoppeDC authored Dec 7, 2024
2 parents 94b72ad + 8c86705 commit 7be9a40
Show file tree
Hide file tree
Showing 27 changed files with 146 additions and 203 deletions.
99 changes: 16 additions & 83 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,10 @@ jobs:
tools: phpstan,flex
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3
env:
SYMFONY_REQUIRE: 7.0.*
SYMFONY_REQUIRE: 7.0.*

- name: Install PHPUnit dependencies
run: vendor/bin/simple-phpunit --version
Expand All @@ -74,19 +63,8 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3

- name: Run tests
run: vendor/bin/simple-phpunit
Expand All @@ -108,22 +86,11 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Allow dev dependencies
run: composer config minimum-stability dev

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3

- name: Run tests
run: vendor/bin/simple-phpunit
Expand All @@ -141,19 +108,10 @@ jobs:
php-version: '8.3'
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer update --prefer-dist --prefer-lowest
uses: ramsey/composer-install@v3
with:
dependency-versions: "lowest"

- name: Run tests
env:
Expand All @@ -176,19 +134,8 @@ jobs:
php-version: '8.3'
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3

- name: Run tests
run: vendor/bin/simple-phpunit
Expand All @@ -206,19 +153,14 @@ jobs:
php-version: '8.3'
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Install Firefox
run: brew install --cask firefox

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Geckodriver
run: brew install geckodriver

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3

- name: Run tests
run: vendor/bin/simple-phpunit
Expand All @@ -240,19 +182,10 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist
uses: ramsey/composer-install@v3
with:
composer-options: "--prefer-dist"

- name: Remove phpunit-bridge dependency (not yet phpunit 10 compliant)
run: composer remove --dev symfony/phpunit-bridge
Expand Down
111 changes: 61 additions & 50 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
{
"name": "symfony/panther",
"type": "library",
"description": "A browser testing and web scraping library for PHP and Symfony.",
"keywords": ["scraping", "E2E", "testing", "webdriver", "selenium", "symfony"],
"homepage": "https://dunglas.fr",
"license": "MIT",
"authors": [
{
"name": "Kévin Dunglas",
"email": "[email protected]",
"homepage": "https://dunglas.fr"
"name": "symfony/panther",
"description": "A browser testing and web scraping library for PHP and Symfony.",
"license": "MIT",
"type": "library",
"keywords": [
"scraping",
"E2E",
"testing",
"webdriver",
"selenium",
"symfony"
],
"authors": [
{
"name": "Kévin Dunglas",
"email": "[email protected]",
"homepage": "https://dunglas.fr"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"homepage": "https://dunglas.fr",
"require": {
"php": ">=8.0",
"ext-dom": "*",
"ext-libxml": "*",
"php-webdriver/webdriver": "^1.8.2",
"symfony/browser-kit": "^5.3 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.3 || ^6.0 || ^7.0",
"symfony/deprecation-contracts": "^2.4 || ^3",
"symfony/dom-crawler": "^5.3 || ^6.0 || ^7.0",
"symfony/http-client": "^5.3 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.3 || ^6.0 || ^7.0",
"symfony/process": "^5.3 || ^6.0 || ^7.0"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"require": {
"php": ">=8.0",
"ext-dom": "*",
"ext-libxml": "*",
"php-webdriver/webdriver": "^1.8.2",
"symfony/browser-kit": "^5.3 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.3 || ^6.0 || ^7.0",
"symfony/deprecation-contracts": "^2.4 || ^3",
"symfony/dom-crawler": "^5.3 || ^6.0 || ^7.0",
"symfony/http-client": "^5.3 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.3 || ^6.0 || ^7.0",
"symfony/process": "^5.3 || ^6.0 || ^7.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Panther\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Symfony\\Component\\Panther\\Tests\\": "tests/" }
},
"extra": {
"branch-alias": {
"dev-main": "2.0.x-dev"
"require-dev": {
"symfony/css-selector": "^5.3 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.3 || ^6.0 || ^7.0",
"symfony/mime": "^5.3 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^5.3 || ^6.0 || ^7.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Symfony\\Component\\Panther\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Symfony\\Component\\Panther\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "2.0.x-dev"
}
}
},
"config": {
"sort-packages": true
},
"require-dev": {
"symfony/css-selector": "^5.3 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.3 || ^6.0 || ^7.0",
"symfony/mime": "^5.3 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^5.3 || ^6.0 || ^7.0"
},
"minimum-stability": "dev",
"prefer-stable": true
}
16 changes: 8 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ final class Client extends AbstractBrowser implements WebDriver, JavaScriptExecu
/**
* @param string[]|null $arguments
*/
public static function createChromeClient(string $chromeDriverBinary = null, array $arguments = null, array $options = [], string $baseUri = null): self
public static function createChromeClient(?string $chromeDriverBinary = null, ?array $arguments = null, array $options = [], ?string $baseUri = null): self
{
return new self(new ChromeManager($chromeDriverBinary, $arguments, $options), $baseUri);
}

/**
* @param string[]|null $arguments
*/
public static function createFirefoxClient(string $geckodriverBinary = null, array $arguments = null, array $options = [], string $baseUri = null): self
public static function createFirefoxClient(?string $geckodriverBinary = null, ?array $arguments = null, array $options = [], ?string $baseUri = null): self
{
return new self(new FirefoxManager($geckodriverBinary, $arguments, $options), $baseUri);
}

public static function createSeleniumClient(string $host = null, WebDriverCapabilities $capabilities = null, string $baseUri = null, array $options = []): self
public static function createSeleniumClient(?string $host = null, ?WebDriverCapabilities $capabilities = null, ?string $baseUri = null, array $options = []): self
{
return new self(new SeleniumManager($host, $capabilities, $options), $baseUri);
}

public function __construct(BrowserManagerInterface $browserManager, string $baseUri = null)
public function __construct(BrowserManagerInterface $browserManager, ?string $baseUri = null)
{
$this->browserManager = $browserManager;
$this->baseUri = $baseUri;
Expand Down Expand Up @@ -252,7 +252,7 @@ public function refreshCrawler(): PantherCrawler
return $this->crawler = $this->createCrawler();
}

public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true): PantherCrawler
public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], ?string $content = null, bool $changeHistory = true): PantherCrawler
{
if ('GET' !== $method) {
throw new \InvalidArgumentException('Only the GET method is supported when using WebDriver.');
Expand All @@ -266,7 +266,7 @@ public function request(string $method, string $uri, array $parameters = [], arr

foreach (['parameters', 'files', 'server'] as $arg) {
if ([] !== $$arg) {
throw new \InvalidArgumentException(sprintf('The parameter "$%s" is not supported when using WebDriver.', $arg));
throw new \InvalidArgumentException(\sprintf('The parameter "$%s" is not supported when using WebDriver.', $arg));
}
}

Expand Down Expand Up @@ -790,9 +790,9 @@ public function ping(int $timeout = 1000): bool
private function createException(string $implementableClass): \Exception
{
if (null === $this->webDriver) {
return new \LogicException(sprintf('WebDriver not started yet. Call method `start()` first before calling any `%s` method.', $implementableClass));
return new \LogicException(\sprintf('WebDriver not started yet. Call method `start()` first before calling any `%s` method.', $implementableClass));
}

return new \RuntimeException(sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), $implementableClass));
return new \RuntimeException(\sprintf('"%s" does not implement "%s".', \get_class($this->webDriver), $implementableClass));
}
}
2 changes: 1 addition & 1 deletion src/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function webDriverToSymfony(WebDriverCookie $cookie): Cookie
return new Cookie($cookie->getName(), $cookie->getValue(), $expiry, $cookie->getPath(), (string) $cookie->getDomain(), (bool) $cookie->isSecure(), (bool) $cookie->isHttpOnly());
}

private function getWebDriverCookie(string $name, string $path = '/', string $domain = null): ?WebDriverCookie
private function getWebDriverCookie(string $name, string $path = '/', ?string $domain = null): ?WebDriverCookie
{
try {
$cookie = $this->webDriver->manage()->getCookieNamed($name);
Expand Down
Loading

0 comments on commit 7be9a40

Please sign in to comment.