1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

- Make a start on completing the phpDoc comments for the template engine

- Tidy template engine code, mainly PHP5 stuff, made some methods void instead of just returning true
- Add tests for the remaining untested compilation code


git-svn-id: file:///svn/phpbb/trunk@9115 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Chris Smith
2008-11-24 21:59:33 +00:00
parent 9954d9c29f
commit 332521a369
8 changed files with 192 additions and 39 deletions

View File

@@ -21,6 +21,9 @@ require_once '../phpBB/includes/template.php';
class phpbb_template_template_test extends phpbb_test_case
{
private $template;
const PRESERVE_CACHE = true;
private function display($handle)
{
ob_start();
@@ -77,6 +80,13 @@ class phpbb_template_template_test extends phpbb_test_case
'', // Expected result
),
*/
array(
'basic.html',
array(),
array(),
array(),
"pass\npass\n<!-- DUMMY var -->",
),
array(
'variable.html',
array('VARIABLE' => 'value'),
@@ -129,10 +139,17 @@ class phpbb_template_template_test extends phpbb_test_case
array(
'loop.html',
array(),
array('loop' => array(array(), array())),
array('loop' => array(array(), array()), 'loop.block' => array(array())),
array(),
"loop\nloop\nloop\nloop",
),
array(
'loop.html',
array(),
array('loop' => array(array(), array()), 'loop.block' => array(array()), 'block' => array(array(), array())),
array(),
"loop\nloop\nloop\nloop\n\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
),
array(
'loop_vars.html',
array(),
@@ -164,9 +181,9 @@ class phpbb_template_template_test extends phpbb_test_case
array(
'define.html',
array(),
array('loop' => array(array(), array(), array(), array(), array(), array(), array())),
array(),
array(),
"xyz\nabc",
"xyz\nabc\n\n00\n11\n22\n33\n44\n55\n66\n\n144\n144",
),
array(
'expressions.html',
@@ -210,6 +227,27 @@ class phpbb_template_template_test extends phpbb_test_case
array(),
"on\non\non\non\noff\noff\noff\noff\non\non\non\non\n\noff\noff\noff\non\non\non\noff\noff\noff\non\non\non",
),
array(
'lang.html',
array(),
array(),
array(),
"{ VARIABLE }\n{ VARIABLE }",
),
array(
'lang.html',
array('L_VARIABLE' => "Value'"),
array(),
array(),
"Value'\nValue\'",
),
array(
'lang.html',
array('LA_VARIABLE' => "Value'"),
array(),
array(),
"{ VARIABLE }\nValue'",
),
);
}
@@ -233,6 +271,12 @@ class phpbb_template_template_test extends phpbb_test_case
$this->assertEquals($expected, $this->display('test'), "Testing $file");
$this->assertFileExists($cache_file);
// For debugging
if (self::PRESERVE_CACHE)
{
copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file));
}
}
/**

View File

@@ -16,3 +16,5 @@ fail
<!-- BEGINELSE -->
pass
<!-- END empty -->
<!-- DUMMY var -->

View File

@@ -9,3 +9,27 @@
<!-- UNDEFINE $VALUE -->
{$VALUE}
<!-- DEFINE $VALUE -->
<!-- BEGIN loop -->
<!-- DEFINE loop.$VALUE = loop.S_ROW_NUM -->
{loop.$VALUE}
<!-- UNDEFINE $VALUE -->
{loop.$VALUE}
<!-- UNDEFINE loop.$VALUE -->
{loop.$VALUE}
<!-- END loop -->
<!-- DEFINE test.deep.defines.$VALUE = 12 * 12 -->
{test.deep.defines.$VALUE}
<!-- UNDEFINE $VALUE -->
{test.deep.defines.$VALUE}
<!-- UNDEFINE test.deep.defines.$VALUE -->
{test.deep.defines.$VALUE}

View File

@@ -10,6 +10,8 @@
<!-- IF 32 is div by 16 -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 10 is not even -->fail<!-- ELSE -->pass<!-- ENDIF -->
<!-- IF 24 == 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 24 eq 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
@@ -84,5 +86,3 @@
<!-- IF 6 % 4 == 2 -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 24 mod 12 == 0 -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF not (43 > 53) -->pass<!-- ELSE -->fail<!-- ENDIF -->

View File

@@ -0,0 +1,3 @@
{L_VARIABLE}
{LA_VARIABLE}

View File

@@ -13,3 +13,11 @@ noloop
<!-- IF .loop == 2 -->
loop
<!-- ENDIF -->
<!-- BEGIN loop -->
<!-- BEGIN !block -->
loop#{loop.S_ROW_NUM}-block#{block.S_ROW_NUM}
<!-- END !block -->
<!-- END loop -->