2525use Symfony \Component \Panther \Client ;
2626use Symfony \Component \Panther \Cookie \CookieJar ;
2727use Symfony \Component \Panther \DomCrawler \Crawler ;
28+ use Symfony \Component \Panther \ProcessManager \ChromeManager ;
2829
2930/**
3031 * @author Kévin Dunglas <[email protected] > @@ -61,16 +62,10 @@ public function testWaitFor(string $locator)
6162 $ this ->assertSame ('Hello ' , $ crawler ->filter ('#hello ' )->text ());
6263 }
6364
64- public function waitForDataProvider (): array
65+ public function waitForDataProvider (): iterable
6566 {
66- return [
67- 'css selector ' => [
68- 'locator ' => '#hello ' ,
69- ],
70- 'xpath expression ' => [
71- 'locator ' => '//*[@id="hello"] ' ,
72- ],
73- ];
67+ yield 'css selector ' => ['locator ' => '#hello ' ];
68+ yield 'xpath expression ' => ['locator ' => '//*[@id="hello"] ' ];
7469 }
7570
7671 public function testWaitForInvisibleElement (): void
@@ -158,7 +153,7 @@ public function testFollowLink(callable $clientFactory, string $type): void
158153 /**
159154 * @dataProvider clientFactoryProvider
160155 */
161- public function testSubmitForm (callable $ clientFactory, string $ type ): void
156+ public function testSubmitForm (callable $ clientFactory ): void
162157 {
163158 /** @var AbstractBrowser $client */
164159 $ client = $ clientFactory ();
@@ -169,7 +164,7 @@ public function testSubmitForm(callable $clientFactory, string $type): void
169164
170165 $ crawler = $ client ->submit ($ form );
171166 $ this ->assertInstanceOf (DomCrawlerCrawler::class, $ crawler );
172- if (Client::class === $ type ) {
167+ if ($ client instanceof Client ) {
173168 $ this ->assertInstanceOf (Crawler::class, $ crawler );
174169 }
175170 $ this ->assertSame (self ::$ baseUri .'/form-handle.php ' , $ crawler ->getUri ());
@@ -294,4 +289,18 @@ public function testServerPort(callable $clientFactory): void
294289 $ clientFactory ();
295290 $ this ->assertEquals ($ expectedPort , \mb_substr (self ::$ baseUri , -4 ));
296291 }
292+
293+ /**
294+ * @dataProvider clientFactoryProvider
295+ */
296+ public function testBrowserProvider (callable $ clientFactory ): void
297+ {
298+ $ client = $ clientFactory ();
299+ if (!$ client instanceof Client) {
300+ $ this ->markTestSkipped ();
301+ }
302+
303+ $ client ->request ('GET ' , self ::$ baseUri .'/ua.php ' );
304+ $ this ->assertStringContainsString ($ client ->getBrowserManager () instanceof ChromeManager ? 'Chrome ' : 'Firefox ' , $ client ->getPageSource ());
305+ }
297306}
0 commit comments