ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
grammarTest Class Reference

legacy More...

+ Inheritance diagram for grammarTest:
+ Collaboration diagram for grammarTest:

Public Member Functions

 testGrammar ($tag, $grammar, $template, $output, $exception)
 getTests More...
 
 getTests ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

legacy

Definition at line 15 of file grammarTest.php.

Member Function Documentation

◆ getTests()

grammarTest::getTests ( )

Definition at line 54 of file grammarTest.php.

References array.

55  {
56  return array(
57  array('foo1', '', '{% foo1 %}', '|', false),
58  array('foo2', '', '{% foo2 "bar" %}', '|', 'Twig_Error_Syntax'),
59  array('foo3', '<foo>', '{% foo3 "bar" %}', '|bar|', false),
60  array('foo4', '<foo>', '{% foo4 1 + 2 %}', '|3|', false),
61  array('foo5', '<foo:expression>', '{% foo5 1 + 2 %}', '|3|', false),
62  array('foo6', '<foo:array>', '{% foo6 1 + 2 %}', '|3|', 'Twig_Error_Syntax'),
63  array('foo7', '<foo>', '{% foo7 %}', '|3|', 'Twig_Error_Syntax'),
64  array('foo8', '<foo:array>', '{% foo8 [1, 2] %}', "|int(0)\nint(1)\nint(1)\nint(2)\n|", false),
65  array('foo9', '<foo> with <bar>', '{% foo9 "bar" with "foobar" %}', '|bar|with|foobar|', false),
66  array('foo10', '<foo> [with <bar>]', '{% foo10 "bar" with "foobar" %}', '|bar|with|foobar|', false),
67  array('foo11', '<foo> [with <bar>]', '{% foo11 "bar" %}', '|bar|', false),
68  );
69  }
Create styles array
The data for the language used.

◆ setUp()

grammarTest::setUp ( )
protected

Definition at line 17 of file grammarTest.php.

18  {
19  require_once __DIR__.'/SimpleTokenParser.php';
20  }

◆ testGrammar()

grammarTest::testGrammar (   $tag,
  $grammar,
  $template,
  $output,
  $exception 
)

getTests

Definition at line 25 of file grammarTest.php.

References $ok, $output, $tag, $template, and array.

26  {
27  $twig = new Twig_Environment(new Twig_Loader_Array(array('template' => $template)), array('cache' => false, 'autoescape' => false, 'debug' => true));
28  $twig->addExtension(new Twig_Extension_Debug());
29  $twig->addTokenParser(new SimpleTokenParser($tag, $grammar));
30 
31  $ok = true;
32  try {
33  $template = $twig->loadTemplate('template');
34  } catch (Exception $e) {
35  $ok = false;
36 
37  if (false === $exception) {
38  $this->fail('Exception not expected');
39  } else {
40  $this->assertEquals($exception, get_class($e));
41  }
42  }
43 
44  if ($ok) {
45  if (false !== $exception) {
46  $this->fail(sprintf('Exception "%s" expected', $exception));
47  }
48 
49  $actual = $template->render(array());
50  $this->assertEquals($output, $actual);
51  }
52  }
$template
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Create styles array
The data for the language used.
Stores the Twig configuration.
Definition: Environment.php:17
Loads a template from an array.
Definition: Array.php:26
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35

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