StringHandlerTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\StringHandler;
  12. use Symfony\Component\CssSelector\Parser\Token;
  13. use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
  14. use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
  15. class StringHandlerTest extends AbstractHandlerTest
  16. {
  17. public function getHandleValueTestData()
  18. {
  19. return array(
  20. array('"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''),
  21. array('"1"', new Token(Token::TYPE_STRING, '1', 1), ''),
  22. array('" "', new Token(Token::TYPE_STRING, ' ', 1), ''),
  23. array('""', new Token(Token::TYPE_STRING, '', 1), ''),
  24. array("'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''),
  25. array("'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'),
  26. );
  27. }
  28. public function getDontHandleValueTestData()
  29. {
  30. return array(
  31. array('hello'),
  32. array('>'),
  33. array('1'),
  34. array(' '),
  35. );
  36. }
  37. protected function generateHandler()
  38. {
  39. $patterns = new TokenizerPatterns();
  40. return new StringHandler($patterns, new TokenizerEscaping($patterns));
  41. }
  42. }