From d34383f10b92eb5a429a0c30fd99ba552ac5cd05 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 12 May 2012 20:35:16 +0200 Subject: [PATCH] [CssSelector] removed an unneeded condition (taken care of afterward in the code) (closes #4269) --- src/Symfony/Component/CssSelector/Node/FunctionNode.php | 5 ----- .../Tests/Component/CssSelector/Node/FunctionNodeTest.php | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index be1b1998a7..8293264fee 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -250,11 +250,6 @@ class FunctionNode implements NodeInterface return array(0, 0); } - if (is_string($s)) { - // Happens when you just get a number - return array(0, $s); - } - if ('odd' == $s) { return array(2, 1); } diff --git a/tests/Symfony/Tests/Component/CssSelector/Node/FunctionNodeTest.php b/tests/Symfony/Tests/Component/CssSelector/Node/FunctionNodeTest.php index 339f90adad..cbb148d7b6 100644 --- a/tests/Symfony/Tests/Component/CssSelector/Node/FunctionNodeTest.php +++ b/tests/Symfony/Tests/Component/CssSelector/Node/FunctionNodeTest.php @@ -58,6 +58,11 @@ class FunctionNodeTest extends \PHPUnit_Framework_TestCase $function = new FunctionNode($element, ':', 'nth-child', $element2); $this->assertEquals("*/*[name() = 'h1' and (position() >= 1)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + // h1:nth-child(1) + $element2 = new ElementNode('*', new Token('Symbol', '2', -1)); + $function = new FunctionNode($element, ':', 'nth-child', $element2); + $this->assertEquals("*/*[name() = 'h1' and (position() = 2)]", (string) $function->toXpath(), '->toXpath() returns the xpath representation of the node'); + // h1:nth-child(2n) $element2 = new ElementNode('*', new Token('Symbol', '2n', -1)); $function = new FunctionNode($element, ':', 'nth-child', $element2);