4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_TokenStreamTest
extends PHPUnit_Framework_TestCase
14 protected static $tokens;
16 public function setUp()
18 self
::$tokens = array(
19 new Twig_Token(Twig_Token
::TEXT_TYPE
, 1, 1),
20 new Twig_Token(Twig_Token
::TEXT_TYPE
, 2, 1),
21 new Twig_Token(Twig_Token
::TEXT_TYPE
, 3, 1),
22 new Twig_Token(Twig_Token
::TEXT_TYPE
, 4, 1),
23 new Twig_Token(Twig_Token
::TEXT_TYPE
, 5, 1),
24 new Twig_Token(Twig_Token
::TEXT_TYPE
, 6, 1),
25 new Twig_Token(Twig_Token
::TEXT_TYPE
, 7, 1),
26 new Twig_Token(Twig_Token
::EOF_TYPE
, 0, 1),
30 public function testNext()
32 $stream = new Twig_TokenStream(self
::$tokens);
34 while (!$stream->isEOF()) {
35 $token = $stream->next();
37 $repr[] = $token->getValue();
39 $this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token');
43 * @expectedException Twig_Error_Syntax
44 * @expectedMessage Unexpected end of template
46 public function testEndOfTemplateNext()
48 $stream = new Twig_TokenStream(array(
49 new Twig_Token(Twig_Token
::BLOCK_START_TYPE
, 1, 1),
51 while (!$stream->isEOF()) {
57 * @expectedException Twig_Error_Syntax
58 * @expectedMessage Unexpected end of template
60 public function testEndOfTemplateLook()
62 $stream = new Twig_TokenStream(array(
63 new Twig_Token(Twig_Token
::BLOCK_START_TYPE
, 1, 1),
65 while (!$stream->isEOF()) {