aboutsummaryrefslogtreecommitdiffstats
path: root/tests/template/template_test_case.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/template/template_test_case.php')
-rw-r--r--tests/template/template_test_case.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 23ee8aae04..0a12dff9f4 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -16,6 +16,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected $template_path;
protected $style_resource_locator;
protected $style_provider;
+ protected $user;
protected $test_path = 'tests/template';
@@ -59,16 +60,17 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected function setup_engine(array $new_config = array())
{
- global $phpbb_root_path, $phpEx, $user;
+ global $phpbb_root_path, $phpEx;
$defaults = $this->config_defaults();
$config = new phpbb_config(array_merge($defaults, $new_config));
+ $this->user = new phpbb_user;
$this->template_path = $this->test_path . '/templates';
$this->style_resource_locator = new phpbb_style_resource_locator();
$this->style_provider = new phpbb_style_path_provider();
- $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
- $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
+ $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, new phpbb_template_context());
+ $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, $this->style_provider, $this->template);
$this->style->set_custom_style('tests', $this->template_path, array(), '');
}
@@ -82,10 +84,10 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected function tearDown()
{
- //$this->template->clear_cache();
+ $this->template->clear_cache();
}
- protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected)
+ protected function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $lang_vars = array())
{
$this->template->set_filenames(array('test' => $file));
$this->template->assign_vars($vars);
@@ -103,13 +105,13 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->template->destroy_block_vars($block);
}
- try
+ foreach ($lang_vars as $name => $value)
{
- $this->assertEquals($expected, $this->display('test'), "Testing $file");
- }
- catch (ErrorException $e)
- {
- throw $e;
+ $this->user->lang[$name] = $value;
}
+
+ $expected = str_replace(array("\n", "\r", "\t"), '', $expected);
+ $output = str_replace(array("\n", "\r", "\t"), '', $this->display('test'));
+ $this->assertEquals($expected, $output, "Testing $file");
}
}