8000 [CssSelector] Fixed Issue for XPathExprOr: missing prefix in string c… · scp/symfony@63e2a99 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63e2a99

Browse files
committed
[CssSelector] Fixed Issue for XPathExprOr: missing prefix in string conversion
1 parent 86d0ddb commit 63e2a99

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/CssSelector/XPathExprOr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($items, $prefix = null)
4242
*/
4343
public function __toString()
4444
{
45-
$prefix = $this->prefix;
45+
$prefix = $this->getPrefix();
4646

4747
$tmp = array();
4848
foreach ($this->items as $i) {

tests/Symfony/Tests/Component/CssSelector/Node/OrNodeTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@ public function testToXpath()
2626

2727
$this->assertEquals("h1 | h2 | h3", (string) $or->toXpath(), '->toXpath() returns the xpath representation of the node');
2828
}
29+
30+
public function testIssueMissingPrefix()
31+
{
32+
// h1, h2, h3
33+
$element1 = new ElementNode('*', 'h1');
34+
$element2 = new ElementNode('*', 'h2');
35+
$element3 = new ElementNode('*', 'h3');
36+
$or = new OrNode(array($element1, $element2, $element3));
37+
38+
$xPath = $or->toXPath();
39+
$xPath->addPrefix('descendant-or-self::');
40+
41+
$this->assertEquals("descendant-or-self::h1 | descendant-or-self::h2 | descendant-or-self::h3", (string) $xPath);
42+
}
2943
}

0 commit comments

Comments
 (0)
0