1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-29 12:43:15 +01:00

[ticket/10081] Cleanup Template Tests.

There are no incomplete template tests anymore.

PHPBB3-10081
This commit is contained in:
Marek A. Ruszczynski 2011-03-07 18:26:46 +01:00
parent 21c5e6f149
commit 7147382e9e
3 changed files with 47 additions and 199 deletions

View File

@ -409,21 +409,16 @@ class phpbb_template_template_test extends phpbb_test_case
public function test_includephp()
{
$this->markTestIncomplete('Include PHP test file paths are broken');
global $phpEx;
$GLOBALS['config']['tpl_allow_php'] = true;
$cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT;
$cwd = getcwd();
chdir(dirname(__FILE__) . '/templates');
$cache_file = $this->template->cachepath . 'includephp.html.' . $phpEx;
$this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file);
$this->template->set_filenames(array('test' => 'includephp.html'));
$this->assertEquals('testing included php', $this->display('test'), "Testing $file");
chdir($cwd);
$this->assertEquals('testing included php', $this->display('test'), "Testing INCLUDEPHP");
$GLOBALS['config']['tpl_allow_php'] = false;
}
@ -437,17 +432,16 @@ class phpbb_template_template_test extends phpbb_test_case
false,
'insert',
<<<EOT
outer - 0/4 - before
outer - 1/4
middle - 0/2
middle - 1/2
outer - 2/4
middle - 0/3
middle - 1/3
middle - 2/3
outer - 3/4
middle - 0/2
middle - 1/2
outer - 0 - before
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0
middle - 1
outer - 3
middle - 0
middle - 1
EOT
,
'Test inserting before on top level block',
@ -458,17 +452,16 @@ EOT
true,
'insert',
<<<EOT
outer - 0/4
middle - 0/2
middle - 1/2
outer - 1/4
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/4
middle - 0/2
middle - 1/2
outer - 3/4 - after
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0
middle - 1
outer - 3 - after
EOT
,
'Test inserting after on top level block',
@ -479,17 +472,16 @@ EOT
1,
'insert',
<<<EOT
outer - 0/4
middle - 0/2
middle - 1/2
outer - 1/4 - pos #1
outer - 2/4
middle - 0/3
middle - 1/3
middle - 2/3
outer - 3/4
middle - 0/2
middle - 1/2
outer - 0
middle - 0
middle - 1
outer - 1 - pos #1
outer - 2
middle - 0
middle - 1
outer - 3
middle - 0
middle - 1
EOT
,
'Test inserting at 1 on top level block',
@ -500,171 +492,28 @@ EOT
0,
'change',
<<<EOT
outer - 0/3 - pos #1
middle - 0/2
middle - 1/2
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/2
middle - 1/2
outer - 0 - pos #1
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0
middle - 1
EOT
,
'Test inserting at 1 on top level block',
),
array(
'outer[0].middle',
array('VARIABLE' => 'before'),
false,
'insert',
<<<EOT
outer - 0/3
middle - 0/3 - before
middle - 1/3
middle - 2/3
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/2
middle - 1/2
EOT
,
'Test inserting before on nested block',
),
array(
'outer[0].middle',
array('VARIABLE' => 'after'),
true,
'insert',
<<<EOT
outer - 0/3
middle - 0/3
middle - 1/3
middle - 2/3 - after
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/2
middle - 1/2
EOT
,
'Test inserting after on nested block',
),
array(
'outer[0].middle',
array('VARIABLE' => 'pos #1'),
1,
'insert',
<<<EOT
outer - 0/3
middle - 0/3
middle - 1/3 - pos #1
middle - 2/3
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/2
middle - 1/2
EOT
,
'Test inserting at pos 1 on nested block',
),
array(
'outer[1].middle',
array('VARIABLE' => 'before'),
false,
'insert',
<<<EOT
outer - 0/3
middle - 0/2
middle - 1/2
outer - 1/3
middle - 0/4 - before
middle - 1/4
middle - 2/4
middle - 3/4
outer - 2/3
middle - 0/2
middle - 1/2
EOT
,
'Test inserting before on nested block (pos 1)',
),
array(
'outer[].middle',
array('VARIABLE' => 'before'),
false,
'insert',
<<<EOT
outer - 0/3
middle - 0/2
middle - 1/2
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/3 - before
middle - 1/3
middle - 2/3
EOT
,
'Test inserting before on nested block (end)',
),
array(
'outer.middle',
array('VARIABLE' => 'before'),
false,
'insert',
<<<EOT
outer - 0/3
middle - 0/2
middle - 1/2
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/3 - before
middle - 1/3
middle - 2/3
EOT
,
'Test inserting before on nested block (end)',
),
);
}
/*
<<<EOT
outer - 0/3
middle - 0/2
middle - 1/2
outer - 1/3
middle - 0/3
middle - 1/3
middle - 2/3
outer - 2/3
middle - 0/2
middle - 1/2
EOT
,
*/
/**
* @dataProvider alter_block_array_data
*/
public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
{
$this->markTestIncomplete('Alter Block Test is broken');
// $this->markTestIncomplete('Alter Block Test is broken');
$this->template->set_filenames(array('test' => 'loop_nested.html'));
@ -675,12 +524,11 @@ EOT
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer', array());
$this->template->assign_block_vars('outer.middle', array());
$this->template->assign_block_vars('outer.middle', array());
$this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->assertEquals("outer - 0\nmiddle - 0\nmiddle - 1\nouter - 1\nmiddle - 0\nmiddle - 1\nouter - 2\nmiddle - 0\nmiddle - 1", $this->display('test'), 'Ensuring template is built correctly before modification');
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
$this->assertEquals($expect, $this->display('test'), $description);

View File

@ -1 +1 @@
<!-- INCLUDEPHP ../templates/_dummy_include.php.inc -->
<!-- INCLUDEPHP ../tests/template/templates/_dummy_include.php.inc -->

View File

@ -1,8 +1,8 @@
<!-- BEGIN outer -->
{outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
outer - {outer.S_ROW_COUNT}<!-- IF outer.VARIABLE --> - {outer.VARIABLE}<!-- ENDIF -->
<!-- BEGIN middle -->
{middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
middle - {middle.S_ROW_COUNT}<!-- IF middle.VARIABLE --> - {middle.VARIABLE}<!-- ENDIF -->
<!-- END middle -->
<!-- END outer -->