diff options
| author | Chris Smith <toonarmy@phpbb.com> | 2008-11-23 03:41:54 +0000 |
|---|---|---|
| committer | Chris Smith <toonarmy@phpbb.com> | 2008-11-23 03:41:54 +0000 |
| commit | ff22d7a3687791fb4659f4808b4425a78d8bfc71 (patch) | |
| tree | 3a107fe01177dc18dfb2931c5818882986058ce3 /tests/template/template.php | |
| parent | f4c079a62befe2e523bf66fa74343ca37548763a (diff) | |
| download | forums-ff22d7a3687791fb4659f4808b4425a78d8bfc71.tar forums-ff22d7a3687791fb4659f4808b4425a78d8bfc71.tar.gz forums-ff22d7a3687791fb4659f4808b4425a78d8bfc71.tar.bz2 forums-ff22d7a3687791fb4659f4808b4425a78d8bfc71.tar.xz forums-ff22d7a3687791fb4659f4808b4425a78d8bfc71.zip | |
Refactor and fix :)
git-svn-id: file:///svn/phpbb/trunk@9093 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'tests/template/template.php')
| -rw-r--r-- | tests/template/template.php | 54 |
1 files changed, 19 insertions, 35 deletions
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 |
