@@ -411,6 +411,74 @@ public function testFilterXPath()
411
411
$ this ->assertCount (3 , $ crawler ->filterXPath ('//body ' )->filterXPath ('//button ' )->parents (), '->filterXpath() preserves parents when chained ' );
412
412
}
413
413
414
+ public function testFilterXPathWithAncestorAxis ()
415
+ {
416
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//form ' );
417
+
418
+ $ this ->assertCount (2 , $ crawler ->filterXPath ('ancestor::* ' ));
419
+ }
420
+
421
+ public function testFilterXPathWithAncestorOrSelfAxis ()
422
+ {
423
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//form ' );
424
+
425
+ $ this ->assertCount (3 , $ crawler ->filterXPath ('ancestor-or-self::* ' ));
426
+ }
427
+
428
+ public function testFilterXPathWithAttributeAxis ()
429
+ {
430
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//form ' );
431
+
432
+ $ this ->assertCount (2 , $ crawler ->filterXPath ('attribute::* ' ));
433
+ }
434
+
435
+ public function testFilterXPathWithChildAxis ()
436
+ {
437
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//body ' );
438
+
439
+ $ this ->assertCount (2 , $ crawler ->filterXPath ('child::input ' ));
440
+ }
441
+
442
+ public function testFilterXPathWithFollowingAxis ()
443
+ {
444
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//a ' );
445
+
446
+ $ this ->assertCount (3 , $ crawler ->filterXPath ('following::div ' ));
447
+ }
448
+
449
+ public function testFilterXPathWithFollowingSiblingAxis ()
450
+ {
451
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//a ' );
452
+
453
+ $ this ->assertCount (2 , $ crawler ->filterXPath ('following-sibling::div ' ));
454
+ }
455
+
456
+ public function testFilterXPathWithParentAxis ()
457
+ {
458
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//button ' );
459
+
460
+ $ this ->assertEquals ('foo ' , $ crawler ->filterXPath ('parent::* ' )->attr ('action ' ));
461
+ }
462
+
463
+ public function testFilterXPathWithPrecedingAxis ()
464
+ {
465
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//form ' );
466
+
467
+ $ this ->assertCount (13 , $ crawler ->filterXPath ('preceding::* ' ));
468
+ }
469
+
470
+ public function testFilterXPathWithPrecedingSiblingAxis ()
471
+ {
472
+ $ crawler = $ this ->createTestCrawler ()->filterXPath ('//form ' );
473
+
474
+ $ this ->assertCount (9 , $ crawler ->filterXPath ('preceding-sibling::* ' ));
475
+ }
476
+
477
+ public function testFilterXPathWithSelfAxes ()
478
+ {
479
+ $ this ->assertCount (1 , $ this ->createTestCrawler ()->filterXPath ('self::* ' ));
480
+ }
481
+
414
482
/**
415
483
* @covers Symfony\Component\DomCrawler\Crawler::filter
416
484
*/
0 commit comments