ArrayLoaderTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2012 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. public function testConstructor() {
  15. $loader = new Mustache_Loader_ArrayLoader(array(
  16. 'foo' => 'bar'
  17. ));
  18. $this->assertEquals('bar', $loader->load('foo'));
  19. }
  20. public function testSetAndLoadTemplates() {
  21. $loader = new Mustache_Loader_ArrayLoader(array(
  22. 'foo' => 'bar'
  23. ));
  24. $this->assertEquals('bar', $loader->load('foo'));
  25. $loader->setTemplate('baz', 'qux');
  26. $this->assertEquals('qux', $loader->load('baz'));
  27. $loader->setTemplates(array(
  28. 'foo' => 'FOO',
  29. 'baz' => 'BAZ',
  30. ));
  31. $this->assertEquals('FOO', $loader->load('foo'));
  32. $this->assertEquals('BAZ', $loader->load('baz'));
  33. }
  34. /**
  35. * @expectedException InvalidArgumentException
  36. */
  37. public function testMissingTemplatesThrowExceptions() {
  38. $loader = new Mustache_Loader_ArrayLoader;
  39. $loader->load('not_a_real_template');
  40. }
  41. }