From e5b8abb56404ebf776367b88d7d430572444cbf3 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 10 Jan 2013 09:49:01 +0000 Subject: [PATCH 1/9] [DomCrawler] Added auto-discovery of namespaces in Crawler::filter() and Crawler::filterByXPath(). Improved content type guessing. --- src/Symfony/Component/DomCrawler/Crawler.php | 11 +++- .../DomCrawler/Tests/CrawlerTest.php | 51 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 412e717e59..826b74e7e3 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -92,7 +92,7 @@ class Crawler extends \SplObjectStorage public function addContent($content, $type = null) { if (empty($type)) { - $type = 'text/html'; + $type = 0 === strpos($content, '[a-zA-Z_][a-zA-Z_0-9\-\.]+):[^:]/', $xpath, $matches)) { + foreach ($matches['prefix'] as $prefix) { + // ask for one namespace, otherwise we'd get a collection with an item for each node + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $prefix)); + foreach ($namespaces as $node) { + $domxpath->registerNamespace($node->prefix, $node->nodeValue); + } + } + } return new static($domxpath->query($xpath), $this->uri); } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index f05d81e681..3e7f835eec 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -370,11 +370,31 @@ EOF $this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression'); } + public function testFilterXPathWithDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//entry/id'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + } + + public function testFilterXPathWithNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//yt:accessControl'); + $this->assertCount(2, $crawler, '->filterXPath() automatically registers a namespace'); + } + + public function testFilterXPathWithMultipleNamespaces() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces'); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::filter */ public function testFilter() { + $this->markSkippedIfCssSelectorNotPresent(); + $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler'); @@ -384,6 +404,14 @@ EOF $this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector'); } + public function testFilterWithNamespace() + { + $this->markSkippedIfCssSelectorNotPresent(); + + $crawler = $this->createTestXmlCrawler()->filter('yt|accessControl'); + $this->assertCount(2, $crawler, '->filter() automatically registers namespaces'); + } + public function testSelectLink() { $crawler = $this->createTestCrawler(); @@ -656,6 +684,22 @@ EOF return new Crawler($dom, $uri); } + protected function createTestXmlCrawler($uri = null) + { + $xml = ' + + tag:youtube.com,2008:video:kgZRZmEc9j4 + + + + Chordates - CrashCourse Biology #24 + widescreen + + '; + + return new Crawler($xml, $uri); + } + protected function createDomDocument() { $dom = new \DOMDocument(); @@ -672,4 +716,11 @@ EOF return $domxpath->query('//div'); } + + protected function markSkippedIfCssSelectorNotPresent() + { + if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { + $this->markTestSkipped('The "CssSelector" component is not available'); + } + } } From 6e717a30927e6da27650d1c57df552bc1c6925fc Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 25 Apr 2013 16:20:17 +0100 Subject: [PATCH 2/9] [DomCrawler] Made sure only the default namespace is removed when loading an XML content. --- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 826b74e7e3..864340dbda 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -197,7 +197,7 @@ class Crawler extends \SplObjectStorage $dom->validateOnParse = true; // remove the default namespace to make XPath expressions simpler - @$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET); + @$dom->loadXML(str_replace('xmlns=', 'ns=', $content), LIBXML_NONET); libxml_use_internal_errors($current); libxml_disable_entity_loader($disableEntities); From c905bba6a0763eaf7d418426660c5798e80bca3b Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Fri, 13 Sep 2013 12:03:00 +0100 Subject: [PATCH 3/9] [DomCrawler] Added more tests for namespaced filtering. --- .../DomCrawler/Tests/CrawlerTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 3e7f835eec..0b20e732fe 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DomCrawler\Tests; +use Symfony\Component\CssSelector\CssSelector; use Symfony\Component\DomCrawler\Crawler; class CrawlerTest extends \PHPUnit_Framework_TestCase @@ -374,6 +375,7 @@ EOF { $crawler = $this->createTestXmlCrawler()->filterXPath('//entry/id'); $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); } public function testFilterXPathWithNamespace() @@ -386,6 +388,7 @@ EOF { $crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio'); $this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces'); + $this->assertSame('widescreen', $crawler->text()); } /** @@ -404,14 +407,36 @@ EOF $this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector'); } + public function testFilterWithDefaultNamespace() + { + $this->markSkippedIfCssSelectorNotPresent(); + + $crawler = $this->createTestXmlCrawler()->filter('entry id'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + public function testFilterWithNamespace() { $this->markSkippedIfCssSelectorNotPresent(); + CssSelector::disableHtmlExtension(); + $crawler = $this->createTestXmlCrawler()->filter('yt|accessControl'); $this->assertCount(2, $crawler, '->filter() automatically registers namespaces'); } + public function testFilterWithMultipleNamespaces() + { + $this->markSkippedIfCssSelectorNotPresent(); + + CssSelector::disableHtmlExtension(); + + $crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('widescreen', $crawler->text()); + } + public function testSelectLink() { $crawler = $this->createTestCrawler(); From 587e2dd44f3253496c563d29361113756862ee49 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 17 Sep 2013 17:57:11 +0100 Subject: [PATCH 4/9] [DomCrawler] Made that default namespace is no longer removed when loading documents with addXmlContent(). --- src/Symfony/Component/DomCrawler/Crawler.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 864340dbda..275637a79d 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -195,9 +195,7 @@ class Crawler extends \SplObjectStorage $dom = new \DOMDocument('1.0', $charset); $dom->validateOnParse = true; - - // remove the default namespace to make XPath expressions simpler - @$dom->loadXML(str_replace('xmlns=', 'ns=', $content), LIBXML_NONET); + @$dom->loadXML($content, LIBXML_NONET); libxml_use_internal_errors($current); libxml_disable_entity_loader($disableEntities); From c6fbb13938e193ad33a28442f028205a7c409bd1 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 17 Sep 2013 18:15:30 +0100 Subject: [PATCH 5/9] [DomCrawler] Added support for an automatic default namespace registration. --- src/Symfony/Component/DomCrawler/Crawler.php | 51 +++++++++++++++---- .../DomCrawler/Tests/CrawlerTest.php | 13 ++++- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 275637a79d..6e63d8ea25 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -577,16 +577,8 @@ class Crawler extends \SplObjectStorage $root->appendChild($document->importNode($node, true)); } - $domxpath = new \DOMXPath($document); - if (preg_match_all('/(?P[a-zA-Z_][a-zA-Z_0-9\-\.]+):[^:]/', $xpath, $matches)) { - foreach ($matches['prefix'] as $prefix) { - // ask for one namespace, otherwise we'd get a collection with an item for each node - $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $prefix)); - foreach ($namespaces as $node) { - $domxpath->registerNamespace($node->prefix, $node->nodeValue); - } - } - } + $prefixes = $this->findNamespacePrefixes($xpath); + $domxpath = $this->createDOMXPath($document, $prefixes); return new static($domxpath->query($xpath), $this->uri); } @@ -799,4 +791,43 @@ class Crawler extends \SplObjectStorage return $nodes; } + + /** + * @param \DOMDocument $document + * @param array $prefixes + * + * @return \DOMXPath + * + * @throws \InvalidArgumentException + */ + private function createDOMXPath(\DOMDocument $document, array $prefixes = array()) + { + $domxpath = new \DOMXPath($document); + + foreach ($prefixes as $prefix) { + // ask for one namespace, otherwise we'd get a collection with an item for each node + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', 'default' === $prefix ? '' : $prefix)); + if ($node = $namespaces->item(0)) { + $domxpath->registerNamespace($prefix, $node->nodeValue); + } else { + throw new \InvalidArgumentException(sprintf('Could not find a namespace for the prefix: "%s"', $prefix)); + } + } + + return $domxpath; + } + + /** + * @param $xpath + * + * @return array + */ + private function findNamespacePrefixes($xpath) + { + if (preg_match_all('/(?P[a-zA-Z_][a-zA-Z_0-9\-\.]+):[^:]/', $xpath, $matches)) { + return array_unique($matches['prefix']); + } + + return array(); + } } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 0b20e732fe..cca6165fc2 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -373,7 +373,7 @@ EOF public function testFilterXPathWithDefaultNamespace() { - $crawler = $this->createTestXmlCrawler()->filterXPath('//entry/id'); + $crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id'); $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); } @@ -391,6 +391,15 @@ EOF $this->assertSame('widescreen', $crawler->text()); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Could not find a namespace for the prefix: "foo" + */ + public function testFilterXPathWithAnInvalidNamespace() + { + $this->createTestXmlCrawler()->filterXPath('//media:group/foo:aspectRatio'); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::filter */ @@ -411,7 +420,7 @@ EOF { $this->markSkippedIfCssSelectorNotPresent(); - $crawler = $this->createTestXmlCrawler()->filter('entry id'); + $crawler = $this->createTestXmlCrawler()->filter('default|entry default|id'); $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); } From 943d446e6126bb4a055f8eaa4410124e8ccf80e5 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 17 Sep 2013 18:24:50 +0100 Subject: [PATCH 6/9] [DomCrawler] Updated the CHANGELOG with namespace auto-registration details. --- src/Symfony/Component/DomCrawler/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Symfony/Component/DomCrawler/CHANGELOG.md b/src/Symfony/Component/DomCrawler/CHANGELOG.md index 2343a51b4f..06ed6c000b 100644 --- a/src/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/src/Symfony/Component/DomCrawler/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +2.4.0 +----- + + * added auto-registration of document namespaces for `Crawler::filterXPath()` and `Crawler::filter()` + * improved content type guessing in `Crawler::addContent()` + * [BC BREAK] `Crawler::addXmlContent()` no longer removes the default document namespace + 2.3.0 ----- From be1e4e6585641c53733e534ceab65cad0b3351fd Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 18 Sep 2013 13:18:44 +0100 Subject: [PATCH 7/9] [DomCrawler] Enabled default namespace prefix overloading. --- src/Symfony/Component/DomCrawler/Crawler.php | 19 +++++++++++++++++-- .../DomCrawler/Tests/CrawlerTest.php | 10 ++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 6e63d8ea25..790d86a75a 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -27,6 +27,11 @@ class Crawler extends \SplObjectStorage */ protected $uri; + /** + * @var string The default namespace prefix to be used with XPath and CSS expressions + */ + private $defaultNamespacePrefix = 'default'; + /** * Constructor. * @@ -708,6 +713,16 @@ class Crawler extends \SplObjectStorage return $form; } + /** + * Overloads a default namespace prefix to be used with XPath and CSS expressions. + * + * @param string $prefix + */ + public function setDefaultNamespacePrefix($prefix) + { + $this->defaultNamespacePrefix = $prefix; + } + /** * Converts string for XPath expressions. * @@ -806,7 +821,7 @@ class Crawler extends \SplObjectStorage foreach ($prefixes as $prefix) { // ask for one namespace, otherwise we'd get a collection with an item for each node - $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', 'default' === $prefix ? '' : $prefix)); + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix)); if ($node = $namespaces->item(0)) { $domxpath->registerNamespace($prefix, $node->nodeValue); } else { @@ -824,7 +839,7 @@ class Crawler extends \SplObjectStorage */ private function findNamespacePrefixes($xpath) { - if (preg_match_all('/(?P[a-zA-Z_][a-zA-Z_0-9\-\.]+):[^:]/', $xpath, $matches)) { + if (preg_match_all('/(?P[a-zA-Z_][a-zA-Z_0-9\-\.]*):[^:]/', $xpath, $matches)) { return array_unique($matches['prefix']); } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index cca6165fc2..54760b7bed 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -378,6 +378,16 @@ EOF $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); } + public function testFilterXPathWithCustomDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->setDefaultNamespacePrefix('x'); + $crawler = $crawler->filterXPath('//x:entry/x:id'); + + $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + public function testFilterXPathWithNamespace() { $crawler = $this->createTestXmlCrawler()->filterXPath('//yt:accessControl'); From 9110468e9982f825cd5a3941f31f6028effcd5ec Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Sun, 22 Sep 2013 23:29:38 +0100 Subject: [PATCH 8/9] [DomCrawler] Enabled manual namespace registration. --- src/Symfony/Component/DomCrawler/CHANGELOG.md | 6 ++- src/Symfony/Component/DomCrawler/Crawler.php | 47 ++++++++++++++++--- .../DomCrawler/Tests/CrawlerTest.php | 12 ++++- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/CHANGELOG.md b/src/Symfony/Component/DomCrawler/CHANGELOG.md index 06ed6c000b..66ce6542c4 100644 --- a/src/Symfony/Component/DomCrawler/CHANGELOG.md +++ b/src/Symfony/Component/DomCrawler/CHANGELOG.md @@ -4,9 +4,11 @@ CHANGELOG 2.4.0 ----- - * added auto-registration of document namespaces for `Crawler::filterXPath()` and `Crawler::filter()` + * added support for automatic discovery and explicit registration of document + namespaces for `Crawler::filterXPath()` and `Crawler::filter()` * improved content type guessing in `Crawler::addContent()` - * [BC BREAK] `Crawler::addXmlContent()` no longer removes the default document namespace + * [BC BREAK] `Crawler::addXmlContent()` no longer removes the default document + namespace 2.3.0 ----- diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 790d86a75a..2935a51f53 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -32,6 +32,11 @@ class Crawler extends \SplObjectStorage */ private $defaultNamespacePrefix = 'default'; + /** + * @var array A map of manually registered namespaces + */ + private $namespaces = array(); + /** * Constructor. * @@ -723,6 +728,15 @@ class Crawler extends \SplObjectStorage $this->defaultNamespacePrefix = $prefix; } + /** + * @param string $prefix + * @param string $namespace + */ + public function registerNamespace($prefix, $namespace) + { + $this->namespaces[$prefix] = $namespace; + } + /** * Converts string for XPath expressions. * @@ -820,18 +834,37 @@ class Crawler extends \SplObjectStorage $domxpath = new \DOMXPath($document); foreach ($prefixes as $prefix) { - // ask for one namespace, otherwise we'd get a collection with an item for each node - $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix)); - if ($node = $namespaces->item(0)) { - $domxpath->registerNamespace($prefix, $node->nodeValue); - } else { - throw new \InvalidArgumentException(sprintf('Could not find a namespace for the prefix: "%s"', $prefix)); - } + $namespace = $this->discoverNamespace($domxpath, $prefix); + $domxpath->registerNamespace($prefix, $namespace); } return $domxpath; } + /** + * @param \DOMXPath $domxpath + * @param string $prefix + * + * @return string + * + * @throws \InvalidArgumentException + */ + private function discoverNamespace(\DOMXPath $domxpath, $prefix) + { + if (isset($this->namespaces[$prefix])) { + return $this->namespaces[$prefix]; + } + + // ask for one namespace, otherwise we'd get a collection with an item for each node + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix)); + + if ($node = $namespaces->item(0)) { + return $node->nodeValue; + } + + throw new \InvalidArgumentException(sprintf('Could not find a namespace for the prefix: "%s"', $prefix)); + } + /** * @param $xpath * diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 54760b7bed..9995b8ffe4 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -384,7 +384,7 @@ EOF $crawler->setDefaultNamespacePrefix('x'); $crawler = $crawler->filterXPath('//x:entry/x:id'); - $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + $this->assertCount(1, $crawler, '->filterXPath() lets to override the default namespace prefix'); $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); } @@ -410,6 +410,16 @@ EOF $this->createTestXmlCrawler()->filterXPath('//media:group/foo:aspectRatio'); } + public function testFilterXPathWithManuallyRegisteredNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/'); + + $crawler = $crawler->filterXPath('//m:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() uses manually registered namespace'); + $this->assertSame('widescreen', $crawler->text()); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::filter */ From 77e2fa5c989f7f33109f68654c9ade5cc0187f8a Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 24 Sep 2013 21:21:41 +0100 Subject: [PATCH 9/9] [DomCrawler] Removed checks if CssSelector is present. --- .../Component/DomCrawler/Tests/CrawlerTest.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 9995b8ffe4..5c27451f6f 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -425,8 +425,6 @@ EOF */ public function testFilter() { - $this->markSkippedIfCssSelectorNotPresent(); - $crawler = $this->createTestCrawler(); $this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler'); @@ -438,8 +436,6 @@ EOF public function testFilterWithDefaultNamespace() { - $this->markSkippedIfCssSelectorNotPresent(); - $crawler = $this->createTestXmlCrawler()->filter('default|entry default|id'); $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); @@ -447,8 +443,6 @@ EOF public function testFilterWithNamespace() { - $this->markSkippedIfCssSelectorNotPresent(); - CssSelector::disableHtmlExtension(); $crawler = $this->createTestXmlCrawler()->filter('yt|accessControl'); @@ -457,8 +451,6 @@ EOF public function testFilterWithMultipleNamespaces() { - $this->markSkippedIfCssSelectorNotPresent(); - CssSelector::disableHtmlExtension(); $crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio'); @@ -770,11 +762,4 @@ EOF return $domxpath->query('//div'); } - - protected function markSkippedIfCssSelectorNotPresent() - { - if (!class_exists('Symfony\Component\CssSelector\CssSelector')) { - $this->markTestSkipped('The "CssSelector" component is not available'); - } - } }