mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[feature/twig] Fix template_test.php
Various tests were broken completely, and some things such as whitespace changed with Twig PHPBB3-11598
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user