]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/test/Twig/Tests/Loader/ArrayTest.php
gitignore vendor
[github/wallabag/wallabag.git] / vendor / twig / twig / test / Twig / Tests / Loader / ArrayTest.php
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
12 class Twig_Tests_Loader_ArrayTest extends PHPUnit_Framework_TestCase
13 {
14 public function testGetSource()
15 {
16 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
17
18 $this->assertEquals('bar', $loader->getSource('foo'));
19 }
20
21 /**
22 * @expectedException Twig_Error_Loader
23 */
24 public function testGetSourceWhenTemplateDoesNotExist()
25 {
26 $loader = new Twig_Loader_Array(array());
27
28 $loader->getSource('foo');
29 }
30
31 public function testGetCacheKey()
32 {
33 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
34
35 $this->assertEquals('bar', $loader->getCacheKey('foo'));
36 }
37
38 /**
39 * @expectedException Twig_Error_Loader
40 */
41 public function testGetCacheKeyWhenTemplateDoesNotExist()
42 {
43 $loader = new Twig_Loader_Array(array());
44
45 $loader->getCacheKey('foo');
46 }
47
48 public function testSetTemplate()
49 {
50 $loader = new Twig_Loader_Array(array());
51 $loader->setTemplate('foo', 'bar');
52
53 $this->assertEquals('bar', $loader->getSource('foo'));
54 }
55
56 public function testIsFresh()
57 {
58 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
59 $this->assertTrue($loader->isFresh('foo', time()));
60 }
61
62 /**
63 * @expectedException Twig_Error_Loader
64 */
65 public function testIsFreshWhenTemplateDoesNotExist()
66 {
67 $loader = new Twig_Loader_Array(array());
68
69 $loader->isFresh('foo', time());
70 }
71
72 public function testTemplateReference()
73 {
74 $name = new Twig_Test_Loader_TemplateReference('foo');
75 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
76
77 $loader->getCacheKey($name);
78 $loader->getSource($name);
79 $loader->isFresh($name, time());
80 $loader->setTemplate($name, 'foobar');
81 }
82 }
83
84 class Twig_Test_Loader_TemplateReference
85 {
86 private $name;
87
88 public function __construct($name)
89 {
90 $this->name = $name;
91 }
92
93 public function __toString()
94 {
95 return $this->name;
96 }
97 }