Skip to content

Commit c905bba

Browse files
committed
[DomCrawler] Added more tests for namespaced filtering.
1 parent 6e717a3 commit c905bba

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DomCrawler\Tests;
1313

14+
use Symfony\Component\CssSelector\CssSelector;
1415
use Symfony\Component\DomCrawler\Crawler;
1516

1617
class CrawlerTest extends \PHPUnit_Framework_TestCase
@@ -374,6 +375,7 @@ public function testFilterXPathWithDefaultNamespace()
374375
{
375376
$crawler = $this->createTestXmlCrawler()->filterXPath('//entry/id');
376377
$this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace');
378+
$this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text());
377379
}
378380

379381
public function testFilterXPathWithNamespace()
@@ -386,6 +388,7 @@ public function testFilterXPathWithMultipleNamespaces()
386388
{
387389
$crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio');
388390
$this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces');
391+
$this->assertSame('widescreen', $crawler->text());
389392
}
390393

391394
/**
@@ -404,14 +407,36 @@ public function testFilter()
404407
$this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector');
405408
}
406409

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+
407419
public function testFilterWithNamespace()
408420
{
409421
$this->markSkippedIfCssSelectorNotPresent();
410422

423+
CssSelector::disableHtmlExtension();
424+
411425
$crawler = $this->createTestXmlCrawler()->filter('yt|accessControl');
412426
$this->assertCount(2, $crawler, '->filter() automatically registers namespaces');
413427
}
414428

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+
415440
public function testSelectLink()
416441
{
417442
$crawler = $this->createTestCrawler();

0 commit comments

Comments
 (0)