XPathExprTest.php 965 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\CssSelector;
  11. use Symfony\Component\CssSelector\XPathExpr;
  12. class XPathExprTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @dataProvider getXPathLiteralValues
  16. */
  17. public function testXpathLiteral($value, $literal)
  18. {
  19. $this->assertEquals($literal, XPathExpr::xpathLiteral($value));
  20. }
  21. public function getXPathLiteralValues()
  22. {
  23. return array(
  24. array('foo', "'foo'"),
  25. array("foo's bar", '"foo\'s bar"'),
  26. array("foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'),
  27. array("foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'),
  28. );
  29. }
  30. }