ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
16{
20 public function testParseGrammar($str, $grammar)
21 {
22 $this->assertEquals($grammar, Twig_Extensions_SimpleTokenParser::parseGrammar($str), '::parseGrammar() parses a grammar');
23 }
24
26 {
27 try {
29 $this->fail();
30 } catch (Exception $e) {
31 $this->assertEquals('Twig_Error_Runtime', get_class($e));
32 }
33
34 try {
36 $this->fail();
37 } catch (Exception $e) {
38 $this->assertEquals('Twig_Error_Runtime', get_class($e));
39 }
40
41 try {
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(
55 )),
56 array(' const ', new Twig_Extensions_Grammar_Tag(
58 )),
59 array('<expr>', new Twig_Extensions_Grammar_Tag(
61 )),
62 array('<expr:expression>', new Twig_Extensions_Grammar_Tag(
64 )),
65 array(' <expr:expression> ', new Twig_Extensions_Grammar_Tag(
67 )),
68 array('<nb:number>', new Twig_Extensions_Grammar_Tag(
70 )),
71 array('<bool:boolean>', new Twig_Extensions_Grammar_Tag(
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(
81 new Twig_Extensions_Grammar_Array('arguments')
82 )
83 )),
84 array(' <expr:expression> [ with <arguments:array> ] ', new Twig_Extensions_Grammar_Tag(
88 new Twig_Extensions_Grammar_Array('arguments')
89 )
90 )),
91 array('<expr:expression> [with <arguments:array> [or <optional:expression>]]', new Twig_Extensions_Grammar_Tag(
95 new Twig_Extensions_Grammar_Array('arguments'),
99 )
100 )
101 )),
102 array('<expr:expression> [with <arguments:array> [, <optional:expression>]]', new Twig_Extensions_Grammar_Tag(
106 new Twig_Extensions_Grammar_Array('arguments'),
110 )
111 )
112 )),
113 );
114 }
115}
An exception for terminatinating execution or to throw for unit testing.
static parseGrammar($str, $main=true)
testParseGrammar($str, $grammar)
@dataProvider getTests
const PUNCTUATION_TYPE
Definition: Token.php:36