ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Tests_ParserTest Class Reference
+ Inheritance diagram for Twig_Tests_ParserTest:
+ Collaboration diagram for Twig_Tests_ParserTest:

Public Member Functions

 testSetMacroThrowsExceptionOnReservedMethods ()
 Twig_Error_Syntax More...
 
 testUnknownTag ()
 Twig_Error_Syntax Unknown "foo" tag. More...
 
 testUnknownTagWithoutSuggestions ()
 Twig_Error_Syntax Unknown "foobar" tag at line 1. More...
 
 testFilterBodyNodes ($input, $expected)
 getFilterBodyNodesData More...
 
 getFilterBodyNodesData ()
 
 testFilterBodyNodesThrowsException ($input)
 getFilterBodyNodesDataThrowsException Twig_Error_Syntax More...
 
 getFilterBodyNodesDataThrowsException ()
 
 testFilterBodyNodesWithBOM ()
 Twig_Error_Syntax A template that extends another one cannot start with a byte order mark (BOM); it must be removed at line 1 More...
 
 testParseIsReentrant ()
 
 testGetVarName ()
 

Protected Member Functions

 getParser ()
 

Detailed Description

Definition at line 11 of file ParserTest.php.

Member Function Documentation

◆ getFilterBodyNodesData()

Twig_Tests_ParserTest::getFilterBodyNodesData ( )

Definition at line 64 of file ParserTest.php.

References array.

65  {
66  return array(
67  array(
68  new Twig_Node(array(new Twig_Node_Text(' ', 1))),
69  new Twig_Node(array()),
70  ),
71  array(
72  $input = new Twig_Node(array(new Twig_Node_Set(false, new Twig_Node(), new Twig_Node(), 1))),
73  $input,
74  ),
75  array(
76  $input = new Twig_Node(array(new Twig_Node_Set(true, new Twig_Node(), new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1))))), 1))),
77  $input,
78  ),
79  );
80  }
Represents a node in the AST.
Definition: Node.php:18
Represents a set node.
Definition: Set.php:17
Create styles array
The data for the language used.
Represents a text node.
Definition: Text.php:18

◆ getFilterBodyNodesDataThrowsException()

Twig_Tests_ParserTest::getFilterBodyNodesDataThrowsException ( )

Definition at line 93 of file ParserTest.php.

References array.

94  {
95  return array(
96  array(new Twig_Node_Text('foo', 1)),
97  array(new Twig_Node(array(new Twig_Node(array(new Twig_Node_Text('foo', 1)))))),
98  );
99  }
Represents a node in the AST.
Definition: Node.php:18
Create styles array
The data for the language used.
Represents a text node.
Definition: Text.php:18

◆ getParser()

Twig_Tests_ParserTest::getParser ( )
protected

Definition at line 156 of file ParserTest.php.

References $parser.

Referenced by testFilterBodyNodes(), testFilterBodyNodesThrowsException(), testFilterBodyNodesWithBOM(), and testSetMacroThrowsExceptionOnReservedMethods().

157  {
158  $parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
159  $parser->setParent(new Twig_Node());
160  $parser->stream = new Twig_TokenStream(array());
161 
162  return $parser;
163  }
Represents a node in the AST.
Definition: Node.php:18
Represents a token stream.
Definition: TokenStream.php:20
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
Stores the Twig configuration.
Definition: Environment.php:17
+ Here is the caller graph for this function:

◆ testFilterBodyNodes()

Twig_Tests_ParserTest::testFilterBodyNodes (   $input,
  $expected 
)

getFilterBodyNodesData

Definition at line 57 of file ParserTest.php.

References $parser, and getParser().

58  {
59  $parser = $this->getParser();
60 
61  $this->assertEquals($expected, $parser->filterBodyNodes($input));
62  }
$parser
Definition: BPMN2Parser.php:23
+ Here is the call graph for this function:

◆ testFilterBodyNodesThrowsException()

Twig_Tests_ParserTest::testFilterBodyNodesThrowsException (   $input)

getFilterBodyNodesDataThrowsException Twig_Error_Syntax

Definition at line 86 of file ParserTest.php.

References $parser, and getParser().

87  {
88  $parser = $this->getParser();
89 
90  $parser->filterBodyNodes($input);
91  }
$parser
Definition: BPMN2Parser.php:23
+ Here is the call graph for this function:

◆ testFilterBodyNodesWithBOM()

Twig_Tests_ParserTest::testFilterBodyNodesWithBOM ( )

Twig_Error_Syntax A template that extends another one cannot start with a byte order mark (BOM); it must be removed at line 1

Definition at line 105 of file ParserTest.php.

References $parser, and getParser().

106  {
107  $parser = $this->getParser();
108  $parser->filterBodyNodes(new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF), 1));
109  }
$parser
Definition: BPMN2Parser.php:23
Represents a text node.
Definition: Text.php:18
+ Here is the call graph for this function:

◆ testGetVarName()

Twig_Tests_ParserTest::testGetVarName ( )

Definition at line 134 of file ParserTest.php.

References array, and EOF.

135  {
136  $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
137  'autoescape' => false,
138  'optimizations' => 0,
139  ));
140 
141  $twig->parse($twig->tokenize(new Twig_Source(<<<EOF
142 {% from _self import foo %}
143 
144 {% macro foo() %}
145  {{ foo }}
146 {% endmacro %}
147 EOF
148  , 'index')));
149 
150  // The getVarName() must not depend on the template loaders,
151  // If this test does not throw any exception, that's good.
152  // see https://github.com/symfony/symfony/issues/4218
153  $this->addToAssertionCount(1);
154  }
Create styles array
The data for the language used.
Holds information about a non-compiled Twig template.
Definition: Source.php:19
Stores the Twig configuration.
Definition: Environment.php:17
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92

◆ testParseIsReentrant()

Twig_Tests_ParserTest::testParseIsReentrant ( )

Definition at line 111 of file ParserTest.php.

References $parser, array, Twig_Token\BLOCK_END_TYPE, Twig_Token\BLOCK_START_TYPE, Twig_Token\EOF_TYPE, Twig_Token\NAME_TYPE, Twig_Token\VAR_END_TYPE, and Twig_Token\VAR_START_TYPE.

112  {
113  $twig = new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock(), array(
114  'autoescape' => false,
115  'optimizations' => 0,
116  ));
117  $twig->addTokenParser(new TestTokenParser());
118 
119  $parser = new Twig_Parser($twig);
120 
121  $parser->parse(new Twig_TokenStream(array(
123  new Twig_Token(Twig_Token::NAME_TYPE, 'test', 1),
126  new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1),
128  new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
129  )));
130 
131  $this->assertNull($parser->getParent());
132  }
Default parser implementation.
Definition: Parser.php:18
Represents a token stream.
Definition: TokenStream.php:20
const VAR_END_TYPE
Definition: Token.php:31
const BLOCK_START_TYPE
Definition: Token.php:28
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
const EOF_TYPE
Definition: Token.php:26
Stores the Twig configuration.
Definition: Environment.php:17
const VAR_START_TYPE
Definition: Token.php:29
const NAME_TYPE
Definition: Token.php:32
const BLOCK_END_TYPE
Definition: Token.php:30

◆ testSetMacroThrowsExceptionOnReservedMethods()

Twig_Tests_ParserTest::testSetMacroThrowsExceptionOnReservedMethods ( )

Twig_Error_Syntax

Definition at line 16 of file ParserTest.php.

References $parser, and getParser().

17  {
18  $parser = $this->getParser();
19  $parser->setMacro('parent', $this->getMockBuilder('Twig_Node_Macro')->disableOriginalConstructor()->getMock());
20  }
$parser
Definition: BPMN2Parser.php:23
+ Here is the call graph for this function:

◆ testUnknownTag()

Twig_Tests_ParserTest::testUnknownTag ( )

Twig_Error_Syntax Unknown "foo" tag.

Did you mean "for" at line 1?

Definition at line 26 of file ParserTest.php.

References $parser, GuzzleHttp\Psr7\$stream, array, Twig_Token\BLOCK_END_TYPE, Twig_Token\BLOCK_START_TYPE, Twig_Token\EOF_TYPE, and Twig_Token\NAME_TYPE.

27  {
30  new Twig_Token(Twig_Token::NAME_TYPE, 'foo', 1),
32  new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
33  ));
34  $parser = new Twig_Parser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
35  $parser->parse($stream);
36  }
Default parser implementation.
Definition: Parser.php:18
Represents a token stream.
Definition: TokenStream.php:20
$stream
PHP stream implementation.
const BLOCK_START_TYPE
Definition: Token.php:28
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
const EOF_TYPE
Definition: Token.php:26
Stores the Twig configuration.
Definition: Environment.php:17
const NAME_TYPE
Definition: Token.php:32
const BLOCK_END_TYPE
Definition: Token.php:30

◆ testUnknownTagWithoutSuggestions()

Twig_Tests_ParserTest::testUnknownTagWithoutSuggestions ( )

Twig_Error_Syntax Unknown "foobar" tag at line 1.

Definition at line 42 of file ParserTest.php.

References $parser, GuzzleHttp\Psr7\$stream, array, Twig_Token\BLOCK_END_TYPE, Twig_Token\BLOCK_START_TYPE, Twig_Token\EOF_TYPE, and Twig_Token\NAME_TYPE.

43  {
46  new Twig_Token(Twig_Token::NAME_TYPE, 'foobar', 1),
48  new Twig_Token(Twig_Token::EOF_TYPE, '', 1),
49  ));
50  $parser = new Twig_Parser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
51  $parser->parse($stream);
52  }
Default parser implementation.
Definition: Parser.php:18
Represents a token stream.
Definition: TokenStream.php:20
$stream
PHP stream implementation.
const BLOCK_START_TYPE
Definition: Token.php:28
Create styles array
The data for the language used.
$parser
Definition: BPMN2Parser.php:23
const EOF_TYPE
Definition: Token.php:26
Stores the Twig configuration.
Definition: Environment.php:17
const NAME_TYPE
Definition: Token.php:32
const BLOCK_END_TYPE
Definition: Token.php:30

The documentation for this class was generated from the following file: