IdentifierHandlerTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Handler;
  11. use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler;
  12. use Symfony\Component\CssSelector\Parser\Token;
  13. use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
  14. use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
  15. class IdentifierHandlerTest extends AbstractHandlerTest
  16. {
  17. public function getHandleValueTestData()
  18. {
  19. return [
  20. ['foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''],
  21. ['foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'],
  22. ['foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'],
  23. ['foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'],
  24. ['foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'],
  25. ];
  26. }
  27. public function getDontHandleValueTestData()
  28. {
  29. return [
  30. ['>'],
  31. ['+'],
  32. [' '],
  33. ['*|foo'],
  34. ['/* comment */'],
  35. ];
  36. }
  37. protected function generateHandler()
  38. {
  39. $patterns = new TokenizerPatterns();
  40. return new IdentifierHandler($patterns, new TokenizerEscaping($patterns));
  41. }
  42. }