InlineLoaderTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2013 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_InlineLoaderTest extends PHPUnit_Framework_TestCase
  14. {
  15. public function testLoadTemplates()
  16. {
  17. $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
  18. $this->assertEquals('{{ foo }}', $loader->load('foo'));
  19. $this->assertEquals('{{#bar}}BAR{{/bar}}', $loader->load('bar'));
  20. }
  21. /**
  22. * @expectedException Mustache_Exception_UnknownTemplateException
  23. */
  24. public function testMissingTemplatesThrowExceptions()
  25. {
  26. $loader = new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__);
  27. $loader->load('not_a_real_template');
  28. }
  29. /**
  30. * @expectedException Mustache_Exception_InvalidArgumentException
  31. */
  32. public function testInvalidOffsetThrowsException()
  33. {
  34. $loader = new Mustache_Loader_InlineLoader(__FILE__, 'notanumber');
  35. }
  36. /**
  37. * @expectedException Mustache_Exception_InvalidArgumentException
  38. */
  39. public function testInvalidFileThrowsException()
  40. {
  41. $loader = new Mustache_Loader_InlineLoader('notarealfile', __COMPILER_HALT_OFFSET__);
  42. }
  43. }
  44. __halt_compiler();
  45. @@ foo
  46. {{ foo }}
  47. @@ bar
  48. {{#bar}}BAR{{/bar}}