No Description

ElementParserTest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\ElementParser;
  14. /**
  15. * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
  16. */
  17. class ElementParserTest extends TestCase
  18. {
  19. /** @dataProvider getParseTestData */
  20. public function testParse($source, $representation)
  21. {
  22. $parser = new ElementParser();
  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('*', 'Element[*]'),
  33. array('testel', 'Element[testel]'),
  34. array('testns|*', 'Element[testns|*]'),
  35. array('testns|testel', 'Element[testns|testel]'),
  36. );
  37. }
  38. }