namespace Symfony\Component\CssSelector\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\CssSelector\CssSelectorConverter;
use Symfony\Component\CssSelector\Exception\ParseException;
class CssSelectorConverterTest extends TestCase
{ public function testCssToXPath() { $converter =
new CssSelectorConverter();
$this->
assertEquals('descendant-or-self::*',
$converter->
toXPath(''
));
$this->
assertEquals('descendant-or-self::h1',
$converter->
toXPath('h1'
));
$this->
assertEquals("descendant-or-self::h1[@id = 'foo']",
$converter->
toXPath('h1#foo'
));
$this->
assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]",
$converter->
toXPath('h1.foo'
));
$this->
assertEquals('descendant-or-self::foo:h1',
$converter->
toXPath('foo|h1'
));
$this->
assertEquals('descendant-or-self::h1',
$converter->
toXPath('H1'
));
// Test the cache layer
$converter =
new CssSelectorConverter();
$this->
assertEquals('descendant-or-self::h1',
$converter->
toXPath('H1'
));
}