TemplateLoaderTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class PHPParser_Tests_TemplateLoaderTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testLoadWithoutSuffix() {
  5. $templateLoader = new PHPParser_TemplateLoader(
  6. new PHPParser_Parser(new PHPParser_Lexer),
  7. dirname(__FILE__)
  8. );
  9. // load this file as a template, as we don't really care about the contents
  10. $template = $templateLoader->load('TemplateLoaderTest.php');
  11. $this->assertInstanceOf('PHPParser_Template', $template);
  12. }
  13. public function testLoadWithSuffix() {
  14. $templateLoader = new PHPParser_TemplateLoader(
  15. new PHPParser_Parser(new PHPParser_Lexer),
  16. dirname(__FILE__), '.php'
  17. );
  18. // load this file as a template, as we don't really care about the contents
  19. $template = $templateLoader->load('TemplateLoaderTest');
  20. $this->assertInstanceOf('PHPParser_Template', $template);
  21. }
  22. /**
  23. * @expectedException InvalidArgumentException
  24. */
  25. public function testNonexistentBaseDirectoryError() {
  26. new PHPParser_TemplateLoader(
  27. new PHPParser_Parser(new PHPParser_Lexer),
  28. dirname(__FILE__) . '/someDirectoryThatDoesNotExist'
  29. );
  30. }
  31. /**
  32. * @expectedException InvalidArgumentException
  33. */
  34. public function testNonexistentFileError() {
  35. $templateLoader = new PHPParser_TemplateLoader(
  36. new PHPParser_Parser(new PHPParser_Lexer),
  37. dirname(__FILE__)
  38. );
  39. $templateLoader->load('SomeTemplateThatDoesNotExist');
  40. }
  41. }