aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/template/invalid_constructs_test.php32
-rw-r--r--tests/template/templates/invalid/include_nonexistent_file.html1
-rw-r--r--tests/template/templates/invalid/output/include_nonexistent_file.html1
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/template/invalid_constructs_test.php b/tests/template/invalid_constructs_test.php
index 8d54df5014..2430b5b9b1 100644
--- a/tests/template/invalid_constructs_test.php
+++ b/tests/template/invalid_constructs_test.php
@@ -37,6 +37,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
);
}
+ public function template_data_error()
+ {
+ return array(
+ array(
+ 'Include a nonexistent file',
+ 'invalid/include_nonexistent_file.html',
+ array(),
+ array(),
+ array(),
+ E_USER_ERROR,
+ 'invalid/output/include_nonexistent_file.html',
+ ),
+ );
+ }
+
/**
* @dataProvider template_data
*/
@@ -52,4 +67,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$expected = trim($expected);
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
}
+
+ /**
+ * @dataProvider template_data_error
+ */
+ public function test_template_error($description, $file, $vars, $block_vars, $destroy, $error, $expected)
+ {
+ $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
+
+ $this->assertFileNotExists($cache_file);
+
+ $expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected);
+ // apparently the template engine does not put
+ // the trailing newline into compiled templates
+ $expected = trim($expected);
+ $this->setExpectedTriggerError($error, $expected);
+ $this->run_template($file, $vars, $block_vars, $destroy, '', $cache_file);
+ }
}
diff --git a/tests/template/templates/invalid/include_nonexistent_file.html b/tests/template/templates/invalid/include_nonexistent_file.html
new file mode 100644
index 0000000000..617d2fdaaa
--- /dev/null
+++ b/tests/template/templates/invalid/include_nonexistent_file.html
@@ -0,0 +1 @@
+<!-- INCLUDE nonexistent.html -->
diff --git a/tests/template/templates/invalid/output/include_nonexistent_file.html b/tests/template/templates/invalid/output/include_nonexistent_file.html
new file mode 100644
index 0000000000..8a118d2713
--- /dev/null
+++ b/tests/template/templates/invalid/output/include_nonexistent_file.html
@@ -0,0 +1 @@
+style resource locator: File for handle nonexistent.html does not exist. Could not find: