diff options
| author | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-07-01 11:58:16 -0500 |
|---|---|---|
| committer | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-07-01 11:58:16 -0500 |
| commit | 8c75d1c1bc494220bed313e542902cdc22c5336f (patch) | |
| tree | e58989d5ab61f8cf1f5fa4427f4a6e28b4839285 /tests/template/template_test_case.php | |
| parent | ddaccaf63e8ae7ff5bd13b187fa40f3d089f02f0 (diff) | |
| download | forums-8c75d1c1bc494220bed313e542902cdc22c5336f.tar forums-8c75d1c1bc494220bed313e542902cdc22c5336f.tar.gz forums-8c75d1c1bc494220bed313e542902cdc22c5336f.tar.bz2 forums-8c75d1c1bc494220bed313e542902cdc22c5336f.tar.xz forums-8c75d1c1bc494220bed313e542902cdc22c5336f.zip | |
[feature/twig] Fix template_test.php
Various tests were broken completely, and some things such as whitespace
changed with Twig
PHPBB3-11598
Diffstat (limited to 'tests/template/template_test_case.php')
| -rw-r--r-- | tests/template/template_test_case.php | 24 |
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"); } } |
