11
11
12
12
namespace Symfony \Component \DomCrawler \Tests ;
13
13
14
+ use Symfony \Component \CssSelector \CssSelector ;
14
15
use Symfony \Component \DomCrawler \Crawler ;
15
16
16
17
class CrawlerTest extends \PHPUnit_Framework_TestCase
@@ -374,6 +375,7 @@ public function testFilterXPathWithDefaultNamespace()
374
375
{
375
376
$ crawler = $ this ->createTestXmlCrawler ()->filterXPath ('//entry/id ' );
376
377
$ this ->assertCount (1 , $ crawler , '->filterXPath() automatically registers a namespace ' );
378
+ $ this ->assertSame ('tag:youtube.com,2008:video:kgZRZmEc9j4 ' , $ crawler ->text ());
377
379
}
378
380
379
381
public function testFilterXPathWithNamespace ()
@@ -386,6 +388,7 @@ public function testFilterXPathWithMultipleNamespaces()
386
388
{
387
389
$ crawler = $ this ->createTestXmlCrawler ()->filterXPath ('//media:group/yt:aspectRatio ' );
388
390
$ this ->assertCount (1 , $ crawler , '->filterXPath() automatically registers multiple namespaces ' );
391
+ $ this ->assertSame ('widescreen ' , $ crawler ->text ());
389
392
}
390
393
391
394
/**
@@ -404,14 +407,36 @@ public function testFilter()
404
407
$ this ->assertCount (6 , $ crawler ->filter ('li ' ), '->filter() filters the node list with the CSS selector ' );
405
408
}
406
409
410
+ public function testFilterWithDefaultNamespace ()
411
+ {
412
+ $ this ->markSkippedIfCssSelectorNotPresent ();
413
+
414
+ $ crawler = $ this ->createTestXmlCrawler ()->filter ('entry id ' );
415
+ $ this ->assertCount (1 , $ crawler , '->filter() automatically registers namespaces ' );
416
+ $ this ->assertSame ('tag:youtube.com,2008:video:kgZRZmEc9j4 ' , $ crawler ->text ());
417
+ }
418
+
407
419
public function testFilterWithNamespace ()
408
420
{
409
421
$ this ->markSkippedIfCssSelectorNotPresent ();
410
422
423
+ CssSelector::disableHtmlExtension ();
424
+
411
425
$ crawler = $ this ->createTestXmlCrawler ()->filter ('yt|accessControl ' );
412
426
$ this ->assertCount (2 , $ crawler , '->filter() automatically registers namespaces ' );
413
427
}
414
428
429
+ public function testFilterWithMultipleNamespaces ()
430
+ {
431
+ $ this ->markSkippedIfCssSelectorNotPresent ();
432
+
433
+ CssSelector::disableHtmlExtension ();
434
+
435
+ $ crawler = $ this ->createTestXmlCrawler ()->filter ('media|group yt|aspectRatio ' );
436
+ $ this ->assertCount (1 , $ crawler , '->filter() automatically registers namespaces ' );
437
+ $ this ->assertSame ('widescreen ' , $ crawler ->text ());
438
+ }
439
+
415
440
public function testSelectLink ()
416
441
{
417
442
$ crawler = $ this ->createTestCrawler ();
0 commit comments