CascadingLoaderTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2016 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_CascadingLoaderTest extends PHPUnit_Framework_TestCase
  14. {
  15. public function testLoadTemplates()
  16. {
  17. $loader = new Mustache_Loader_CascadingLoader(array(
  18. new Mustache_Loader_ArrayLoader(array('foo' => '{{ foo }}')),
  19. new Mustache_Loader_ArrayLoader(array('bar' => '{{#bar}}BAR{{/bar}}')),
  20. ));
  21. $this->assertEquals('{{ foo }}', $loader->load('foo'));
  22. $this->assertEquals('{{#bar}}BAR{{/bar}}', $loader->load('bar'));
  23. }
  24. /**
  25. * @expectedException Mustache_Exception_UnknownTemplateException
  26. */
  27. public function testMissingTemplatesThrowExceptions()
  28. {
  29. $loader = new Mustache_Loader_CascadingLoader(array(
  30. new Mustache_Loader_ArrayLoader(array('foo' => '{{ foo }}')),
  31. new Mustache_Loader_ArrayLoader(array('bar' => '{{#bar}}BAR{{/bar}}')),
  32. ));
  33. $loader->load('not_a_real_template');
  34. }
  35. }