No Description

HashParserTest.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Component\CssSelector\Tests\Parser\Shortcut;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\CssSelector\Node\SelectorNode;
  13. use Symfony\Component\CssSelector\Parser\Shortcut\HashParser;
  14. /**
  15. * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
  16. */
  17. class HashParserTest extends TestCase
  18. {
  19. /** @dataProvider getParseTestData */
  20. public function testParse($source, $representation)
  21. {
  22. $parser = new HashParser();
  23. $selectors = $parser->parse($source);
  24. $this->assertCount(1, $selectors);
  25. /** @var SelectorNode $selector */
  26. $selector = $selectors[0];
  27. $this->assertEquals($representation, (string) $selector->getTree());
  28. }
  29. public function getParseTestData()
  30. {
  31. return array(
  32. array('#testid', 'Hash[Element[*]#testid]'),
  33. array('testel#testid', 'Hash[Element[testel]#testid]'),
  34. array('testns|#testid', 'Hash[Element[testns|*]#testid]'),
  35. array('testns|*#testid', 'Hash[Element[testns|*]#testid]'),
  36. array('testns|testel#testid', 'Hash[Element[testns|testel]#testid]'),
  37. );
  38. }
  39. }