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

Public Member Functions

 testGetSource ()
 @group legacy More...
 
 testGetSourceContext ()
 
 testGetSourceContextWhenTemplateDoesNotExist ()
 @expectedException Twig_Error_Loader More...
 
 testGetSourceWhenTemplateDoesNotExist ()
 @group legacy @expectedException Twig_Error_Loader More...
 
 testGetCacheKey ()
 
 testGetCacheKeyWhenTemplateDoesNotExist ()
 @expectedException 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 {
94 $loader->addLoader(new Twig_Loader_Array(array('foo' => 'bar')));
95
96 $this->assertEquals('bar', $loader->getSourceContext('foo')->getCode());
97 }
Loads a template from an array.
Definition: Array.php:27
Loads templates from other loaders.
Definition: Chain.php:20

References $loader.

◆ testExists()

Twig_Tests_Loader_ChainTest::testExists ( )

Definition at line 99 of file ChainTest.php.

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
111 $loader->addLoader($loader1);
112 $loader->addLoader($loader2);
113
114 $this->assertTrue($loader->exists('foo'));
115 }
Holds information about a non-compiled Twig template.
Definition: Source.php:20

References $loader.

◆ 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 }

References $loader.

◆ testGetCacheKeyWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetCacheKeyWhenTemplateDoesNotExist ( )

@expectedException 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 }

References $loader.

◆ testGetSource()

Twig_Tests_Loader_ChainTest::testGetSource ( )

@group 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 }

References $loader.

◆ testGetSourceContext()

Twig_Tests_Loader_ChainTest::testGetSourceContext ( )

Definition at line 28 of file ChainTest.php.

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 }
Loads template from the filesystem.
Definition: Filesystem.php:18

References $loader, and $path.

◆ testGetSourceContextWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetSourceContextWhenTemplateDoesNotExist ( )

@expectedException 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 }

References $loader.

◆ testGetSourceWhenTemplateDoesNotExist()

Twig_Tests_Loader_ChainTest::testGetSourceWhenTemplateDoesNotExist ( )

@group legacy @expectedException 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 }

References $loader.


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