aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/mock/filesystem_extension_manager.php31
-rw-r--r--tests/template/template_events_test.php22
2 files changed, 40 insertions, 13 deletions
diff --git a/tests/mock/filesystem_extension_manager.php b/tests/mock/filesystem_extension_manager.php
new file mode 100644
index 0000000000..3332e2b82d
--- /dev/null
+++ b/tests/mock/filesystem_extension_manager.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_mock_filesystem_extension_manager extends phpbb_mock_extension_manager
+{
+ public function __construct($phpbb_root_path)
+ {
+ $extensions = array();
+ $iterator = new DirectoryIterator($phpbb_root_path . 'ext/');
+ foreach ($iterator as $fileinfo)
+ {
+ if ($fileinfo->isDir() && substr($fileinfo->getFilename(), 0, 1) != '.')
+ {
+ $name = $fileinfo->getFilename();
+ $extension = array(
+ 'ext_name' => $name,
+ 'ext_active' => true,
+ 'ext_path' => 'ext/' . $name . '/',
+ );
+ $extensions[$name] = $extension;
+ }
+ }
+ parent::__construct($phpbb_root_path, $extensions);
+ }
+}
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 22aa2e88d5..9652f341c3 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -17,6 +17,7 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
/*
array(
'', // File
+ '', // Dataset
array(), // vars
array(), // block vars
array(), // destroy
@@ -25,6 +26,7 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
*/
array(
'Simple template event',
+ 'ext_trivial',
'event_simple.html',
array(),
array(),
@@ -33,6 +35,7 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
),
array(
'Universal template event ("all" style)',
+ 'ext_trivial',
'event_universal.html',
array(),
array(),
@@ -45,34 +48,27 @@ class phpbb_template_template_events_test extends phpbb_template_template_test_c
/**
* @dataProvider template_data
*/
- public function test_event($desc, $file, array $vars, array $block_vars, array $destroy, $expected)
+ public function test_event($desc, $dataset, $file, array $vars, array $block_vars, array $destroy, $expected)
{
// Reset the engine state
- $this->setup_engine();
+ $this->setup_engine_with_dataset($dataset);
// Run test
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
}
- protected function setup_engine(array $new_config = array())
+ protected function setup_engine_with_dataset($dataset, array $new_config = array())
{
global $phpbb_root_path, $phpEx, $user;
$defaults = $this->config_defaults();
$config = new phpbb_config(array_merge($defaults, $new_config));
- $this->template_path = dirname(__FILE__) . '/datasets/ext_trivial/templates';
+ $this->template_path = dirname(__FILE__) . "/datasets/$dataset/templates";
$this->style_resource_locator = new phpbb_style_resource_locator();
- $this->extension_manager = new phpbb_mock_extension_manager(
- dirname(__FILE__) . '/datasets/ext_trivial/',
- array(
- 'trivial' => array(
- 'ext_name' => 'trivial',
- 'ext_active' => true,
- 'ext_path' => 'ext/trivial/',
- ),
- )
+ $this->extension_manager = new phpbb_mock_filesystem_extension_manager(
+ dirname(__FILE__) . "/datasets/$dataset/"
);
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
$this->style_provider = new phpbb_style_path_provider();