ArrayLoaderTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2014 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @group unit
  12. */
  13. class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase
  14. {
  15. public function testConstructor()
  16. {
  17. $loader = new Mustache_Loader_ArrayLoader(array(
  18. 'foo' => 'bar'
  19. ));
  20. $this->assertEquals('bar', $loader->load('foo'));
  21. }
  22. public function testSetAndLoadTemplates()
  23. {
  24. $loader = new Mustache_Loader_ArrayLoader(array(
  25. 'foo' => 'bar'
  26. ));
  27. $this->assertEquals('bar', $loader->load('foo'));
  28. $loader->setTemplate('baz', 'qux');
  29. $this->assertEquals('qux', $loader->load('baz'));
  30. $loader->setTemplates(array(
  31. 'foo' => 'FOO',
  32. 'baz' => 'BAZ',
  33. ));
  34. $this->assertEquals('FOO', $loader->load('foo'));
  35. $this->assertEquals('BAZ', $loader->load('baz'));
  36. }
  37. /**
  38. * @expectedException Mustache_Exception_UnknownTemplateException
  39. */
  40. public function testMissingTemplatesThrowExceptions()
  41. {
  42. $loader = new Mustache_Loader_ArrayLoader;
  43. $loader->load('not_a_real_template');
  44. }
  45. }