From 11df8c09f5cba4de59e7c716026a3a365be92091 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Mon, 25 Aug 2025 17:33:56 +0700 Subject: [PATCH] Fix CI --- .github/workflows/ci.yml | 2 +- src/PantherTestCaseTrait.php | 2 ++ tests/AssertionsTest.php | 2 ++ tests/ClientTest.php | 31 +++++++++++++--- tests/DomCrawler/CrawlerTest.php | 35 +++++++++++++++++-- .../DomCrawler/Field/ChoiceFormFieldTest.php | 13 ++++++- .../Field/EmailInputFormFieldTest.php | 5 +++ tests/DomCrawler/Field/FileFormFieldTest.php | 8 ++++- tests/DomCrawler/Field/InputFormFieldTest.php | 4 +++ .../Field/NumberInputFormFieldTest.php | 5 +++ .../Field/TextareaFormFieldTest.php | 4 +++ tests/DomCrawler/FormTest.php | 7 ++++ tests/FutureAssertionsTest.php | 12 +++++++ tests/ServerExtensionTest.php | 2 ++ tests/TestCase.php | 15 ++++++++ tests/WebDriver/WebDriverCheckBoxTest.php | 7 ++++ tests/WebDriver/WebDriverMouseTest.php | 2 ++ 17 files changed, 145 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed8bf5aa..fe90b1ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,7 +190,7 @@ jobs: - name: Remove phpunit-bridge dependency (not yet PHPUnit 10+ compliant) run: composer remove --dev symfony/phpunit-bridge - - name: Install latest PHPUnit 11 + - name: Install latest PHPUnit run: composer require --dev --prefer-dist 'phpunit/phpunit:>=10' - name: Run tests diff --git a/src/PantherTestCaseTrait.php b/src/PantherTestCaseTrait.php index d1860da5..62f00d5b 100644 --- a/src/PantherTestCaseTrait.php +++ b/src/PantherTestCaseTrait.php @@ -203,6 +203,7 @@ protected static function createPantherClient(array $options = [], array $kernel } } + // @phpstan-ignore-next-line if (is_a(self::class, KernelTestCase::class, true)) { static::bootKernel($kernelOptions); // @phpstan-ignore-line } @@ -247,6 +248,7 @@ protected static function createHttpBrowserClient(array $options = [], array $ke self::$httpBrowserClient = new HttpBrowserClient(HttpClient::create($httpClientOptions)); } + // @phpstan-ignore-next-line if (is_a(self::class, KernelTestCase::class, true)) { static::bootKernel($kernelOptions); // @phpstan-ignore-line } diff --git a/tests/AssertionsTest.php b/tests/AssertionsTest.php index 65ee6da1..205b7249 100644 --- a/tests/AssertionsTest.php +++ b/tests/AssertionsTest.php @@ -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; @@ -32,6 +33,7 @@ protected function setUp(): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testDomCrawlerAssertions(callable $clientFactory): void { $this->request($clientFactory, '/basic.html'); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index edda41dd..ee75f89f 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -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; @@ -59,6 +60,7 @@ public function testWaitForEmptyLocator(): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitFor(string $locator): void { $client = self::createPantherClient(); @@ -86,6 +88,7 @@ public static function waitForDataProvider(): iterable /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForVisibility(string $locator): void { $client = self::createPantherClient(); @@ -98,6 +101,7 @@ public function testWaitForVisibility(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForInvisibility(string $locator): void { $client = self::createPantherClient(); @@ -110,6 +114,7 @@ public function testWaitForInvisibility(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForElementToContain(string $locator): void { $client = self::createPantherClient(); @@ -122,6 +127,7 @@ public function testWaitForElementToContain(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForElementToNotContain(string $locator): void { $client = self::createPantherClient(); @@ -134,6 +140,7 @@ public function testWaitForElementToNotContain(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForEnabled(string $locator): void { $client = self::createPantherClient(); @@ -146,6 +153,7 @@ public function testWaitForEnabled(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForDisabled(string $locator): void { $client = self::createPantherClient(); @@ -158,6 +166,7 @@ public function testWaitForDisabled(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForAttributeToContain(string $locator): void { $client = self::createPantherClient(); @@ -170,6 +179,7 @@ public function testWaitForAttributeToContain(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForAttributeToNotContain(string $locator): void { $client = self::createPantherClient(); @@ -182,6 +192,7 @@ public function testWaitForAttributeToNotContain(string $locator): void /** * @dataProvider waitForDataProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForStalenessElement(string $locator): void { $client = self::createPantherClient(); @@ -247,6 +258,7 @@ public static function waitForExceptionsProvider(): iterable /** * @dataProvider waitForExceptionsProvider */ + #[DataProvider('waitForDataProvider')] public function testWaitForExceptions(string $method, array $args, string $message): void { $this->expectException(TimeoutException::class); @@ -282,15 +294,15 @@ public function testExecuteAsyncScript(): void const t = document.querySelector(parentArgs[0]).innerText; callback(t); }, 100, arguments); -JS - , ['.p-1']); +JS, ['.p-1']); $this->assertSame('P1', $innerText); } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testGetCrawler(callable $clientFactory, string $type): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -320,8 +332,9 @@ public function testRefreshCrawler(): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testFollowLink(callable $clientFactory, string $type): void { /** @var AbstractBrowser $client */ @@ -340,6 +353,7 @@ public function testFollowLink(callable $clientFactory, string $type): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('waitForDataProvider')] public function testSubmitForm(callable $clientFactory): void { /** @var AbstractBrowser $client */ @@ -395,6 +409,7 @@ public function testSubmitForm(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('waitForDataProvider')] public function testSubmitFormWithValues(callable $clientFactory): void { /** @var AbstractBrowser $client */ @@ -421,6 +436,7 @@ public function testSubmitFormWithValues(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('waitForDataProvider')] public function testHistory(callable $clientFactory): void { /** @var AbstractBrowser $client */ @@ -446,8 +462,9 @@ public function testHistory(callable $clientFactory): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testCookie(callable $clientFactory, string $type): void { /** @var AbstractBrowser $client */ @@ -500,6 +517,7 @@ public function testCookie(callable $clientFactory, string $type): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('waitForDataProvider')] public function testServerPort(callable $clientFactory): void { $expectedPort = $_SERVER['PANTHER_WEB_SERVER_PORT'] ?? '9080'; @@ -510,6 +528,7 @@ public function testServerPort(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('waitForDataProvider')] public function testBrowserProvider(callable $clientFactory): void { $client = $clientFactory(); @@ -599,6 +618,7 @@ public function testCreateHttpBrowserClientWithInvalidHttpClientOptions(): void /** * @dataProvider providePrefersReducedMotion */ + #[DataProvider('waitForDataProvider')] public function testPrefersReducedMotion(string $browser): void { $client = self::createPantherClient(['browser' => $browser]); @@ -611,6 +631,7 @@ public function testPrefersReducedMotion(string $browser): void /** * @dataProvider providePrefersReducedMotion */ + #[DataProvider('waitForDataProvider')] public function testPrefersReducedMotionDisabled(string $browser): void { $this->expectException(ElementClickInterceptedException::class); diff --git a/tests/DomCrawler/CrawlerTest.php b/tests/DomCrawler/CrawlerTest.php index 0347357c..fbab5324 100644 --- a/tests/DomCrawler/CrawlerTest.php +++ b/tests/DomCrawler/CrawlerTest.php @@ -14,6 +14,8 @@ namespace Symfony\Component\Panther\Tests\DomCrawler; use Facebook\WebDriver\WebDriverElement; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\Panther\Client; use Symfony\Component\Panther\Client as PantherClient; @@ -37,6 +39,7 @@ public function testCreateCrawler(): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetUri(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -46,6 +49,7 @@ public function testGetUri(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testHtml(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -55,6 +59,7 @@ public function testHtml(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testIterate(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -66,6 +71,7 @@ public function testIterate(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFilterXpath(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -89,6 +95,7 @@ public function testFilterXpath(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFilter(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -105,6 +112,7 @@ public function testFilter(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testReduce(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -118,6 +126,7 @@ public function testReduce(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testEq(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -127,6 +136,7 @@ public function testEq(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFirst(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -136,6 +146,7 @@ public function testFirst(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testLast(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -145,6 +156,7 @@ public function testLast(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSiblings(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -160,6 +172,7 @@ public function testSiblings(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testMatches(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -176,6 +189,7 @@ public function testMatches(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testClosest(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/closest.html'); @@ -204,6 +218,7 @@ public function testClosest(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testNextAll(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -219,6 +234,7 @@ public function testNextAll(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testPreviousAll(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -234,6 +250,7 @@ public function testPreviousAll(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testChildren(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -249,6 +266,7 @@ public function testChildren(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testChildrenFilter($clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -266,6 +284,8 @@ public function testChildrenFilter($clientFactory): void * * @group legacy */ + #[DataProvider('clientFactoryProvider')] + #[Group('legacy')] public function testParents(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -285,6 +305,7 @@ public function testParents(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testAncestors(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -300,6 +321,7 @@ public function testAncestors(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testExtract(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -311,8 +333,9 @@ public function testExtract(callable $clientFactory): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testLink(callable $clientFactory, string $type): void { $crawler = $this->request($clientFactory, '/link.html'); @@ -340,8 +363,9 @@ public function testLink(callable $clientFactory, string $type): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testImage(callable $clientFactory, string $type): void { $crawler = $this->request($clientFactory, '/link.html'); @@ -368,6 +392,7 @@ public function testImage(callable $clientFactory, string $type): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testTextDefault(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -377,6 +402,7 @@ public function testTextDefault(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testHtmlDefault(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -386,6 +412,7 @@ public function testHtmlDefault(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testEmptyHtml(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -395,6 +422,7 @@ public function testEmptyHtml(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testEmptyHtmlWithoutDefault(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/basic.html'); @@ -402,8 +430,9 @@ public function testEmptyHtmlWithoutDefault(callable $clientFactory): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testNormalizeText(callable $clientFactory, string $clientClass): void { if (PantherClient::class !== $clientClass) { diff --git a/tests/DomCrawler/Field/ChoiceFormFieldTest.php b/tests/DomCrawler/Field/ChoiceFormFieldTest.php index 2aa39d7d..88f3b236 100644 --- a/tests/DomCrawler/Field/ChoiceFormFieldTest.php +++ b/tests/DomCrawler/Field/ChoiceFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\ChoiceFormField; use Symfony\Component\Panther\Client as PantherClient; use Symfony\Component\Panther\Tests\TestCase; @@ -25,6 +26,7 @@ class ChoiceFormFieldTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromSelectIfOneIsSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -39,6 +41,7 @@ public function testGetValueFromSelectIfOneIsSelected(callable $clientFactory): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromSelectIfNoneIsSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -53,6 +56,7 @@ public function testGetValueFromSelectIfNoneIsSelected(callable $clientFactory): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromSelectMultipleIfOneIsSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -67,6 +71,7 @@ public function testGetValueFromSelectMultipleIfOneIsSelected(callable $clientFa /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromSelectMultipleIfMultipleIsSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -81,6 +86,7 @@ public function testGetValueFromSelectMultipleIfMultipleIsSelected(callable $cli /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromSelectMultipleIfNoneIsSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -95,6 +101,7 @@ public function testGetValueFromSelectMultipleIfNoneIsSelected(callable $clientF /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromRadioIfSelected(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -109,6 +116,7 @@ public function testGetValueFromRadioIfSelected(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromRadioIfNoneIsChecked(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -123,6 +131,7 @@ public function testGetValueFromRadioIfNoneIsChecked(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromCheckboxIfChecked(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -135,8 +144,9 @@ public function testGetValueFromCheckboxIfChecked(callable $clientFactory): void } /** - * @dataProvider clientFactoryProvider + * @dataProvider clientFactoryProviderWithType */ + #[DataProvider('clientFactoryProviderWithType')] public function testGetValueFromCheckboxIfMultipleAreChecked(callable $clientFactory, string $type): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); @@ -155,6 +165,7 @@ public function testGetValueFromCheckboxIfMultipleAreChecked(callable $clientFac /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueFromCheckboxIfNoneIsChecked(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/choice-form-field.html'); diff --git a/tests/DomCrawler/Field/EmailInputFormFieldTest.php b/tests/DomCrawler/Field/EmailInputFormFieldTest.php index c14f1812..9ec2c472 100644 --- a/tests/DomCrawler/Field/EmailInputFormFieldTest.php +++ b/tests/DomCrawler/Field/EmailInputFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\InputFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -24,6 +25,7 @@ class EmailInputFormFieldTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-email-form-field.html'); @@ -38,6 +40,7 @@ public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithNoValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-email-form-field.html'); @@ -52,6 +55,7 @@ public function testGetValueWithNoValueFromTextInput(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSetValueMultipleTimesInTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-email-form-field.html'); @@ -71,6 +75,7 @@ public function testSetValueMultipleTimesInTextInput(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testChangeValueFromExistingValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-email-form-field.html'); diff --git a/tests/DomCrawler/Field/FileFormFieldTest.php b/tests/DomCrawler/Field/FileFormFieldTest.php index 7e4ad01b..4f511c64 100644 --- a/tests/DomCrawler/Field/FileFormFieldTest.php +++ b/tests/DomCrawler/Field/FileFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\FileFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -41,6 +42,7 @@ private function assertValueContains($needle, $haystack): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFileUploadWithUpload(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/file-form-field.html'); @@ -57,6 +59,7 @@ public function testFileUploadWithUpload(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFileUploadWithSetValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/file-form-field.html'); @@ -73,7 +76,8 @@ public function testFileUploadWithSetValue(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ - public function testFileUploadWithSetFilePath(callable $clientFactory, $class): void + #[DataProvider('clientFactoryProvider')] + public function testFileUploadWithSetFilePath(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/file-form-field.html'); $form = $crawler->filter('form')->form(); @@ -92,6 +96,7 @@ public function testFileUploadWithSetFilePath(callable $clientFactory, $class): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFileUploadWithInvalidValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/file-form-field.html'); @@ -117,6 +122,7 @@ public function testFileUploadWithInvalidValue(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testPreventIsNotCanonicalError(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/file-form-field.html'); diff --git a/tests/DomCrawler/Field/InputFormFieldTest.php b/tests/DomCrawler/Field/InputFormFieldTest.php index b548f82c..ad822c5c 100644 --- a/tests/DomCrawler/Field/InputFormFieldTest.php +++ b/tests/DomCrawler/Field/InputFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\InputFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -24,6 +25,7 @@ class InputFormFieldTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-form-field.html'); @@ -38,6 +40,7 @@ public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithNoValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-form-field.html'); @@ -52,6 +55,7 @@ public function testGetValueWithNoValueFromTextInput(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSetValueMultipleTimesInTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-form-field.html'); diff --git a/tests/DomCrawler/Field/NumberInputFormFieldTest.php b/tests/DomCrawler/Field/NumberInputFormFieldTest.php index 3e96a754..57e87074 100644 --- a/tests/DomCrawler/Field/NumberInputFormFieldTest.php +++ b/tests/DomCrawler/Field/NumberInputFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\InputFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -24,6 +25,7 @@ class NumberInputFormFieldTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-number-form-field.html'); @@ -38,6 +40,7 @@ public function testGetValueWithSomeValueFromTextInput(callable $clientFactory): /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithNoValueFromTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-number-form-field.html'); @@ -52,6 +55,7 @@ public function testGetValueWithNoValueFromTextInput(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSetValueMultipleTimesInTextInput(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-number-form-field.html'); @@ -71,6 +75,7 @@ public function testSetValueMultipleTimesInTextInput(callable $clientFactory): v /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testChangeValueFromExistingValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/input-number-form-field.html'); diff --git a/tests/DomCrawler/Field/TextareaFormFieldTest.php b/tests/DomCrawler/Field/TextareaFormFieldTest.php index 101a879f..725dac0e 100644 --- a/tests/DomCrawler/Field/TextareaFormFieldTest.php +++ b/tests/DomCrawler/Field/TextareaFormFieldTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler\Field; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\TextareaFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -24,6 +25,7 @@ class TextareaFormFieldTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithSomeValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/textarea-form-field.html'); @@ -38,6 +40,7 @@ public function testGetValueWithSomeValue(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValueWithNoValue(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/textarea-form-field.html'); @@ -52,6 +55,7 @@ public function testGetValueWithNoValue(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSetValueMultipleTimes(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/textarea-form-field.html'); diff --git a/tests/DomCrawler/FormTest.php b/tests/DomCrawler/FormTest.php index b4ba3db4..0108fd9a 100644 --- a/tests/DomCrawler/FormTest.php +++ b/tests/DomCrawler/FormTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\DomCrawler; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\DomCrawler\Field\ChoiceFormField; use Symfony\Component\Panther\Tests\TestCase; @@ -24,6 +25,7 @@ class FormTest extends TestCase /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFormByButton(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); @@ -50,6 +52,7 @@ public function testFormByButton(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFormById(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); @@ -73,6 +76,7 @@ public function testFormById(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testFormFields(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); @@ -99,6 +103,7 @@ public function testFormFields(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testSelect(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); @@ -134,6 +139,7 @@ public function testSelect(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetValuesDoesNotContainFiles(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); @@ -149,6 +155,7 @@ public function testGetValuesDoesNotContainFiles(callable $clientFactory): void /** * @dataProvider clientFactoryProvider */ + #[DataProvider('clientFactoryProvider')] public function testGetFilesContainOnlyFiles(callable $clientFactory): void { $crawler = $this->request($clientFactory, '/form.html'); diff --git a/tests/FutureAssertionsTest.php b/tests/FutureAssertionsTest.php index 93a21348..961ee3b4 100644 --- a/tests/FutureAssertionsTest.php +++ b/tests/FutureAssertionsTest.php @@ -13,9 +13,12 @@ namespace Symfony\Component\Panther\Tests; +use PHPUnit\Framework\Attributes\DataProvider; + class FutureAssertionsTest extends TestCase { /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureExistenceAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor.html'); @@ -24,6 +27,7 @@ public function testFutureExistenceAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureStalenessAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-staleness.html'); @@ -32,6 +36,7 @@ public function testFutureStalenessAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureVisibilityAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-element-to-be-visible.html'); @@ -41,6 +46,7 @@ public function testFutureVisibilityAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureInvisibilityAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-element-to-be-invisible.html'); @@ -49,6 +55,7 @@ public function testFutureInvisibilityAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureContainAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-element-to-contain.html'); @@ -57,6 +64,7 @@ public function testFutureContainAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureNotContainAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-element-to-not-contain.html'); @@ -65,6 +73,7 @@ public function testFutureNotContainAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureEnabledAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-input-to-be-enabled.html'); @@ -73,6 +82,7 @@ public function testFutureEnabledAssertion(string $locator): void } /** @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureDisabledAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-input-to-be-disabled.html'); @@ -83,6 +93,7 @@ public function testFutureDisabledAssertion(string $locator): void /** * @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureAttributeContainAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-attribute-to-contain.html'); @@ -93,6 +104,7 @@ public function testFutureAttributeContainAssertion(string $locator): void /** * @dataProvider futureDataProvider */ + #[DataProvider('futureDataProvider')] public function testFutureAttributeNotContainAssertion(string $locator): void { $crawler = self::createPantherClient()->request('GET', '/waitfor-attribute-to-contain.html'); diff --git a/tests/ServerExtensionTest.php b/tests/ServerExtensionTest.php index a5c9db00..087b90da 100644 --- a/tests/ServerExtensionTest.php +++ b/tests/ServerExtensionTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Panther\PantherTestCase; use Symfony\Component\Panther\ServerExtensionLegacy; @@ -37,6 +38,7 @@ public function testStartAndStop(): void /** * @dataProvider provideTestPauseOnFailure */ + #[DataProvider('provideTestPauseOnFailure')] public function testPauseOnFailure(string $method, string $expected): void { $extension = new ServerExtensionLegacy(); diff --git a/tests/TestCase.php b/tests/TestCase.php index d59d043f..711615c4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -28,6 +28,21 @@ abstract class TestCase extends PantherTestCase protected static ?string $webServerDir = __DIR__.'/fixtures'; public static function clientFactoryProvider(): iterable + { + // Tests must pass with both Panther and HttpBrowser + yield 'HttpBrowser' => [[static::class, 'createHttpBrowserClient']]; + yield 'Panther' => [[static::class, 'createPantherClient']]; + + if ('' === ($_SERVER['SKIP_FIREFOX'] ?? '')) { + $firefoxFactory = static function (): PantherClient { + return self::createPantherClient(['browser' => self::FIREFOX]); + }; + + yield 'PantherFirefox' => [$firefoxFactory]; + } + } + + public static function clientFactoryProviderWithType(): iterable { // Tests must pass with both Panther and HttpBrowser yield 'HttpBrowser' => [[static::class, 'createHttpBrowserClient'], HttpBrowserClient::class]; diff --git a/tests/WebDriver/WebDriverCheckBoxTest.php b/tests/WebDriver/WebDriverCheckBoxTest.php index d3e1eecf..9b073036 100644 --- a/tests/WebDriver/WebDriverCheckBoxTest.php +++ b/tests/WebDriver/WebDriverCheckBoxTest.php @@ -15,6 +15,7 @@ use Facebook\WebDriver\Exception\NoSuchElementException; use Facebook\WebDriver\Exception\UnsupportedOperationException; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Panther\Tests\TestCase; use Symfony\Component\Panther\WebDriver\WebDriverCheckbox; @@ -39,6 +40,7 @@ public function testWebDriverCheckboxIsMultiple(): void /** * @dataProvider getOptionsDataProvider */ + #[DataProvider('getOptionsDataProvider')] public function testWebDriverCheckboxGetOptions(string $type, array $options): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); @@ -77,6 +79,7 @@ public function testWebDriverCheckboxGetFirstSelectedOption(): void /** * @dataProvider selectByValueDataProvider */ + #[DataProvider('selectByValueDataProvider')] public function testWebDriverCheckboxSelectByValue(string $type, array $selectedOptions): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); @@ -114,6 +117,7 @@ public function testWebDriverCheckboxSelectByValueInvalid(): void /** * @dataProvider selectByIndexDataProvider */ + #[DataProvider('selectByIndexDataProvider')] public function testWebDriverCheckboxSelectByIndex(string $type, array $selectedOptions): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); @@ -151,6 +155,7 @@ public function testWebDriverCheckboxSelectByIndexInvalid(): void /** * @dataProvider selectByVisibleTextDataProvider */ + #[DataProvider('selectByVisibleTextDataProvider')] public function testWebDriverCheckboxSelectByVisibleText(string $type, string $text, string $value): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); @@ -172,6 +177,7 @@ public static function selectByVisibleTextDataProvider(): iterable /** * @dataProvider selectByVisiblePartialTextDataProvider */ + #[DataProvider('selectByVisiblePartialTextDataProvider')] public function testWebDriverCheckboxSelectByVisiblePartialText(string $type, string $text, string $value): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); @@ -303,6 +309,7 @@ public function testWebDriverCheckboxDeselectByVisiblePartialTextRadio(): void /** * @dataProvider selectByValueDataProviderWithZeroValue */ + #[DataProvider('selectByValueDataProviderWithZeroValue')] public function testWebDriverCheckboxSelectByValueWithZeroValue(string $type, string $selectedAndExpectedOption): void { $crawler = self::createPantherClient()->request('GET', self::$baseUri.'/form.html'); diff --git a/tests/WebDriver/WebDriverMouseTest.php b/tests/WebDriver/WebDriverMouseTest.php index f31fbe36..545f9cee 100644 --- a/tests/WebDriver/WebDriverMouseTest.php +++ b/tests/WebDriver/WebDriverMouseTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Panther\Tests\WebDriver; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Panther\Tests\TestCase; /** @@ -28,6 +29,7 @@ public static function setUpBeforeClass(): void /** * @dataProvider provide */ + #[DataProvider('provide')] public function test(string $method, string $cssSelector, string $result): void { $client = self::createPantherClient();