TokenStreamTest.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. class Twig_Tests_TokenStreamTest extends PHPUnit_Framework_TestCase
  11. {
  12. static protected $tokens;
  13. public function setUp()
  14. {
  15. self::$tokens = array(
  16. new Twig_Token(Twig_Token::TEXT_TYPE, 1, 0),
  17. new Twig_Token(Twig_Token::TEXT_TYPE, 2, 0),
  18. new Twig_Token(Twig_Token::TEXT_TYPE, 3, 0),
  19. new Twig_Token(Twig_Token::TEXT_TYPE, 4, 0),
  20. new Twig_Token(Twig_Token::TEXT_TYPE, 5, 0),
  21. new Twig_Token(Twig_Token::TEXT_TYPE, 6, 0),
  22. new Twig_Token(Twig_Token::TEXT_TYPE, 7, 0),
  23. new Twig_Token(Twig_Token::EOF_TYPE, 0, 0),
  24. );
  25. }
  26. public function testNext()
  27. {
  28. $stream = new Twig_TokenStream(self::$tokens);
  29. $repr = array();
  30. while (!$stream->isEOF()) {
  31. $token = $stream->next();
  32. $repr[] = $token->getValue();
  33. }
  34. $this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token');
  35. }
  36. }