diff options
-rw-r--r-- | tests/security/redirect.php | 15 | ||||
-rw-r--r-- | tests/template/template.php | 54 | ||||
-rw-r--r-- | tests/template/templates/include.html | 1 |
3 files changed, 27 insertions, 43 deletions
diff --git a/tests/security/redirect.php b/tests/security/redirect.php index 2474d62355..0cf67b7aef 100644 --- a/tests/security/redirect.php +++ b/tests/security/redirect.php @@ -19,14 +19,6 @@ define('PHP_EXT', 'php'); require_once '../phpBB/includes/functions.php'; require_once '../phpBB/includes/session.php'; -if (!isset($config)) -{ - $config = array(); -} -$config += array( - 'force_server_vars' => 0, -); - class phpbb_security_redirect_test extends PHPUnit_Extensions_OutputTestCase { protected $error_triggered = false; @@ -44,6 +36,13 @@ class phpbb_security_redirect_test extends PHPUnit_Extensions_OutputTestCase ); } + protected function setUp() + { + $GLOBALS['config'] = array( + 'force_server_vars' => 0, + ); + } + /** * Own error handler to catch trigger_error() calls within phpBB */ diff --git a/tests/template/template.php b/tests/template/template.php index e9fd583ad8..3e0143f599 100644 --- a/tests/template/template.php +++ b/tests/template/template.php @@ -18,19 +18,9 @@ require_once '../phpBB/includes/constants.php'; require_once '../phpBB/includes/functions.php'; require_once '../phpBB/includes/template.php'; -if (!isset($config)) -{ - $config = array(); -} -$config += array( - 'load_tplcompile' => true -); - class phpbb_template_template_test extends PHPUnit_Framework_TestCase { private $template; - private static $ran_non_cached = false; - private function display($handle) { ob_start(); @@ -41,18 +31,10 @@ class phpbb_template_template_test extends PHPUnit_Framework_TestCase return $contents; } - private function setup_engine($clear_cache = false) + private function setup_engine() { $this->template = new template; $this->template->set_custom_template(dirname(__FILE__) . '/templates/', 'tests'); - - if ($clear_cache) - { - foreach (glob($this->template->cachepath . '*') as $file) - { - unlink($file); - } - } } protected function setUp() @@ -64,6 +46,15 @@ class phpbb_template_template_test extends PHPUnit_Framework_TestCase { $this->markTestSkipped("Template cache directory is not writable."); } + + foreach (glob($this->template->cachepath . '*') as $file) + { + unlink($file); + } + + $GLOBALS['config'] = array( + 'load_tplcompile' => true + ); } /** @@ -158,9 +149,12 @@ class phpbb_template_template_test extends PHPUnit_Framework_TestCase /** * @dataProvider template_data */ - public function test_template_no_cache($file, array $vars, array $block_vars, $expected) + public function test_template($file, array $vars, array $block_vars, $expected) { - $this->setup_engine(true); + $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . PHP_EXT; + + $this->assertFileNotExists($cache_file); + $this->template->set_filenames(array('test' => $file)); $this->template->assign_vars($vars); @@ -173,22 +167,11 @@ class phpbb_template_template_test extends PHPUnit_Framework_TestCase } $this->assertEquals($expected, $this->display('test'), "Testing $file"); + $this->assertFileExists($cache_file); - self::$ran_non_cached = true; - } - - /** - * @dataProvider template_data - */ - public function test_template($file, array $vars, array $block_vars, $expected) - { - if (!self::$ran_non_cached) - { - $this->fail('Non cached tests failed to run first'); - return; - } - + // Reset the engine state $this->setup_engine(); + $this->template->set_filenames(array('test' => $file)); $this->template->assign_vars($vars); @@ -201,6 +184,7 @@ class phpbb_template_template_test extends PHPUnit_Framework_TestCase } $this->assertEquals($expected, $this->display('test'), "Testing $file"); + $this->assertFileExists($cache_file); } } ?>
\ No newline at end of file diff --git a/tests/template/templates/include.html b/tests/template/templates/include.html new file mode 100644 index 0000000000..730d713d65 --- /dev/null +++ b/tests/template/templates/include.html @@ -0,0 +1 @@ +<!-- INCLUDE variable.html --> |