ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Tests_Loader_ChainTest Class Reference
+ Inheritance diagram for Twig_Tests_Loader_ChainTest:
+ Collaboration diagram for Twig_Tests_Loader_ChainTest:

Public Member Functions

 testGetSource ()
 legacy More...
 
 testGetSourceContext ()
 
 testGetSourceContextWhenTemplateDoesNotExist ()
 Twig_Error_Loader More...
 
 testGetSourceWhenTemplateDoesNotExist ()
 legacy Twig_Error_Loader More...
 
 testGetCacheKey ()
 
 testGetCacheKeyWhenTemplateDoesNotExist ()
 Twig_Error_Loader More...
 
 testAddLoader ()
 
 testExists ()
 

Detailed Description

Definition at line 12 of file ChainTest.php.

Member Function Documentation

◆ testAddLoader()

Twig_Tests_Loader_ChainTest::testAddLoader ( )

Definition at line 91 of file ChainTest.php.

92  {
93  $loader = new Twig_Loader_Chain();
94  $loader->addLoader(new Twig_Loader_Array(array('foo' => 'bar')));
95 
96  $this->assertEquals('bar', $loader->getSourceContext('foo')->getCode());
97  }
Loads templates from other loaders.
Definition: Chain.php:19
Loads a template from an array.
Definition: Array.php:26

◆ testExists()

Twig_Tests_Loader_ChainTest::testExists ( )

Definition at line 99 of file ChainTest.php.

References Sabre\Event\once().

100  {
101  $loader1 = $this->getMockBuilder('Twig_ChainTestLoaderWithExistsInterface')->getMock();
102  $loader1->expects($this->once())->method('exists')->will($this->returnValue(false));
103  $loader1->expects($this->never())->method('getSourceContext');
104 
105  // can be removed in 2.0
106  $loader2 = $this->getMockBuilder('Twig_ChainTestLoaderInterface')->getMock();
107  //$loader2 = $this->getMockBuilder(array('Twig_LoaderInterface', 'Twig_SourceContextLoaderInterface'))->getMock();
108  $loader2->expects($this->once())->method('getSourceContext')->will($this->returnValue(new Twig_Source('content', 'index')));
109 
110  $loader = new Twig_Loader_Chain();
111  $loader->addLoader($loader1);
112  $loader->addLoader($loader2);
113 
114  $this->assertTrue($loader->exists('foo'));
115  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Loads templates from other loaders.
Definition: Chain.php:19
Holds information about a non-compiled Twig template.
Definition: Source.php:19
+ Here is the call graph for this function:

◆ testGetCacheKey()

Twig_Tests_Loader_ChainTest::testGetCacheKey ( )

Definition at line 70 of file ChainTest.php.

71  {
72  $loader = new Twig_Loader_Chain(array(
73  new Twig_Loader_Array(array('foo' => 'bar')),
74  new Twig_Loader_Array(array('foo' => 'foobar', 'bar' => 'foo')),
75  ));
76 
77  $this->assertEquals('foo:bar', $loader->getCacheKey('foo'));
78  $this->assertEquals('bar:foo', $loader->getCacheKey('bar'));
79  }
Loads templates from other loaders.
Definition: Chain.php:19
Loads a template from an array.
Definition: Array.php:26

◆ testGetCacheKeyWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetCacheKeyWhenTemplateDoesNotExist ( )

Twig_Error_Loader

Definition at line 84 of file ChainTest.php.

85  {
86  $loader = new Twig_Loader_Chain(array());
87 
88  $loader->getCacheKey('foo');
89  }
Loads templates from other loaders.
Definition: Chain.php:19

◆ testGetSource()

Twig_Tests_Loader_ChainTest::testGetSource ( )

legacy

Definition at line 17 of file ChainTest.php.

18  {
19  $loader = new Twig_Loader_Chain(array(
20  new Twig_Loader_Array(array('foo' => 'bar')),
21  new Twig_Loader_Array(array('foo' => 'foobar', 'bar' => 'foo')),
22  ));
23 
24  $this->assertEquals('bar', $loader->getSource('foo'));
25  $this->assertEquals('foo', $loader->getSource('bar'));
26  }
Loads templates from other loaders.
Definition: Chain.php:19
Loads a template from an array.
Definition: Array.php:26

◆ testGetSourceContext()

Twig_Tests_Loader_ChainTest::testGetSourceContext ( )

Definition at line 28 of file ChainTest.php.

References $path.

29  {
30  $path = dirname(__FILE__).'/../Fixtures';
31  $loader = new Twig_Loader_Chain(array(
32  new Twig_Loader_Array(array('foo' => 'bar')),
33  new Twig_Loader_Array(array('errors/index.html' => 'baz')),
34  new Twig_Loader_Filesystem(array($path)),
35  ));
36 
37  $this->assertEquals('foo', $loader->getSourceContext('foo')->getName());
38  $this->assertSame('', $loader->getSourceContext('foo')->getPath());
39 
40  $this->assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName());
41  $this->assertSame('', $loader->getSourceContext('errors/index.html')->getPath());
42  $this->assertEquals('baz', $loader->getSourceContext('errors/index.html')->getCode());
43 
44  $this->assertEquals('errors/base.html', $loader->getSourceContext('errors/base.html')->getName());
45  $this->assertEquals(realpath($path.'/errors/base.html'), realpath($loader->getSourceContext('errors/base.html')->getPath()));
46  $this->assertNotEquals('baz', $loader->getSourceContext('errors/base.html')->getCode());
47  }
$path
Definition: aliased.php:25
Loads template from the filesystem.
Definition: Filesystem.php:17
Loads templates from other loaders.
Definition: Chain.php:19
Loads a template from an array.
Definition: Array.php:26

◆ testGetSourceContextWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetSourceContextWhenTemplateDoesNotExist ( )

Twig_Error_Loader

Definition at line 52 of file ChainTest.php.

53  {
54  $loader = new Twig_Loader_Chain(array());
55 
56  $loader->getSourceContext('foo');
57  }
Loads templates from other loaders.
Definition: Chain.php:19

◆ testGetSourceWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetSourceWhenTemplateDoesNotExist ( )

legacy Twig_Error_Loader

Definition at line 63 of file ChainTest.php.

64  {
65  $loader = new Twig_Loader_Chain(array());
66 
67  $loader->getSource('foo');
68  }
Loads templates from other loaders.
Definition: Chain.php:19

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