2010-03-31 07:42:18 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2010-04-25 16:06:54 +01:00
|
|
|
* This file is part of the Symfony package.
|
2010-03-31 07:42:18 +01:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-03-31 07:42:18 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\CssSelector\Node;
|
2010-03-31 07:42:18 +01:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\CssSelector\Node\OrNode;
|
|
|
|
use Symfony\Component\CssSelector\Node\ElementNode;
|
2010-03-31 07:42:18 +01:00
|
|
|
|
|
|
|
class OrNodeTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-05-06 12:25:53 +01:00
|
|
|
public function testToXpath()
|
|
|
|
{
|
|
|
|
// h1, h2, h3
|
|
|
|
$element1 = new ElementNode('*', 'h1');
|
|
|
|
$element2 = new ElementNode('*', 'h2');
|
|
|
|
$element3 = new ElementNode('*', 'h3');
|
|
|
|
$or = new OrNode(array($element1, $element2, $element3));
|
2010-03-31 07:42:18 +01:00
|
|
|
|
2010-05-06 12:25:53 +01:00
|
|
|
$this->assertEquals("h1 | h2 | h3", (string) $or->toXpath(), '->toXpath() returns the xpath representation of the node');
|
|
|
|
}
|
2011-12-13 07:50:54 +00:00
|
|
|
|
2011-11-28 21:00:26 +00:00
|
|
|
public function testIssueMissingPrefix()
|
|
|
|
{
|
|
|
|
// h1, h2, h3
|
|
|
|
$element1 = new ElementNode('*', 'h1');
|
|
|
|
$element2 = new ElementNode('*', 'h2');
|
|
|
|
$element3 = new ElementNode('*', 'h3');
|
|
|
|
$or = new OrNode(array($element1, $element2, $element3));
|
2011-12-13 07:50:54 +00:00
|
|
|
|
2011-11-28 21:00:26 +00:00
|
|
|
$xPath = $or->toXPath();
|
|
|
|
$xPath->addPrefix('descendant-or-self::');
|
|
|
|
|
|
|
|
$this->assertEquals("descendant-or-self::h1 | descendant-or-self::h2 | descendant-or-self::h3", (string) $xPath);
|
|
|
|
}
|
2010-03-31 07:42:18 +01:00
|
|
|
}
|