Skip to content

Commit 6a05d18

Browse files
committed
Tests with PHPUnit 11
1 parent c9c4cf1 commit 6a05d18

17 files changed

+182
-0
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,34 @@ jobs:
195195

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

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ parameters:
2525
- '#Call to an undefined method DOMNode::getTagName\(\)\.#'
2626
- '#Return type \(void\) of method Symfony\\Component\\Panther\\DomCrawler\\Crawler::clear\(\) should be compatible with return type \(Facebook\\WebDriver\\WebDriverElement\) of method Facebook\\WebDriver\\WebDriverElement::clear\(\)#'
2727
- '#Return type \(ArrayIterator<int, Facebook\\WebDriver\\WebDriverElement>\) of method Symfony\\Component\\Panther\\DomCrawler\\Crawler::getIterator\(\) should be compatible with return type \(ArrayIterator<int, DOMNode>\) of method Symfony\\Component\\DomCrawler\\Crawler::getIterator\(\)#'
28+
# PHPStan runs with lowest dependencies
29+
- '#Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist\.#'

phpunit.xml.dist.11

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
4+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
6+
backupGlobals="false"
7+
bootstrap="vendor/autoload.php"
8+
colors="true"
9+
cacheDirectory=".phpunit.cache"
10+
>
11+
12+
<coverage>
13+
<include>
14+
<directory>.</directory>
15+
</include>
16+
<exclude>
17+
<directory>tests</directory>
18+
<directory>vendor</directory>
19+
</exclude>
20+
</coverage>
21+
22+
<php>
23+
<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"/>
26+
</php>
27+
28+
<testsuites>
29+
<testsuite name="Project Test Suite">
30+
<directory>tests</directory>
31+
</testsuite>
32+
</testsuites>
33+
34+
</phpunit>

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)