Skip to content

Commit 2f9393d

Browse files
committed
Fix PHPUnit DataProvider
1 parent 3a49dcb commit 2f9393d

14 files changed

+118
-0
lines changed

tests/AssertionsTest.php

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

1616
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1717
use Symfony\Component\BrowserKit\AbstractBrowser;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819

1920
class AssertionsTest extends TestCase
2021
{
@@ -29,6 +30,7 @@ protected function setUp(): void
2930
}
3031
}
3132

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

tests/ClientTest.php

Lines changed: 23 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,8 @@ public function testWaitForEmptyLocator(): void
5657
$client->waitFor('');
5758
}
5859

60+
#[DataProvider('waitForDataProvider')]
61+
5962
/**
6063
* @dataProvider waitForDataProvider
6164
*/
@@ -83,6 +86,7 @@ public static function waitForDataProvider(): iterable
8386
yield 'xpath expression' => ['locator' => '//*[@id="hello"]'];
8487
}
8588

89+
#[DataProvider('waitForDataProvider')]
8690
/**
8791
* @dataProvider waitForDataProvider
8892
*/
@@ -95,6 +99,7 @@ public function testWaitForVisibility(string $locator): void
9599
$this->assertSame('Hello', $crawler->filter('#hello')->text(null, true));
96100
}
97101

102+
#[DataProvider('waitForDataProvider')]
98103
/**
99104
* @dataProvider waitForDataProvider
100105
*/
@@ -107,6 +112,7 @@ public function testWaitForInvisibility(string $locator): void
107112
$this->assertSame('', $crawler->filter('#hello')->text(null, true));
108113
}
109114

115+
#[DataProvider('waitForDataProvider')]
110116
/**
111117
* @dataProvider waitForDataProvider
112118
*/
@@ -119,6 +125,7 @@ public function testWaitForElementToContain(string $locator): void
119125
$this->assertSame('Hello new content', $crawler->filter('#hello')->text(null, true));
120126
}
121127

128+
#[DataProvider('waitForDataProvider')]
122129
/**
123130
* @dataProvider waitForDataProvider
124131
*/
@@ -131,6 +138,7 @@ public function testWaitForElementToNotContain(string $locator): void
131138
$this->assertSame('Hello', $crawler->filter('#hello')->text(null, true));
132139
}
133140

141+
#[DataProvider('waitForDataProvider')]
134142
/**
135143
* @dataProvider waitForDataProvider
136144
*/
@@ -143,6 +151,7 @@ public function testWaitForEnabled(string $locator): void
143151
$this->assertTrue($crawler->filter('#hello')->isEnabled());
144152
}
145153

154+
#[DataProvider('waitForDataProvider')]
146155
/**
147156
* @dataProvider waitForDataProvider
148157
*/
@@ -155,6 +164,7 @@ public function testWaitForDisabled(string $locator): void
155164
$this->assertFalse($crawler->filter('#hello')->isEnabled());
156165
}
157166

167+
#[DataProvider('waitForDataProvider')]
158168
/**
159169
* @dataProvider waitForDataProvider
160170
*/
@@ -167,6 +177,7 @@ public function testWaitForAttributeToContain(string $locator): void
167177
$this->assertSame('42', $crawler->filter('#hello')->getAttribute('data-old-price'));
168178
}
169179

180+
#[DataProvider('waitForDataProvider')]
170181
/**
171182
* @dataProvider waitForDataProvider
172183
*/
@@ -179,6 +190,7 @@ public function testWaitForAttributeToNotContain(string $locator): void
179190
$this->assertSame('36', $crawler->filter('#hello')->getAttribute('data-old-price'));
180191
}
181192

193+
#[DataProvider('waitForDataProvider')]
182194
/**
183195
* @dataProvider waitForDataProvider
184196
*/
@@ -244,6 +256,7 @@ public static function waitForExceptionsProvider(): iterable
244256
];
245257
}
246258

259+
#[DataProvider('waitForExceptionsProvider')]
247260
/**
248261
* @dataProvider waitForExceptionsProvider
249262
*/
@@ -288,6 +301,7 @@ public function testExecuteAsyncScript(): void
288301
$this->assertSame('P1', $innerText);
289302
}
290303

304+
#[DataProvider('clientFactoryProvider')]
291305
/**
292306
* @dataProvider clientFactoryProvider
293307
*/
@@ -319,6 +333,7 @@ public function testRefreshCrawler(): void
319333
$this->assertSame('Hello', $refreshedCrawler->filter('h1')->text(null, true));
320334
}
321335

336+
#[DataProvider('clientFactoryProvider')]
322337
/**
323338
* @dataProvider clientFactoryProvider
324339
*/
@@ -337,6 +352,7 @@ public function testFollowLink(callable $clientFactory, string $type): void
337352
$this->assertSame(self::$baseUri.'/basic.html#e12', $crawler->getUri());
338353
}
339354

355+
#[DataProvider('clientFactoryProvider')]
340356
/**
341357
* @dataProvider clientFactoryProvider
342358
*/
@@ -392,6 +408,7 @@ public function testSubmitForm(callable $clientFactory): void
392408
$this->assertSame('I1: n/a', $crawler->filter('#result')->text(null, true));
393409
}
394410

411+
#[DataProvider('clientFactoryProvider')]
395412
/**
396413
* @dataProvider clientFactoryProvider
397414
*/
@@ -418,6 +435,7 @@ public function testSubmitFormWithValues(callable $clientFactory): void
418435
$this->assertSame('I1: Reclus', $crawler->filter('#result')->text(null, true));
419436
}
420437

438+
#[DataProvider('clientFactoryProvider')]
421439
/**
422440
* @dataProvider clientFactoryProvider
423441
*/
@@ -445,6 +463,7 @@ public function testHistory(callable $clientFactory): void
445463
$this->assertSame(self::$baseUri.'/link.html', $crawler->getUri());
446464
}
447465

466+
#[DataProvider('clientFactoryProvider')]
448467
/**
449468
* @dataProvider clientFactoryProvider
450469
*/
@@ -497,6 +516,7 @@ public function testCookie(callable $clientFactory, string $type): void
497516
$this->assertNull($cookieJar->get('foo'));
498517
}
499518

519+
#[DataProvider('clientFactoryProvider')]
500520
/**
501521
* @dataProvider clientFactoryProvider
502522
*/
@@ -507,6 +527,7 @@ public function testServerPort(callable $clientFactory): void
507527
$this->assertEquals($expectedPort, mb_substr(self::$baseUri, -4));
508528
}
509529

530+
#[DataProvider('clientFactoryProvider')]
510531
/**
511532
* @dataProvider clientFactoryProvider
512533
*/
@@ -596,6 +617,7 @@ public function testCreateHttpBrowserClientWithInvalidHttpClientOptions(): void
596617
]);
597618
}
598619

620+
#[DataProvider('providePrefersReducedMotion')]
599621
/**
600622
* @dataProvider providePrefersReducedMotion
601623
*/
@@ -608,6 +630,7 @@ public function testPrefersReducedMotion(string $browser): void
608630
$this->assertStringEndsWith('#clicked', $client->getCurrentURL());
609631
}
610632

633+
#[DataProvider('providePrefersReducedMotion')]
611634
/**
612635
* @dataProvider providePrefersReducedMotion
613636
*/

0 commit comments

Comments
 (0)