UnknownTemplateExceptionTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class Mustache_Test_Exception_UnknownTemplateExceptionTest extends PHPUnit_Framework_TestCase
  11. {
  12. public function testInstance()
  13. {
  14. $e = new Mustache_Exception_UnknownTemplateException('mario');
  15. $this->assertTrue($e instanceof InvalidArgumentException);
  16. $this->assertTrue($e instanceof Mustache_Exception);
  17. }
  18. public function testMessage()
  19. {
  20. $e = new Mustache_Exception_UnknownTemplateException('luigi');
  21. $this->assertEquals('Unknown template: luigi', $e->getMessage());
  22. }
  23. public function testGetTemplateName()
  24. {
  25. $e = new Mustache_Exception_UnknownTemplateException('yoshi');
  26. $this->assertEquals('yoshi', $e->getTemplateName());
  27. }
  28. public function testPrevious()
  29. {
  30. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  31. $this->markTestSkipped('Exception chaining requires at least PHP 5.3');
  32. }
  33. $previous = new Exception();
  34. $e = new Mustache_Exception_UnknownTemplateException('foo', $previous);
  35. $this->assertSame($previous, $e->getPrevious());
  36. }
  37. }