aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-05-10 03:36:58 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2012-05-10 03:36:58 -0400
commit56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7 (patch)
tree2656b3c67fd75efe74f23e7898a3edf2f5e7333f /tests
parent720d07c9b3942a103ceedc1996fb11e13c1bc2f0 (diff)
downloadforums-56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7.tar
forums-56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7.tar.gz
forums-56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7.tar.bz2
forums-56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7.tar.xz
forums-56b2b87423c9afd62312fd36b5c2f6fff2d1d8a7.zip
[ticket/10882] Add a test for including a nonexistent file.
PHPBB3-10882
Diffstat (limited to 'tests')
-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: