1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-25 04:23:38 +01:00

[feature/template-events] Add a universal template event test.

Also drop the irrelevant includejs code and add a simple
template event test. The simple test is not working yet however
due to the template engine not correctly tracking which template
it is rendering.

PHPBB3-9550
This commit is contained in:
Oleg Pudeyev 2012-05-11 13:39:38 -04:00
parent 09b4cf2f4c
commit 667f8d581f
5 changed files with 33 additions and 21 deletions

View File

@ -0,0 +1 @@
Universal in trivial extension.

View File

@ -0,0 +1 @@
Simple in trivial extension.

View File

@ -11,31 +11,30 @@ require_once dirname(__FILE__) . '/template_test_case.php';
class phpbb_template_template_events_test extends phpbb_template_template_test_case
{
public function test_includejs_compilation()
public function test_simple_event()
{
// Reset the engine state
$this->setup_engine();
// Prepare correct result
$dir = dirname(__FILE__);
$files = array(
$dir . '/templates/child_only.html',
$dir . '/parent_templates/parent_only.html',
$dir . '/templates/parent_and_child.html'
);
$contents = '';
foreach ($files as $file)
{
if (file_exists($file))
{
$contents .= file_get_contents($file);
}
}
$contents = trim($contents);
$contents = "Simple in trivial extension.";
// Run test
$cache_file = $this->template->cachepath . 'events.html.php';
$this->run_template('events.html', array(), array(), array(), $contents, $cache_file);
$cache_file = $this->template->cachepath . 'event_simple.html.php';
$this->run_template('event_simple.html', array(), array(), array(), $contents, $cache_file);
}
public function test_universal_event()
{
// Reset the engine state
$this->setup_engine();
// Prepare correct result
$contents = "Universal in trivial extension.";
// Run test
$cache_file = $this->template->cachepath . 'event_universal.html.php';
$this->run_template('event_universal.html', array(), array(), array(), $contents, $cache_file);
}
protected function setup_engine(array $new_config = array())
@ -46,11 +45,20 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
$config = new phpbb_config(array_merge($defaults, $new_config));
$this->template_path = dirname(__FILE__) . '/templates';
$this->parent_template_path = dirname(__FILE__) . '/parent_templates';
$this->style_resource_locator = new phpbb_style_resource_locator();
$this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
array(
'trivial' => array(
'ext_name' => 'trivial',
'ext_active' => true,
'ext_path' => 'ext/trivial/',
),
)
);
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->extension_manager);
$this->style_provider = new phpbb_style_path_provider();
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator);
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), '');
$this->style->set_custom_style('tests', array($this->template_path), '');
}
}

View File

@ -0,0 +1 @@
<!-- EVENT simple -->

View File

@ -0,0 +1 @@
<!-- EVENT universal -->