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

Public Member Functions

 testHasGetBlocks ()
 
 testRenderBlock ()
 
 testDisplayBlock ()
 

Detailed Description

Definition at line 11 of file TemplateWrapperTest.php.

Member Function Documentation

◆ testDisplayBlock()

Twig_Tests_TemplateWrapperTest::testDisplayBlock ( )

Definition at line 50 of file TemplateWrapperTest.php.

References array.

51  {
53  'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}',
54  )));
55  $twig->addGlobal('bar', 'BAR');
56 
57  $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
58 
59  ob_start();
60  $wrapper->displayBlock('foo', array('foo' => 'FOO'));
61 
62  $this->assertEquals('FOOBAR', ob_get_clean());
63  }
Exposes a template to userland.
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

◆ testHasGetBlocks()

Twig_Tests_TemplateWrapperTest::testHasGetBlocks ( )

Definition at line 13 of file TemplateWrapperTest.php.

References array.

14  {
16  'index' => '{% block foo %}{% endblock %}',
17  'index_with_use' => '{% use "imported" %}{% block foo %}{% endblock %}',
18  'index_with_extends' => '{% extends "extended" %}{% block foo %}{% endblock %}',
19  'imported' => '{% block imported %}{% endblock %}',
20  'extended' => '{% block extended %}{% endblock %}',
21  )));
22 
23  $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
24  $this->assertTrue($wrapper->hasBlock('foo'));
25  $this->assertFalse($wrapper->hasBlock('bar'));
26  $this->assertEquals(array('foo'), $wrapper->getBlockNames());
27 
28  $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_use'));
29  $this->assertTrue($wrapper->hasBlock('foo'));
30  $this->assertTrue($wrapper->hasBlock('imported'));
31  $this->assertEquals(array('imported', 'foo'), $wrapper->getBlockNames());
32 
33  $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index_with_extends'));
34  $this->assertTrue($wrapper->hasBlock('foo'));
35  $this->assertTrue($wrapper->hasBlock('extended'));
36  $this->assertEquals(array('foo', 'extended'), $wrapper->getBlockNames());
37  }
Exposes a template to userland.
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

◆ testRenderBlock()

Twig_Tests_TemplateWrapperTest::testRenderBlock ( )

Definition at line 39 of file TemplateWrapperTest.php.

References array.

40  {
42  'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}',
43  )));
44  $twig->addGlobal('bar', 'BAR');
45 
46  $wrapper = new Twig_TemplateWrapper($twig, $twig->loadTemplate('index'));
47  $this->assertEquals('FOOBAR', $wrapper->renderBlock('foo', array('foo' => 'FOO')));
48  }
Exposes a template to userland.
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

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