HashHandlerTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\HashHandler;
  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 HashHandlerTest extends AbstractHandlerTest
  16. {
  17. public function getHandleValueTestData()
  18. {
  19. return [
  20. ['#id', new Token(Token::TYPE_HASH, 'id', 0), ''],
  21. ['#123', new Token(Token::TYPE_HASH, '123', 0), ''],
  22. ['#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'],
  23. ['#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'],
  24. ];
  25. }
  26. public function getDontHandleValueTestData()
  27. {
  28. return [
  29. ['id'],
  30. ['123'],
  31. ['<'],
  32. ['<'],
  33. ['#'],
  34. ];
  35. }
  36. protected function generateHandler()
  37. {
  38. $patterns = new TokenizerPatterns();
  39. return new HashHandler($patterns, new TokenizerEscaping($patterns));
  40. }
  41. }