diff options
author | Chris Smith <toonarmy@phpbb.com> | 2008-11-24 21:59:33 +0000 |
---|---|---|
committer | Chris Smith <toonarmy@phpbb.com> | 2008-11-24 21:59:33 +0000 |
commit | 332521a3696df8e1504933bee5658d005549f3b4 (patch) | |
tree | 28bb6252017cb568046517b4bfd4b9a9904aee0f /tests/template | |
parent | 9954d9c29f551acc0ad88bf4ecc806c51c764a6e (diff) | |
download | forums-332521a3696df8e1504933bee5658d005549f3b4.tar forums-332521a3696df8e1504933bee5658d005549f3b4.tar.gz forums-332521a3696df8e1504933bee5658d005549f3b4.tar.bz2 forums-332521a3696df8e1504933bee5658d005549f3b4.tar.xz forums-332521a3696df8e1504933bee5658d005549f3b4.zip |
- 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
Diffstat (limited to 'tests/template')
-rw-r--r-- | tests/template/template.php | 50 | ||||
-rw-r--r-- | tests/template/templates/basic.html | 2 | ||||
-rw-r--r-- | tests/template/templates/define.html | 24 | ||||
-rw-r--r-- | tests/template/templates/expressions.html | 4 | ||||
-rw-r--r-- | tests/template/templates/lang.html | 3 | ||||
-rw-r--r-- | tests/template/templates/loop.html | 8 |
6 files changed, 86 insertions, 5 deletions
diff --git a/tests/template/template.php b/tests/template/template.php index 89de67a453..9558ea09f9 100644 --- a/tests/template/template.php +++ b/tests/template/template.php @@ -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(); @@ -78,6 +81,13 @@ class phpbb_template_template_test extends phpbb_test_case ), */ array( + 'basic.html', + array(), + array(), + array(), + "pass\npass\n<!-- DUMMY var -->", + ), + array( 'variable.html', array('VARIABLE' => 'value'), array(), @@ -129,11 +139,18 @@ 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(), array('loop' => array(array('VARIABLE' => 'x'))), @@ -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)); + } } /** diff --git a/tests/template/templates/basic.html b/tests/template/templates/basic.html index 1a3fd5a96a..c1dd690260 100644 --- a/tests/template/templates/basic.html +++ b/tests/template/templates/basic.html @@ -16,3 +16,5 @@ fail <!-- BEGINELSE --> pass <!-- END empty --> + +<!-- DUMMY var --> diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index 94741e53fc..b9a2219a02 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -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} diff --git a/tests/template/templates/expressions.html b/tests/template/templates/expressions.html index f0b38cc2ec..47a164e481 100644 --- a/tests/template/templates/expressions.html +++ b/tests/template/templates/expressions.html @@ -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 --> diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html new file mode 100644 index 0000000000..2b5ea1cafe --- /dev/null +++ b/tests/template/templates/lang.html @@ -0,0 +1,3 @@ +{L_VARIABLE} + +{LA_VARIABLE} diff --git a/tests/template/templates/loop.html b/tests/template/templates/loop.html index 3912635e9d..f1e1bf7e53 100644 --- a/tests/template/templates/loop.html +++ b/tests/template/templates/loop.html @@ -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 --> |