diff --git a/composer.json b/composer.json index 2dd9f97..4209f8a 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "symfony/validator": "2.6.*", "symfony/process": "2.6.*", "symfony/yaml": "2.6.*", + "symfony/dom-crawler": "2.6.*", "twig/twig": "1.16.*", "doctrine/common": "dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5", "doctrine/annotations": "1.2.*", diff --git a/composer.lock b/composer.lock index 89000cd..3a17792 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "50c7f5cc4610a0c2f5cd986ea846ddbf", + "hash": "4d34ebabb8ae84edecae52b750f21094", "packages": [ { "name": "doctrine/annotations", @@ -1918,24 +1918,24 @@ }, { "name": "symfony/dom-crawler", - "version": "v2.6.1", + "version": "v2.6.3", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "300d449f79d74ac62b06edd05214e8dd2e635840" + "reference": "26a9eb302decd828990e1015afaa11b78b016073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/300d449f79d74ac62b06edd05214e8dd2e635840", - "reference": "300d449f79d74ac62b06edd05214e8dd2e635840", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/26a9eb302decd828990e1015afaa11b78b016073", + "reference": "26a9eb302decd828990e1015afaa11b78b016073", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "symfony/css-selector": "~2.0" + "symfony/css-selector": "~2.3" }, "suggest": { "symfony/css-selector": "" @@ -1967,7 +1967,7 @@ ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "time": "2015-01-03 08:01:59" }, { "name": "symfony/event-dispatcher", diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index b996381..564eeb8 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -2676,61 +2676,6 @@ ] }, { - "name": "symfony/dom-crawler", - "version": "v2.6.1", - "version_normalized": "2.6.1.0", - "target-dir": "Symfony/Component/DomCrawler", - "source": { - "type": "git", - "url": "https://github.com/symfony/DomCrawler.git", - "reference": "300d449f79d74ac62b06edd05214e8dd2e635840" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/300d449f79d74ac62b06edd05214e8dd2e635840", - "reference": "300d449f79d74ac62b06edd05214e8dd2e635840", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/css-selector": "~2.0" - }, - "suggest": { - "symfony/css-selector": "" - }, - "time": "2014-12-02 20:19:20", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\DomCrawler\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "http://symfony.com" - }, - { "name": "phpunit/phpunit-dom-assertions", "version": "dev-master", "version_normalized": "9999999-dev", @@ -2788,5 +2733,60 @@ "phpunit", "tests" ] + }, + { + "name": "symfony/dom-crawler", + "version": "v2.6.3", + "version_normalized": "2.6.3.0", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler.git", + "reference": "26a9eb302decd828990e1015afaa11b78b016073" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/26a9eb302decd828990e1015afaa11b78b016073", + "reference": "26a9eb302decd828990e1015afaa11b78b016073", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "~2.3" + }, + "suggest": { + "symfony/css-selector": "" + }, + "time": "2015-01-03 08:01:59", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com" } ] diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php index 818220b..9471d54 100755 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php @@ -23,7 +23,7 @@ class Crawler extends \SplObjectStorage { /** - * @var string The current URI or the base href value + * @var string The current URI */ protected $uri; @@ -38,16 +38,22 @@ class Crawler extends \SplObjectStorage private $namespaces = array(); /** + * @var string The base href value + */ + private $baseHref; + + /** * Constructor. * * @param mixed $node A Node to use as the base for the crawling - * @param string $uri The current URI or the base href value - * + * @param string $currentUri The current URI + * @param string $baseHref The base href value * @api */ - public function __construct($node = null, $uri = null) + public function __construct($node = null, $currentUri = null, $baseHref = null) { - $this->uri = $uri; + $this->uri = $currentUri; + $this->baseHref = $baseHref ?: $currentUri; $this->add($node); } @@ -186,13 +192,13 @@ public function addHtmlContent($content, $charset = 'UTF-8') $baseHref = current($base); if (count($base) && !empty($baseHref)) { - if ($this->uri) { + if ($this->baseHref) { $linkNode = $dom->createElement('a'); $linkNode->setAttribute('href', $baseHref); - $link = new Link($linkNode, $this->uri); - $this->uri = $link->getUri(); + $link = new Link($linkNode, $this->baseHref); + $this->baseHref = $link->getUri(); } else { - $this->uri = $baseHref; + $this->baseHref = $baseHref; } } } @@ -308,11 +314,11 @@ public function eq($position) { foreach ($this as $i => $node) { if ($i == $position) { - return new static($node, $this->uri); + return new static($node, $this->uri, $this->baseHref); } } - return new static(null, $this->uri); + return new static(null, $this->uri, $this->baseHref); } /** @@ -337,7 +343,7 @@ public function each(\Closure $closure) { $data = array(); foreach ($this as $i => $node) { - $data[] = $closure(new static($node, $this->uri), $i); + $data[] = $closure(new static($node, $this->uri, $this->baseHref), $i); } return $data; @@ -371,16 +377,16 @@ public function reduce(\Closure $closure) { $nodes = array(); foreach ($this as $i => $node) { - if (false !== $closure(new static($node, $this->uri), $i)) { + if (false !== $closure(new static($node, $this->uri, $this->baseHref), $i)) { $nodes[] = $node; } } - return new static($nodes, $this->uri); + return new static($nodes, $this->uri, $this->baseHref); } /** - * Returns the first node of the current selection + * Returns the first node of the current selection. * * @return Crawler A Crawler instance with the first selected node * @@ -392,7 +398,7 @@ public function first() } /** - * Returns the last node of the current selection + * Returns the last node of the current selection. * * @return Crawler A Crawler instance with the last selected node * @@ -404,7 +410,7 @@ public function last() } /** - * Returns the siblings nodes of the current selection + * Returns the siblings nodes of the current selection. * * @return Crawler A Crawler instance with the sibling nodes * @@ -418,11 +424,11 @@ public function siblings() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0)->parentNode->firstChild), $this->uri); + return new static($this->sibling($this->getNode(0)->parentNode->firstChild), $this->uri, $this->baseHref); } /** - * Returns the next siblings nodes of the current selection + * Returns the next siblings nodes of the current selection. * * @return Crawler A Crawler instance with the next sibling nodes * @@ -436,11 +442,11 @@ public function nextAll() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0)), $this->uri); + return new static($this->sibling($this->getNode(0)), $this->uri, $this->baseHref); } /** - * Returns the previous sibling nodes of the current selection + * Returns the previous sibling nodes of the current selection. * * @return Crawler A Crawler instance with the previous sibling nodes * @@ -454,11 +460,11 @@ public function previousAll() throw new \InvalidArgumentException('The current node list is empty.'); } - return new static($this->sibling($this->getNode(0), 'previousSibling'), $this->uri); + return new static($this->sibling($this->getNode(0), 'previousSibling'), $this->uri, $this->baseHref); } /** - * Returns the parents nodes of the current selection + * Returns the parents nodes of the current selection. * * @return Crawler A Crawler instance with the parents nodes of the current selection * @@ -481,11 +487,11 @@ public function parents() } } - return new static($nodes, $this->uri); + return new static($nodes, $this->uri, $this->baseHref); } /** - * Returns the children nodes of the current selection + * Returns the children nodes of the current selection. * * @return Crawler A Crawler instance with the children nodes * @@ -501,7 +507,7 @@ public function children() $node = $this->getNode(0)->firstChild; - return new static($node ? $this->sibling($node) : array(), $this->uri); + return new static($node ? $this->sibling($node) : array(), $this->uri, $this->baseHref); } /** @@ -646,7 +652,7 @@ public function filterXPath($xpath) // If we dropped all expressions in the XPath while preparing it, there would be no match if ('' === $xpath) { - return new static(null, $this->uri); + return new static(null, $this->uri, $this->baseHref); } return $this->filterRelativeXPath($xpath); @@ -730,7 +736,7 @@ public function link($method = 'get') $node = $this->getNode(0); - return new Link($node, $this->uri, $method); + return new Link($node, $this->baseHref, $method); } /** @@ -744,7 +750,7 @@ public function links() { $links = array(); foreach ($this as $node) { - $links[] = new Link($node, $this->uri, 'get'); + $links[] = new Link($node, $this->baseHref, 'get'); } return $links; @@ -856,7 +862,7 @@ private function filterRelativeXPath($xpath) { $prefixes = $this->findNamespacePrefixes($xpath); - $crawler = new static(null, $this->uri); + $crawler = new static(null, $this->uri, $this->baseHref); foreach ($this as $node) { $domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes); diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index c89609c..ae7f4d1 100644 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -55,7 +55,7 @@ public function hasValue() } /** - * Check if the current selected option is disabled + * Check if the current selected option is disabled. * * @return bool */ @@ -257,7 +257,7 @@ protected function initialize() } /** - * Returns option value with associated disabled flag + * Returns option value with associated disabled flag. * * @param \DOMElement $node * @@ -275,7 +275,7 @@ private function buildOptionValue(\DOMElement $node) } /** - * Checks whether given value is in the existing options + * Checks whether given value is in the existing options. * * @param string $optionValue * @param array $options @@ -298,7 +298,7 @@ public function containsOption($optionValue, $options) } /** - * Returns list of available field options + * Returns list of available field options. * * @return array */ diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php index a3eb25e..c3423b2 100644 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -83,7 +83,7 @@ public function setValue($value) } /** - * Sets path to the file as string for simulating HTTP request + * Sets path to the file as string for simulating HTTP request. * * @param string $path The path to the file */ diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php index 964006d..5d70292 100644 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php @@ -100,7 +100,7 @@ public function hasValue() } /** - * Check if the current field is disabled + * Check if the current field is disabled. * * @return bool */ diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE index 0b3292c..43028bc 100644 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2014 Fabien Potencier +Copyright (c) 2004-2015 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php index e4b070c..03149f2 100644 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php @@ -141,7 +141,7 @@ protected function getRawUri() } /** - * Returns the canonicalized URI path (see RFC 3986, section 5.2.4) + * Returns the canonicalized URI path (see RFC 3986, section 5.2.4). * * @param string $path URI path * diff --git a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index fdbb1c7..82045a1 100755 --- a/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/core/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -948,16 +948,42 @@ public function testParents() } } - public function testBaseTag() + /** + * @dataProvider getBaseTagData + */ + public function testBaseTag($baseValue, $linkValue, $expectedUri, $currentUri = null, $description = null) { - $crawler = new Crawler(''); - $this->assertEquals('http://base.com/link', $crawler->filterXPath('//a')->link()->getUri()); + $crawler = new Crawler('', $currentUri); + $this->assertEquals($expectedUri, $crawler->filterXPath('//a')->link()->getUri(), $description); + } - $crawler = new Crawler('', 'https://domain.com'); - $this->assertEquals('https://base.com/link', $crawler->filterXPath('//a')->link()->getUri(), ' tag can use a schema-less URL'); + public function getBaseTagData() + { + return array( + array('http://base.com', 'link', 'http://base.com/link'), + array('//base.com', 'link', 'https://base.com/link', 'https://domain.com', ' tag can use a schema-less URL'), + array('path/', 'link', 'https://domain.com/path/link', 'https://domain.com', ' tag can set a path'), + array('http://base.com', '#', 'http://base.com#', 'http://domain.com/path/link', ' tag does work with links to an anchor'), + array('http://base.com', '', 'http://base.com', 'http://domain.com/path/link', ' tag does work with empty links'), + ); + } - $crawler = new Crawler('', 'https://domain.com'); - $this->assertEquals('https://domain.com/path/link', $crawler->filterXPath('//a')->link()->getUri(), ' tag can set a path'); + /** + * @dataProvider getBaseTagWithFormData + */ + public function testBaseTagWithForm($baseValue, $actionValue, $expectedUri, $currentUri = null, $description = null) + { + $crawler = new Crawler('