CommentHandlerTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 array(
  30. // 2nd argument only exists for inherited method compatibility
  31. array('/* comment */', new Token(null, null, null), ''),
  32. array('/* comment */foo', new Token(null, null, null), 'foo'),
  33. );
  34. }
  35. public function getDontHandleValueTestData()
  36. {
  37. return array(
  38. array('>'),
  39. array('+'),
  40. array(' '),
  41. );
  42. }
  43. protected function generateHandler()
  44. {
  45. return new CommentHandler();
  46. }
  47. }