ElementParserTest.php 1.2 KB

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