Test missing files

git-svn-id: file:///svn/phpbb/trunk@9117 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Chris Smith 2008-11-25 00:42:32 +00:00
parent c95f0c7935
commit 7b5dc8f3c5

View file

@ -21,18 +21,16 @@ require_once '../phpBB/includes/template.php';
class phpbb_template_template_test extends phpbb_test_case class phpbb_template_template_test extends phpbb_test_case
{ {
private $template; private $template;
private $template_path;
// Keep the contents of the cache for debugging? // Keep the contents of the cache for debugging?
const PRESERVE_CACHE = true; const PRESERVE_CACHE = false;
private function display($handle) private function display($handle)
{ {
ob_start(); ob_start();
$this->assertTrue($this->template->display($handle, false)); $this->assertTrue($this->template->display($handle, false));
$contents = self::trim_template_result(ob_get_contents()); return self::trim_template_result(ob_get_clean());
ob_end_clean();
return $contents;
} }
private static function trim_template_result($result) private static function trim_template_result($result)
@ -42,8 +40,9 @@ class phpbb_template_template_test extends phpbb_test_case
private function setup_engine() private function setup_engine()
{ {
$this->template_path = dirname(__FILE__) . '/templates';
$this->template = new template; $this->template = new template;
$this->template->set_custom_template(dirname(__FILE__) . '/templates/', 'tests'); $this->template->set_custom_template($this->template_path, 'tests');
} }
protected function setUp() protected function setUp()
@ -252,6 +251,17 @@ class phpbb_template_template_test extends phpbb_test_case
); );
} }
public function test_missing()
{
$filename = 'file_not_found.html';
$this->template->set_filenames(array('test' => $filename));
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
$this->setExpectedTriggerError(E_USER_ERROR, sprintf('template->_tpl_load_file(): File %s does not exist or is empty', realpath($this->template_path) . '/' . $filename));
$this->display('test');
}
private function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file) private function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file)
{ {
$this->template->set_filenames(array('test' => $file)); $this->template->set_filenames(array('test' => $file));