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
37 changes: 35 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ jobs:

- name: Install dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: highest
env:
SYMFONY_REQUIRE: ^7
SYMFONY_REQUIRE: ^8

- name: Install PHPUnit dependencies
run: vendor/bin/simple-phpunit --version
run: SYMFONY_PHPUNIT_VERSION=11.5 vendor/bin/simple-phpunit --version

- name: PHPStan
run: phpstan analyse --no-progress
Expand Down Expand Up @@ -195,3 +197,34 @@ jobs:

- name: Run tests
run: vendor/bin/phpunit --configuration phpunit.xml.dist.10

phpunit-11:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4', '8.5']
fail-fast: false
name: PHP ${{ matrix.php-versions }} (PHPUnit 11) Test on ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: zip

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

- name: Remove phpunit-bridge dependency (not yet PHPUnit 11+ compliant)
run: composer remove --dev symfony/phpunit-bridge

- name: Install latest PHPUnit 11
run: composer require --dev --prefer-dist 'phpunit/phpunit:11.5.*'

- name: Run tests
run: vendor/bin/phpunit --configuration phpunit.xml.dist.11
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
"symfony/deprecation-contracts": "^2.4 || ^3",
"symfony/dom-crawler": "^6.4 || ^7.3 || ^8.0",
"symfony/http-client": "^6.4 || ^7.0",
"symfony/http-client": "^6.4 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
"symfony/process": "^6.4 || ^7.3 || ^8.0"
},
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ parameters:
- tests/DummyKernel.php
# There are lots of missing phpunit classes since we are supporting multiple versions
- src/ServerExtension.php
reportUnmatchedIgnoredErrors: false
ignoreErrors:
# False positive
- '#Call to an undefined method ReflectionType::getName\(\)\.#'
# False positive : assertNotEmpty assert that count() !== 0 on Countable
- '#Call to static method PHPUnit\\Framework\\Assert::assert(Not)?Empty\(\) with Symfony\\Component\\DomCrawler\\Crawler will always evaluate to (true|false)\.#'
# False positive : getStatus exists for PHPUnit < 10 only
- '#Call to function method_exists\(\) with \$this\(Symfony\\Component\\Panther\\PantherTestCase\) and ''getStatus'' will always evaluate to true\.#'
# False positive : status exists for PHPUnit > 10 only
- '#Call to function method_exists\(\) with \$this\(Symfony\\Component\\Panther\\PantherTestCase\) and ''status'' will always evaluate to true\.#'
# False positive : PantherTestCase has no getClient method when symfony/framework-bundle (and WebTestCase) are not available
- '#Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Panther\\\\PantherTestCase'' and ''getClient'' will always evaluate to true\.#'
# To fix in PHP WebDriver
Expand Down
2 changes: 0 additions & 2 deletions phpunit.xml.dist.10
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

<php>
<env name="KERNEL_CLASS" value="Symfony\Component\Panther\Tests\DummyKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
<server name="SYMFONY_PHPUNIT_VERSION" value=">=10"/>
</php>

<testsuites>
Expand Down
38 changes: 38 additions & 0 deletions phpunit.xml.dist.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation comment references PHPUnit manual version 4.1, which is outdated for a PHPUnit 11 configuration file. This should reference the current PHPUnit 11 documentation URL.

Suggested change
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<!-- https://docs.phpunit.de/en/11.0/configuration.html -->

Copilot uses AI. Check for mistakes.
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="Symfony\Component\Panther\Tests\DummyKernel"/>
<server name="SHELL_VERBOSITY" value="-1" />
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<source ignoreSuppressionOfDeprecations="true"
ignoreIndirectDeprecations="true"
restrictNotices="true"
restrictWarnings="true"
>
<include>
<directory>src</directory>
</include>

<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
</source>

</phpunit>
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected function createCrawler(): PantherCrawler
return new PantherCrawler($elements, $this->webDriver, $this->webDriver->getCurrentURL());
}

protected function doRequest($request)
protected function doRequest(object $request): object
{
throw new LogicException('Not useful in WebDriver mode.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function matches(string $selector): bool
return $this->filterXPath($xpath)->count() > 0;
}

public function closest(string $selector): ?self
public function closest(string $selector): ?static
{
$converter = $this->createCssSelectorConverter();
$xpath = WebDriverBy::xpath($converter->toXPath($selector, 'self::'));
Expand Down
2 changes: 2 additions & 0 deletions tests/AssertionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Symfony\Component\Panther\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\AbstractBrowser;

Expand All @@ -29,6 +30,7 @@ protected function setUp(): void
}
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Facebook\WebDriver\JavaScriptExecutor;
use Facebook\WebDriver\WebDriver;
use Facebook\WebDriver\WebDriverExpectedCondition;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\BrowserKit\AbstractBrowser;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\BrowserKit\CookieJar as BrowserKitCookieJar;
Expand Down Expand Up @@ -56,6 +57,7 @@ public function testWaitForEmptyLocator(): void
$client->waitFor('');
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand Down Expand Up @@ -83,6 +85,7 @@ public static function waitForDataProvider(): iterable
yield 'xpath expression' => ['locator' => '//*[@id="hello"]'];
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -95,6 +98,7 @@ public function testWaitForVisibility(string $locator): void
$this->assertSame('Hello', $crawler->filter('#hello')->text(null, true));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -107,6 +111,7 @@ public function testWaitForInvisibility(string $locator): void
$this->assertSame('', $crawler->filter('#hello')->text(null, true));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -119,6 +124,7 @@ public function testWaitForElementToContain(string $locator): void
$this->assertSame('Hello new content', $crawler->filter('#hello')->text(null, true));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -131,6 +137,7 @@ public function testWaitForElementToNotContain(string $locator): void
$this->assertSame('Hello', $crawler->filter('#hello')->text(null, true));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -143,6 +150,7 @@ public function testWaitForEnabled(string $locator): void
$this->assertTrue($crawler->filter('#hello')->isEnabled());
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -155,6 +163,7 @@ public function testWaitForDisabled(string $locator): void
$this->assertFalse($crawler->filter('#hello')->isEnabled());
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -167,6 +176,7 @@ public function testWaitForAttributeToContain(string $locator): void
$this->assertSame('42', $crawler->filter('#hello')->getAttribute('data-old-price'));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand All @@ -179,6 +189,7 @@ public function testWaitForAttributeToNotContain(string $locator): void
$this->assertSame('36', $crawler->filter('#hello')->getAttribute('data-old-price'));
}

#[DataProvider('waitForDataProvider')]
/**
* @dataProvider waitForDataProvider
*/
Expand Down Expand Up @@ -244,6 +255,7 @@ public static function waitForExceptionsProvider(): iterable
];
}

#[DataProvider('waitForExceptionsProvider')]
/**
* @dataProvider waitForExceptionsProvider
*/
Expand Down Expand Up @@ -287,6 +299,7 @@ public function testExecuteAsyncScript(): void
$this->assertSame('P1', $innerText);
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down Expand Up @@ -318,6 +331,7 @@ public function testRefreshCrawler(): void
$this->assertSame('Hello', $refreshedCrawler->filter('h1')->text(null, true));
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand All @@ -336,6 +350,7 @@ public function testFollowLink(callable $clientFactory, string $type): void
$this->assertSame(self::$baseUri.'/basic.html#e12', $crawler->getUri());
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down Expand Up @@ -391,6 +406,7 @@ public function testSubmitForm(callable $clientFactory): void
$this->assertSame('I1: n/a', $crawler->filter('#result')->text(null, true));
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand All @@ -417,6 +433,7 @@ public function testSubmitFormWithValues(callable $clientFactory): void
$this->assertSame('I1: Reclus', $crawler->filter('#result')->text(null, true));
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down Expand Up @@ -444,6 +461,7 @@ public function testHistory(callable $clientFactory): void
$this->assertSame(self::$baseUri.'/link.html', $crawler->getUri());
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down Expand Up @@ -496,6 +514,7 @@ public function testCookie(callable $clientFactory, string $type): void
$this->assertNull($cookieJar->get('foo'));
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand All @@ -506,6 +525,7 @@ public function testServerPort(callable $clientFactory): void
$this->assertEquals($expectedPort, mb_substr(self::$baseUri, -4));
}

#[DataProvider('clientFactoryProvider')]
/**
* @dataProvider clientFactoryProvider
*/
Expand Down Expand Up @@ -593,6 +613,7 @@ public function testCreateHttpBrowserClientWithInvalidHttpClientOptions(): void
]);
}

#[DataProvider('providePrefersReducedMotion')]
/**
* @dataProvider providePrefersReducedMotion
*/
Expand All @@ -605,6 +626,7 @@ public function testPrefersReducedMotion(string $browser): void
$this->assertStringEndsWith('#clicked', $client->getCurrentURL());
}

#[DataProvider('providePrefersReducedMotion')]
/**
* @dataProvider providePrefersReducedMotion
*/
Expand Down
Loading
Loading