2012-04-03 23:52:00 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PHPParser_Tests_TemplateLoaderTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testLoadWithoutSuffix() {
|
|
|
|
$templateLoader = new PHPParser_TemplateLoader(
|
2012-04-25 20:04:46 +02:00
|
|
|
new PHPParser_Parser(new PHPParser_Lexer),
|
|
|
|
dirname(__FILE__)
|
2012-04-03 23:52:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// load this file as a template, as we don't really care about the contents
|
|
|
|
$template = $templateLoader->load('TemplateLoaderTest.php');
|
|
|
|
$this->assertInstanceOf('PHPParser_Template', $template);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLoadWithSuffix() {
|
|
|
|
$templateLoader = new PHPParser_TemplateLoader(
|
2012-04-25 20:04:46 +02:00
|
|
|
new PHPParser_Parser(new PHPParser_Lexer),
|
|
|
|
dirname(__FILE__), '.php'
|
2012-04-03 23:52:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// load this file as a template, as we don't really care about the contents
|
|
|
|
$template = $templateLoader->load('TemplateLoaderTest');
|
|
|
|
$this->assertInstanceOf('PHPParser_Template', $template);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testNonexistentBaseDirectoryError() {
|
|
|
|
new PHPParser_TemplateLoader(
|
2012-04-25 20:04:46 +02:00
|
|
|
new PHPParser_Parser(new PHPParser_Lexer),
|
|
|
|
dirname(__FILE__) . '/someDirectoryThatDoesNotExist'
|
2012-04-03 23:52:00 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function testNonexistentFileError() {
|
|
|
|
$templateLoader = new PHPParser_TemplateLoader(
|
2012-04-25 20:04:46 +02:00
|
|
|
new PHPParser_Parser(new PHPParser_Lexer),
|
|
|
|
dirname(__FILE__)
|
2012-04-03 23:52:00 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$templateLoader->load('SomeTemplateThatDoesNotExist');
|
|
|
|
}
|
|
|
|
}
|