Skip to content

Commit 2d81039

Browse files
committed
feature #678 Symfony 8 support follow-up, PHPUnit 11 (Kocal)
This PR was squashed before being merged into the 2.0.x-dev branch. Discussion ---------- Symfony 8 support follow-up, PHPUnit 11 IIRC the CI was already broken before this PR Blockers: - php-webdriver/php-webdriver#1134 Commits ------- 814b155 Symfony 8 support follow-up, PHPUnit 11
2 parents bc606ef + 814b155 commit 2d81039

22 files changed

+200
-8
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ jobs:
3737

3838
- name: Install dependencies
3939
uses: ramsey/composer-install@v3
40+
with:
41+
dependency-versions: highest
4042
env:
41-
SYMFONY_REQUIRE: ^7
43+
SYMFONY_REQUIRE: ^8
4244

4345
- name: Install PHPUnit dependencies
44-
run: vendor/bin/simple-phpunit --version
46+
run: SYMFONY_PHPUNIT_VERSION=11.5 vendor/bin/simple-phpunit --version
4547

4648
- name: PHPStan
4749
run: phpstan analyse --no-progress
@@ -195,3 +197,34 @@ jobs:
195197

196198
- name: Run tests
197199
run: vendor/bin/phpunit --configuration phpunit.xml.dist.10
200+
201+
phpunit-11:
202+
runs-on: ubuntu-latest
203+
strategy:
204+
matrix:
205+
php-versions: ['8.2', '8.3', '8.4', '8.5']
206+
fail-fast: false
207+
name: PHP ${{ matrix.php-versions }} (PHPUnit 11) Test on ubuntu-latest
208+
steps:
209+
- name: Checkout
210+
uses: actions/checkout@v5
211+
212+
- name: Setup PHP
213+
uses: shivammathur/setup-php@v2
214+
with:
215+
php-version: ${{ matrix.php-versions }}
216+
extensions: zip
217+
218+
- name: Install dependencies
219+
uses: ramsey/composer-install@v3
220+
with:
221+
composer-options: "--prefer-dist"
222+
223+
- name: Remove phpunit-bridge dependency (not yet PHPUnit 11+ compliant)
224+
run: composer remove --dev symfony/phpunit-bridge
225+
226+
- name: Install latest PHPUnit 11
227+
run: composer require --dev --prefer-dist 'phpunit/phpunit:11.5.*'
228+
229+
- name: Run tests
230+
run: vendor/bin/phpunit --configuration phpunit.xml.dist.11

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
3333
"symfony/deprecation-contracts": "^2.4 || ^3",
3434
"symfony/dom-crawler": "^6.4 || ^7.3 || ^8.0",
35-
"symfony/http-client": "^6.4 || ^7.0",
35+
"symfony/http-client": "^6.4 || ^7.0 || ^8.0",
3636
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
3737
"symfony/process": "^6.4 || ^7.3 || ^8.0"
3838
},

phpstan.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ parameters:
1010
- tests/DummyKernel.php
1111
# There are lots of missing phpunit classes since we are supporting multiple versions
1212
- src/ServerExtension.php
13+
reportUnmatchedIgnoredErrors: false
1314
ignoreErrors:
1415
# False positive
1516
- '#Call to an undefined method ReflectionType::getName\(\)\.#'
1617
# False positive : assertNotEmpty assert that count() !== 0 on Countable
1718
- '#Call to static method PHPUnit\\Framework\\Assert::assert(Not)?Empty\(\) with Symfony\\Component\\DomCrawler\\Crawler will always evaluate to (true|false)\.#'
1819
# False positive : getStatus exists for PHPUnit < 10 only
1920
- '#Call to function method_exists\(\) with \$this\(Symfony\\Component\\Panther\\PantherTestCase\) and ''getStatus'' will always evaluate to true\.#'
21+
# False positive : status exists for PHPUnit > 10 only
22+
- '#Call to function method_exists\(\) with \$this\(Symfony\\Component\\Panther\\PantherTestCase\) and ''status'' will always evaluate to true\.#'
2023
# False positive : PantherTestCase has no getClient method when symfony/framework-bundle (and WebTestCase) are not available
2124
- '#Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Panther\\\\PantherTestCase'' and ''getClient'' will always evaluate to true\.#'
2225
# To fix in PHP WebDriver

phpunit.xml.dist.10

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
<php>
2323
<env name="KERNEL_CLASS" value="Symfony\Component\Panther\Tests\DummyKernel"/>
24-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
25-
<server name="SYMFONY_PHPUNIT_VERSION" value=">=10"/>
2624
</php>
2725

2826
<testsuites>

phpunit.xml.dist.11

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- https://docs.phpunit.de/en/11.0/configuration.html -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6+
backupGlobals="false"
7+
bootstrap="vendor/autoload.php"
8+
colors="true"
9+
cacheDirectory=".phpunit.cache"
10+
>
11+
<php>
12+
<ini name="display_errors" value="1" />
13+
<ini name="error_reporting" value="-1" />
14+
<env name="KERNEL_CLASS" value="Symfony\Component\Panther\Tests\DummyKernel"/>
15+
<server name="SHELL_VERBOSITY" value="-1" />
16+
</php>
17+
18+
<testsuites>
19+
<testsuite name="Project Test Suite">
20+
<directory>tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
24+
<source ignoreSuppressionOfDeprecations="true"
25+
ignoreIndirectDeprecations="true"
26+
restrictNotices="true"
27+
restrictWarnings="true"
28+
>
29+
<include>
30+
<directory>src</directory>
31+
</include>
32+
33+
<deprecationTrigger>
34+
<function>trigger_deprecation</function>
35+
</deprecationTrigger>
36+
</source>
37+
38+
</phpunit>

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ protected function createCrawler(): PantherCrawler
291291
return new PantherCrawler($elements, $this->webDriver, $this->webDriver->getCurrentURL());
292292
}
293293

294-
protected function doRequest($request)
294+
protected function doRequest(object $request): object
295295
{
296296
throw new LogicException('Not useful in WebDriver mode.');
297297
}

src/DomCrawler/Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function matches(string $selector): bool
142142
return $this->filterXPath($xpath)->count() > 0;
143143
}
144144

145-
public function closest(string $selector): ?self
145+
public function closest(string $selector): ?static
146146
{
147147
$converter = $this->createCssSelectorConverter();
148148
$xpath = WebDriverBy::xpath($converter->toXPath($selector, 'self::'));

tests/AssertionsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Symfony\Component\Panther\Tests;
1515

16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1718
use Symfony\Component\BrowserKit\AbstractBrowser;
1819

@@ -29,6 +30,7 @@ protected function setUp(): void
2930
}
3031
}
3132

33+
#[DataProvider('clientFactoryProvider')]
3234
/**
3335
* @dataProvider clientFactoryProvider
3436
*/

tests/ClientTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Facebook\WebDriver\JavaScriptExecutor;
2121
use Facebook\WebDriver\WebDriver;
2222
use Facebook\WebDriver\WebDriverExpectedCondition;
23+
use PHPUnit\Framework\Attributes\DataProvider;
2324
use Symfony\Component\BrowserKit\AbstractBrowser;
2425
use Symfony\Component\BrowserKit\Cookie;
2526
use Symfony\Component\BrowserKit\CookieJar as BrowserKitCookieJar;
@@ -56,6 +57,7 @@ public function testWaitForEmptyLocator(): void
5657
$client->waitFor('');
5758
}
5859

60+
#[DataProvider('waitForDataProvider')]
5961
/**
6062
* @dataProvider waitForDataProvider
6163
*/
@@ -83,6 +85,7 @@ public static function waitForDataProvider(): iterable
8385
yield 'xpath expression' => ['locator' => '//*[@id="hello"]'];
8486
}
8587

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

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

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

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

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

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

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

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

192+
#[DataProvider('waitForDataProvider')]
182193
/**
183194
* @dataProvider waitForDataProvider
184195
*/
@@ -244,6 +255,7 @@ public static function waitForExceptionsProvider(): iterable
244255
];
245256
}
246257

258+
#[DataProvider('waitForExceptionsProvider')]
247259
/**
248260
* @dataProvider waitForExceptionsProvider
249261
*/
@@ -287,6 +299,7 @@ public function testExecuteAsyncScript(): void
287299
$this->assertSame('P1', $innerText);
288300
}
289301

302+
#[DataProvider('clientFactoryProvider')]
290303
/**
291304
* @dataProvider clientFactoryProvider
292305
*/
@@ -318,6 +331,7 @@ public function testRefreshCrawler(): void
318331
$this->assertSame('Hello', $refreshedCrawler->filter('h1')->text(null, true));
319332
}
320333

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

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

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

436+
#[DataProvider('clientFactoryProvider')]
420437
/**
421438
* @dataProvider clientFactoryProvider
422439
*/
@@ -444,6 +461,7 @@ public function testHistory(callable $clientFactory): void
444461
$this->assertSame(self::$baseUri.'/link.html', $crawler->getUri());
445462
}
446463

464+
#[DataProvider('clientFactoryProvider')]
447465
/**
448466
* @dataProvider clientFactoryProvider
449467
*/
@@ -496,6 +514,7 @@ public function testCookie(callable $clientFactory, string $type): void
496514
$this->assertNull($cookieJar->get('foo'));
497515
}
498516

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

528+
#[DataProvider('clientFactoryProvider')]
509529
/**
510530
* @dataProvider clientFactoryProvider
511531
*/
@@ -593,6 +613,7 @@ public function testCreateHttpBrowserClientWithInvalidHttpClientOptions(): void
593613
]);
594614
}
595615

616+
#[DataProvider('providePrefersReducedMotion')]
596617
/**
597618
* @dataProvider providePrefersReducedMotion
598619
*/
@@ -605,6 +626,7 @@ public function testPrefersReducedMotion(string $browser): void
605626
$this->assertStringEndsWith('#clicked', $client->getCurrentURL());
606627
}
607628

629+
#[DataProvider('providePrefersReducedMotion')]
608630
/**
609631
* @dataProvider providePrefersReducedMotion
610632
*/

0 commit comments

Comments
 (0)