|
19 | 19 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
20 | 20 | use Symfony\Component\BrowserKit\Cookie;
|
21 | 21 | use Symfony\Component\BrowserKit\CookieJar;
|
22 |
| -use Symfony\Component\DomCrawler\Crawler; |
| 22 | +use Symfony\Component\DomCrawler\DomCrawler; |
23 | 23 | use Symfony\Component\HttpFoundation\Cookie as HttpFoundationCookie;
|
24 | 24 | use Symfony\Component\HttpFoundation\Request;
|
25 | 25 | use Symfony\Component\HttpFoundation\Response;
|
@@ -192,126 +192,126 @@ public function testAssertBrowserCookieValueSame()
|
192 | 192 |
|
193 | 193 | public function testAssertSelectorExists()
|
194 | 194 | {
|
195 |
| - $this->getCrawlerTester(new Crawler('<html><body><h1>'))->assertSelectorExists('body > h1'); |
| 195 | + $this->getCrawlerTester(new DomCrawler('<html><body><h1>'))->assertSelectorExists('body > h1'); |
196 | 196 | $this->expectException(AssertionFailedError::class);
|
197 | 197 | $this->expectExceptionMessage('matches selector "body > h1".');
|
198 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertSelectorExists('body > h1'); |
| 198 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertSelectorExists('body > h1'); |
199 | 199 | }
|
200 | 200 |
|
201 | 201 | public function testAssertSelectorNotExists()
|
202 | 202 | {
|
203 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertSelectorNotExists('body > h1'); |
| 203 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertSelectorNotExists('body > h1'); |
204 | 204 | $this->expectException(AssertionFailedError::class);
|
205 | 205 | $this->expectExceptionMessage('does not match selector "body > h1".');
|
206 |
| - $this->getCrawlerTester(new Crawler('<html><body><h1>'))->assertSelectorNotExists('body > h1'); |
| 206 | + $this->getCrawlerTester(new DomCrawler('<html><body><h1>'))->assertSelectorNotExists('body > h1'); |
207 | 207 | }
|
208 | 208 |
|
209 | 209 | public function testAssertSelectorCount()
|
210 | 210 | {
|
211 |
| - $this->getCrawlerTester(new Crawler('<html><body><p>Hello</p></body></html>'))->assertSelectorCount(1, 'p'); |
212 |
| - $this->getCrawlerTester(new Crawler('<html><body><p>Hello</p><p>Foo</p></body></html>'))->assertSelectorCount(2, 'p'); |
213 |
| - $this->getCrawlerTester(new Crawler('<html><body><h1>This is not a paragraph.</h1></body></html>'))->assertSelectorCount(0, 'p'); |
| 211 | + $this->getCrawlerTester(new DomCrawler('<html><body><p>Hello</p></body></html>'))->assertSelectorCount(1, 'p'); |
| 212 | + $this->getCrawlerTester(new DomCrawler('<html><body><p>Hello</p><p>Foo</p></body></html>'))->assertSelectorCount(2, 'p'); |
| 213 | + $this->getCrawlerTester(new DomCrawler('<html><body><h1>This is not a paragraph.</h1></body></html>'))->assertSelectorCount(0, 'p'); |
214 | 214 | $this->expectException(AssertionFailedError::class);
|
215 | 215 | $this->expectExceptionMessage('Failed asserting that the Crawler selector "p" was expected to be found 0 time(s) but was found 1 time(s).');
|
216 |
| - $this->getCrawlerTester(new Crawler('<html><body><p>Hello</p></body></html>'))->assertSelectorCount(0, 'p'); |
| 216 | + $this->getCrawlerTester(new DomCrawler('<html><body><p>Hello</p></body></html>'))->assertSelectorCount(0, 'p'); |
217 | 217 | }
|
218 | 218 |
|
219 | 219 | public function testAssertSelectorTextNotContains()
|
220 | 220 | {
|
221 |
| - $this->getCrawlerTester(new Crawler('<html><body><h1>Foo'))->assertSelectorTextNotContains('body > h1', 'Bar'); |
| 221 | + $this->getCrawlerTester(new DomCrawler('<html><body><h1>Foo'))->assertSelectorTextNotContains('body > h1', 'Bar'); |
222 | 222 | $this->expectException(AssertionFailedError::class);
|
223 | 223 | $this->expectExceptionMessage('matches selector "body > h1" and the text "Foo" of the node matching selector "body > h1" does not contain "Foo".');
|
224 |
| - $this->getCrawlerTester(new Crawler('<html><body><h1>Foo'))->assertSelectorTextNotContains('body > h1', 'Foo'); |
| 224 | + $this->getCrawlerTester(new DomCrawler('<html><body><h1>Foo'))->assertSelectorTextNotContains('body > h1', 'Foo'); |
225 | 225 | }
|
226 | 226 |
|
227 | 227 | public function testAssertAnySelectorTextContains()
|
228 | 228 | {
|
229 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Foo Baz'))->assertAnySelectorTextContains('ul li', 'Foo'); |
| 229 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Foo Baz'))->assertAnySelectorTextContains('ul li', 'Foo'); |
230 | 230 | $this->expectException(AssertionFailedError::class);
|
231 | 231 | $this->expectExceptionMessage('matches selector "ul li" and the text of any node matching selector "ul li" contains "Foo".');
|
232 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextContains('ul li', 'Foo'); |
| 232 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextContains('ul li', 'Foo'); |
233 | 233 | }
|
234 | 234 |
|
235 | 235 | public function testAssertAnySelectorTextSame()
|
236 | 236 | {
|
237 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextSame('ul li', 'Foo'); |
| 237 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextSame('ul li', 'Foo'); |
238 | 238 | $this->expectException(AssertionFailedError::class);
|
239 | 239 | $this->expectExceptionMessage('matches selector "ul li" and has at least a node matching selector "ul li" with content "Foo".');
|
240 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextSame('ul li', 'Foo'); |
| 240 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextSame('ul li', 'Foo'); |
241 | 241 | }
|
242 | 242 |
|
243 | 243 | public function testAssertAnySelectorTextNotContains()
|
244 | 244 | {
|
245 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextNotContains('ul li', 'Foo'); |
| 245 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Baz'))->assertAnySelectorTextNotContains('ul li', 'Foo'); |
246 | 246 | $this->expectException(AssertionFailedError::class);
|
247 | 247 | $this->expectExceptionMessage('matches selector "ul li" and the text of any node matching selector "ul li" does not contain "Foo".');
|
248 |
| - $this->getCrawlerTester(new Crawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextNotContains('ul li', 'Foo'); |
| 248 | + $this->getCrawlerTester(new DomCrawler('<ul><li>Bar</li><li>Foo'))->assertAnySelectorTextNotContains('ul li', 'Foo'); |
249 | 249 | }
|
250 | 250 |
|
251 | 251 | public function testAssertPageTitleSame()
|
252 | 252 | {
|
253 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertPageTitleSame('Foo'); |
| 253 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertPageTitleSame('Foo'); |
254 | 254 | $this->expectException(AssertionFailedError::class);
|
255 | 255 | $this->expectExceptionMessage('matches selector "title" and has a node matching selector "title" with content "Bar".');
|
256 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertPageTitleSame('Bar'); |
| 256 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertPageTitleSame('Bar'); |
257 | 257 | }
|
258 | 258 |
|
259 | 259 | public function testAssertPageTitleContains()
|
260 | 260 | {
|
261 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foobar'))->assertPageTitleContains('Foo'); |
| 261 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foobar'))->assertPageTitleContains('Foo'); |
262 | 262 | $this->expectException(AssertionFailedError::class);
|
263 | 263 | $this->expectExceptionMessage('matches selector "title" and the text "Foo" of the node matching selector "title" contains "Bar".');
|
264 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertPageTitleContains('Bar'); |
| 264 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertPageTitleContains('Bar'); |
265 | 265 | }
|
266 | 266 |
|
267 | 267 | public function testAssertInputValueSame()
|
268 | 268 | {
|
269 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="text" name="username" value="Fabien">'))->assertInputValueSame('username', 'Fabien'); |
| 269 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="text" name="username" value="Fabien">'))->assertInputValueSame('username', 'Fabien'); |
270 | 270 | $this->expectException(AssertionFailedError::class);
|
271 | 271 | $this->expectExceptionMessage('matches selector "input[name="password"]" and has a node matching selector "input[name="password"]" with attribute "value" of value "pa$$".');
|
272 |
| - $this->getCrawlerTester(new Crawler('<html><head><title>Foo'))->assertInputValueSame('password', 'pa$$'); |
| 272 | + $this->getCrawlerTester(new DomCrawler('<html><head><title>Foo'))->assertInputValueSame('password', 'pa$$'); |
273 | 273 | }
|
274 | 274 |
|
275 | 275 | public function testAssertInputValueNotSame()
|
276 | 276 | {
|
277 |
| - $this->getCrawlerTester(new Crawler('<html><body><input type="text" name="username" value="Helene">'))->assertInputValueNotSame('username', 'Fabien'); |
| 277 | + $this->getCrawlerTester(new DomCrawler('<html><body><input type="text" name="username" value="Helene">'))->assertInputValueNotSame('username', 'Fabien'); |
278 | 278 | $this->expectException(AssertionFailedError::class);
|
279 | 279 | $this->expectExceptionMessage('matches selector "input[name="password"]" and does not have a node matching selector "input[name="password"]" with attribute "value" of value "pa$$".');
|
280 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="text" name="password" value="pa$$">'))->assertInputValueNotSame('password', 'pa$$'); |
| 280 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="text" name="password" value="pa$$">'))->assertInputValueNotSame('password', 'pa$$'); |
281 | 281 | }
|
282 | 282 |
|
283 | 283 | public function testAssertCheckboxChecked()
|
284 | 284 | {
|
285 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe'); |
286 |
| - $this->getCrawlerTester(new Crawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe'); |
| 285 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe'); |
| 286 | + $this->getCrawlerTester(new DomCrawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxChecked('rememberMe'); |
287 | 287 | $this->expectException(AssertionFailedError::class);
|
288 | 288 | $this->expectExceptionMessage('matches selector "input[name="rememberMe"]:checked".');
|
289 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxChecked('rememberMe'); |
| 289 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxChecked('rememberMe'); |
290 | 290 | }
|
291 | 291 |
|
292 | 292 | public function testAssertCheckboxNotChecked()
|
293 | 293 | {
|
294 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe'); |
295 |
| - $this->getCrawlerTester(new Crawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe'); |
| 294 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe'); |
| 295 | + $this->getCrawlerTester(new DomCrawler('<!DOCTYPE html><body><form><input type="checkbox" name="rememberMe">'))->assertCheckboxNotChecked('rememberMe'); |
296 | 296 | $this->expectException(AssertionFailedError::class);
|
297 | 297 | $this->expectExceptionMessage('does not match selector "input[name="rememberMe"]:checked".');
|
298 |
| - $this->getCrawlerTester(new Crawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxNotChecked('rememberMe'); |
| 298 | + $this->getCrawlerTester(new DomCrawler('<html><body><form><input type="checkbox" name="rememberMe" checked>'))->assertCheckboxNotChecked('rememberMe'); |
299 | 299 | }
|
300 | 300 |
|
301 | 301 | public function testAssertFormValue()
|
302 | 302 | {
|
303 |
| - $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="text" name="username" value="Fabien">', 'http://localhost'))->assertFormValue('#form', 'username', 'Fabien'); |
| 303 | + $this->getCrawlerTester(new DomCrawler('<html><body><form id="form"><input type="text" name="username" value="Fabien">', 'http://localhost'))->assertFormValue('#form', 'username', 'Fabien'); |
304 | 304 | $this->expectException(AssertionFailedError::class);
|
305 | 305 | $this->expectExceptionMessage('Failed asserting that two strings are identical.');
|
306 |
| - $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="text" name="username" value="Fabien">', 'http://localhost'))->assertFormValue('#form', 'username', 'Jane'); |
| 306 | + $this->getCrawlerTester(new DomCrawler('<html><body><form id="form"><input type="text" name="username" value="Fabien">', 'http://localhost'))->assertFormValue('#form', 'username', 'Jane'); |
307 | 307 | }
|
308 | 308 |
|
309 | 309 | public function testAssertNoFormValue()
|
310 | 310 | {
|
311 |
| - $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="checkbox" name="rememberMe">', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe'); |
| 311 | + $this->getCrawlerTester(new DomCrawler('<html><body><form id="form"><input type="checkbox" name="rememberMe">', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe'); |
312 | 312 | $this->expectException(AssertionFailedError::class);
|
313 | 313 | $this->expectExceptionMessage('Field "rememberMe" has a value in form "#form".');
|
314 |
| - $this->getCrawlerTester(new Crawler('<html><body><form id="form"><input type="checkbox" name="rememberMe" checked>', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe'); |
| 314 | + $this->getCrawlerTester(new DomCrawler('<html><body><form id="form"><input type="checkbox" name="rememberMe" checked>', 'http://localhost'))->assertNoFormValue('#form', 'rememberMe'); |
315 | 315 | }
|
316 | 316 |
|
317 | 317 | public function testAssertRequestAttributeValueSame()
|
@@ -357,7 +357,7 @@ private function getResponseTester(Response $response): WebTestCase
|
357 | 357 | return $this->getTester($client);
|
358 | 358 | }
|
359 | 359 |
|
360 |
| - private function getCrawlerTester(Crawler $crawler): WebTestCase |
| 360 | + private function getCrawlerTester(DomCrawler $crawler): WebTestCase |
361 | 361 | {
|
362 | 362 | $client = $this->createMock(KernelBrowser::class);
|
363 | 363 | $client->expects($this->any())->method('getCrawler')->willReturn($crawler);
|
|
0 commit comments