ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
SimpleTokenParserTest.php
Go to the documentation of this file.
1
<?
php
2
3
/*
4
* This file is part of Twig.
5
*
6
* (c) Fabien Potencier
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
15
class
Twig_Tests_SimpleTokenParserTest
extends
PHPUnit_Framework_TestCase
16
{
20
public
function
testParseGrammar
($str, $grammar)
21
{
22
$this->assertEquals($grammar,
Twig_Extensions_SimpleTokenParser::parseGrammar
($str),
'::parseGrammar() parses a grammar'
);
23
}
24
25
public
function
testParseGrammarExceptions
()
26
{
27
try
{
28
Twig_Extensions_SimpleTokenParser::parseGrammar
(
'<foo:foo>'
);
29
$this->fail();
30
}
catch
(
Exception
$e) {
31
$this->assertEquals(
'Twig_Error_Runtime'
, get_class($e));
32
}
33
34
try
{
35
Twig_Extensions_SimpleTokenParser::parseGrammar
(
'<foo:foo'
);
36
$this->fail();
37
}
catch
(
Exception
$e) {
38
$this->assertEquals(
'Twig_Error_Runtime'
, get_class($e));
39
}
40
41
try
{
42
Twig_Extensions_SimpleTokenParser::parseGrammar
(
'<foo:foo> (with'
);
43
$this->fail();
44
}
catch
(
Exception
$e) {
45
$this->assertEquals(
'Twig_Error_Runtime'
, get_class($e));
46
}
47
}
48
49
public
function
getTests
()
50
{
51
return
array(
52
array(
''
,
new
Twig_Extensions_Grammar_Tag
()),
53
array(
'const'
,
new
Twig_Extensions_Grammar_Tag
(
54
new
Twig_Extensions_Grammar_Constant
(
'const'
)
55
)),
56
array(
' const '
,
new
Twig_Extensions_Grammar_Tag
(
57
new
Twig_Extensions_Grammar_Constant
(
'const'
)
58
)),
59
array(
'<expr>'
,
new
Twig_Extensions_Grammar_Tag
(
60
new
Twig_Extensions_Grammar_Expression
(
'expr'
)
61
)),
62
array(
'<expr:expression>'
,
new
Twig_Extensions_Grammar_Tag
(
63
new
Twig_Extensions_Grammar_Expression
(
'expr'
)
64
)),
65
array(
' <expr:expression> '
,
new
Twig_Extensions_Grammar_Tag
(
66
new
Twig_Extensions_Grammar_Expression
(
'expr'
)
67
)),
68
array(
'<nb:number>'
,
new
Twig_Extensions_Grammar_Tag
(
69
new
Twig_Extensions_Grammar_Number
(
'nb'
)
70
)),
71
array(
'<bool:boolean>'
,
new
Twig_Extensions_Grammar_Tag
(
72
new
Twig_Extensions_Grammar_Boolean
(
'bool'
)
73
)),
74
array(
'<content:body>'
,
new
Twig_Extensions_Grammar_Tag
(
75
new
Twig_Extensions_Grammar_Body
(
'content'
)
76
)),
77
array(
'<expr:expression> [with <arguments:array>]'
,
new
Twig_Extensions_Grammar_Tag
(
78
new
Twig_Extensions_Grammar_Expression
(
'expr'
),
79
new
Twig_Extensions_Grammar_Optional
(
80
new
Twig_Extensions_Grammar_Constant
(
'with'
),
81
new
Twig_Extensions_Grammar_Array
(
'arguments'
)
82
)
83
)),
84
array(
' <expr:expression> [ with <arguments:array> ] '
,
new
Twig_Extensions_Grammar_Tag
(
85
new
Twig_Extensions_Grammar_Expression
(
'expr'
),
86
new
Twig_Extensions_Grammar_Optional
(
87
new
Twig_Extensions_Grammar_Constant
(
'with'
),
88
new
Twig_Extensions_Grammar_Array
(
'arguments'
)
89
)
90
)),
91
array(
'<expr:expression> [with <arguments:array> [or <optional:expression>]]'
,
new
Twig_Extensions_Grammar_Tag
(
92
new
Twig_Extensions_Grammar_Expression
(
'expr'
),
93
new
Twig_Extensions_Grammar_Optional
(
94
new
Twig_Extensions_Grammar_Constant
(
'with'
),
95
new
Twig_Extensions_Grammar_Array
(
'arguments'
),
96
new
Twig_Extensions_Grammar_Optional
(
97
new
Twig_Extensions_Grammar_Constant
(
'or'
),
98
new
Twig_Extensions_Grammar_Expression
(
'optional'
)
99
)
100
)
101
)),
102
array(
'<expr:expression> [with <arguments:array> [, <optional:expression>]]'
,
new
Twig_Extensions_Grammar_Tag
(
103
new
Twig_Extensions_Grammar_Expression
(
'expr'
),
104
new
Twig_Extensions_Grammar_Optional
(
105
new
Twig_Extensions_Grammar_Constant
(
'with'
),
106
new
Twig_Extensions_Grammar_Array
(
'arguments'
),
107
new
Twig_Extensions_Grammar_Optional
(
108
new
Twig_Extensions_Grammar_Constant
(
','
,
Twig_Token::PUNCTUATION_TYPE
),
109
new
Twig_Extensions_Grammar_Expression
(
'optional'
)
110
)
111
)
112
)),
113
);
114
}
115
}
Twig_Token\PUNCTUATION_TYPE
const PUNCTUATION_TYPE
Definition:
Token.php:36
Twig_Tests_SimpleTokenParserTest
legacy
Definition:
SimpleTokenParserTest.php:15
Twig_Extensions_Grammar_Array
Definition:
Array.php:15
Twig_Tests_SimpleTokenParserTest\testParseGrammar
testParseGrammar($str, $grammar)
getTests
Definition:
SimpleTokenParserTest.php:20
Twig_Extensions_Grammar_Number
Definition:
Number.php:15
PHPUnit_Framework_TestCase
Twig_Tests_SimpleTokenParserTest\getTests
getTests()
Definition:
SimpleTokenParserTest.php:49
Twig_Extensions_Grammar_Expression
Definition:
Expression.php:15
Twig_Extensions_Grammar_Optional
Definition:
Optional.php:15
Twig_Extensions_SimpleTokenParser\parseGrammar
static parseGrammar($str, $main=true)
Definition:
SimpleTokenParser.php:97
Twig_Extensions_Grammar_Boolean
Definition:
Boolean.php:15
Twig_Extensions_Grammar_Constant
Definition:
Constant.php:15
Twig_Tests_SimpleTokenParserTest\testParseGrammarExceptions
testParseGrammarExceptions()
Definition:
SimpleTokenParserTest.php:25
Twig_Extensions_Grammar_Body
Definition:
Body.php:15
php
Twig_Extensions_Grammar_Tag
Definition:
Tag.php:15
Exception
libs
composer
vendor
twig
extensions
test
Twig
Tests
SimpleTokenParserTest.php
Generated on Thu Jan 30 2025 19:01:34 for ILIAS by
1.8.13 (using
Doxyfile
)