4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 class Twig_Tests_Loader_ArrayTest
extends PHPUnit_Framework_TestCase
14 public function testGetSource()
16 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
18 $this->assertEquals('bar', $loader->getSource('foo'));
22 * @expectedException Twig_Error_Loader
24 public function testGetSourceWhenTemplateDoesNotExist()
26 $loader = new Twig_Loader_Array(array());
28 $loader->getSource('foo');
31 public function testGetCacheKey()
33 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
35 $this->assertEquals('bar', $loader->getCacheKey('foo'));
39 * @expectedException Twig_Error_Loader
41 public function testGetCacheKeyWhenTemplateDoesNotExist()
43 $loader = new Twig_Loader_Array(array());
45 $loader->getCacheKey('foo');
48 public function testSetTemplate()
50 $loader = new Twig_Loader_Array(array());
51 $loader->setTemplate('foo', 'bar');
53 $this->assertEquals('bar', $loader->getSource('foo'));
56 public function testIsFresh()
58 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
59 $this->assertTrue($loader->isFresh('foo', time()));
63 * @expectedException Twig_Error_Loader
65 public function testIsFreshWhenTemplateDoesNotExist()
67 $loader = new Twig_Loader_Array(array());
69 $loader->isFresh('foo', time());
72 public function testTemplateReference()
74 $name = new Twig_Test_Loader_TemplateReference('foo');
75 $loader = new Twig_Loader_Array(array('foo' => 'bar'));
77 $loader->getCacheKey($name);
78 $loader->getSource($name);
79 $loader->isFresh($name, time());
80 $loader->setTemplate($name, 'foobar');
84 class Twig_Test_Loader_TemplateReference
88 public function __construct($name)
93 public function __toString()