aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2011-07-10 00:35:07 +0200
committerIgor Wiedler <igor@wiedler.ch>2011-07-10 00:35:07 +0200
commitae53623230a45eeedf50cc3f6220164d8cd256c3 (patch)
tree130080560cc500d1da9b1e83f05c29d29a688e64 /tests
parentee0bba3ab65f68a24942a650b9414b8f2ad700b4 (diff)
downloadforums-ae53623230a45eeedf50cc3f6220164d8cd256c3.tar
forums-ae53623230a45eeedf50cc3f6220164d8cd256c3.tar.gz
forums-ae53623230a45eeedf50cc3f6220164d8cd256c3.tar.bz2
forums-ae53623230a45eeedf50cc3f6220164d8cd256c3.tar.xz
forums-ae53623230a45eeedf50cc3f6220164d8cd256c3.zip
[feature/template-engine] Refactor $config dependency out of the filter
The template stream filter no longer depends on the $config global. Instead it uses a 'allow_php' param that is passed via stream_bucket_append's last argument. Tests also adjusted. PHPBB3-9726
Diffstat (limited to 'tests')
-rw-r--r--tests/template/includephp_test.php8
-rw-r--r--tests/template/subdir/includephp_from_subdir_test.php4
-rw-r--r--tests/template/template_compile_test.php2
-rw-r--r--tests/template/template_test.php4
-rw-r--r--tests/template/template_test_case.php16
5 files changed, 15 insertions, 19 deletions
diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php
index 45dc8dc39e..64240e1be8 100644
--- a/tests/template/includephp_test.php
+++ b/tests/template/includephp_test.php
@@ -13,7 +13,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
public function test_includephp_relative()
{
- $GLOBALS['config']['tpl_allow_php'] = true;
+ $this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_relative.html.php';
@@ -21,8 +21,6 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
-
- $GLOBALS['config']['tpl_allow_php'] = false;
}
public function test_includephp_absolute()
@@ -36,7 +34,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
fputs($fp, $template_text);
fclose($fp);
- $GLOBALS['config']['tpl_allow_php'] = true;
+ $this->setup_engine(array('tpl_allow_php' => true));
$this->template->set_custom_template($cache_dir, 'tests');
$cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
@@ -45,7 +43,5 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => 'includephp_absolute.html'));
$this->assertEquals("Path is absolute.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
-
- $GLOBALS['config']['tpl_allow_php'] = false;
}
}
diff --git a/tests/template/subdir/includephp_from_subdir_test.php b/tests/template/subdir/includephp_from_subdir_test.php
index d6148c7032..3cc632485d 100644
--- a/tests/template/subdir/includephp_from_subdir_test.php
+++ b/tests/template/subdir/includephp_from_subdir_test.php
@@ -17,7 +17,7 @@ class phpbb_template_subdir_includephp_from_subdir_test extends phpbb_template_t
// board root.
public function test_includephp_relative()
{
- $GLOBALS['config']['tpl_allow_php'] = true;
+ $this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_relative.html.php';
@@ -25,7 +25,5 @@ class phpbb_template_subdir_includephp_from_subdir_test extends phpbb_template_t
$this->template->set_filenames(array('test' => 'includephp_relative.html'));
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
-
- $GLOBALS['config']['tpl_allow_php'] = false;
}
}
diff --git a/tests/template/template_compile_test.php b/tests/template/template_compile_test.php
index 769c7c2680..8c136c9985 100644
--- a/tests/template/template_compile_test.php
+++ b/tests/template/template_compile_test.php
@@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case
protected function setUp()
{
- $this->template_compile = new phpbb_template_compile();
+ $this->template_compile = new phpbb_template_compile(false);
$this->template_path = dirname(__FILE__) . '/templates';
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 71cf9d38f3..df3f927c22 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -328,15 +328,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
public function test_php()
{
- $GLOBALS['config']['tpl_allow_php'] = true;
+ $this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'php.html.php';
$this->assertFileNotExists($cache_file);
$this->run_template('php.html', array(), array(), array(), 'test', $cache_file);
-
- $GLOBALS['config']['tpl_allow_php'] = false;
}
public static function alter_block_array_data()
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index cab1aa3d4f..ed5afdc643 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -29,9 +29,16 @@ class phpbb_template_template_test_case extends phpbb_test_case
return str_replace("\n\n", "\n", implode("\n", array_map('trim', explode("\n", trim($result)))));
}
- protected function setup_engine()
+ protected function setup_engine(array $new_config = array())
{
- global $phpbb_root_path, $phpEx, $config, $user;
+ global $phpbb_root_path, $phpEx, $user;
+
+ $defaults = array(
+ 'load_tplcompile' => true,
+ 'tpl_allow_php' => false,
+ );
+
+ $config = new phpbb_config(array_merge($defaults, $new_config));
$this->template_path = dirname(__FILE__) . '/templates';
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user);
@@ -53,10 +60,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
unlink($file);
}
- $GLOBALS['config'] = array(
- 'load_tplcompile' => true,
- 'tpl_allow_php' => false,
- );
+ $this->setup_engine();
}
protected function tearDown()