CommentHandlerTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\CommentHandler;
  12. use Symfony\Component\CssSelector\Parser\Reader;
  13. use Symfony\Component\CssSelector\Parser\Token;
  14. use Symfony\Component\CssSelector\Parser\TokenStream;
  15. class CommentHandlerTest extends AbstractHandlerTest
  16. {
  17. /** @dataProvider getHandleValueTestData */
  18. public function testHandleValue($value, Token $unusedArgument, $remainingContent)
  19. {
  20. $reader = new Reader($value);
  21. $stream = new TokenStream();
  22. $this->assertTrue($this->generateHandler()->handle($reader, $stream));
  23. // comments are ignored (not pushed as token in stream)
  24. $this->assertStreamEmpty($stream);
  25. $this->assertRemainingContent($reader, $remainingContent);
  26. }
  27. public function getHandleValueTestData()
  28. {
  29. return [
  30. // 2nd argument only exists for inherited method compatibility
  31. ['/* comment */', new Token(null, null, null), ''],
  32. ['/* comment */foo', new Token(null, null, null), 'foo'],
  33. ];
  34. }
  35. public function getDontHandleValueTestData()
  36. {
  37. return [
  38. ['>'],
  39. ['+'],
  40. [' '],
  41. ];
  42. }
  43. protected function generateHandler()
  44. {
  45. return new CommentHandler();
  46. }
  47. }