mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02: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:
@@ -0,0 +1 @@
|
|||||||
|
Universal in trivial extension.
|
@@ -0,0 +1 @@
|
|||||||
|
Simple in trivial extension.
|
@@ -11,31 +11,30 @@ require_once dirname(__FILE__) . '/template_test_case.php';
|
|||||||
|
|
||||||
class phpbb_template_template_events_test extends phpbb_template_template_test_case
|
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
|
// Reset the engine state
|
||||||
$this->setup_engine();
|
$this->setup_engine();
|
||||||
|
|
||||||
// Prepare correct result
|
// Prepare correct result
|
||||||
$dir = dirname(__FILE__);
|
$contents = "Simple in trivial extension.";
|
||||||
$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);
|
|
||||||
|
|
||||||
// Run test
|
// Run test
|
||||||
$cache_file = $this->template->cachepath . 'events.html.php';
|
$cache_file = $this->template->cachepath . 'event_simple.html.php';
|
||||||
$this->run_template('events.html', array(), array(), array(), $contents, $cache_file);
|
$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())
|
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));
|
$config = new phpbb_config(array_merge($defaults, $new_config));
|
||||||
|
|
||||||
$this->template_path = dirname(__FILE__) . '/templates';
|
$this->template_path = dirname(__FILE__) . '/templates';
|
||||||
$this->parent_template_path = dirname(__FILE__) . '/parent_templates';
|
|
||||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
$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->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 = 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), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
tests/template/templates/event_simple.html
Normal file
1
tests/template/templates/event_simple.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<!-- EVENT simple -->
|
1
tests/template/templates/event_universal.html
Normal file
1
tests/template/templates/event_universal.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<!-- EVENT universal -->
|
Reference in New Issue
Block a user