菜谱项目

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