diff options
author | javiexin <javiexin@gmail.com> | 2017-01-07 19:57:22 +0100 |
---|---|---|
committer | javiexin <javiexin@gmail.com> | 2017-01-07 19:57:22 +0100 |
commit | c40642b8274c9afa39af6b34cd831bed8b960b83 (patch) | |
tree | 64d9da99ce1f74d8949017997471e3f46b0749f9 /tests/template/template_test.php | |
parent | 45ea013b111547ef684cc7c64dd91a6217935ab1 (diff) | |
download | forums-c40642b8274c9afa39af6b34cd831bed8b960b83.tar forums-c40642b8274c9afa39af6b34cd831bed8b960b83.tar.gz forums-c40642b8274c9afa39af6b34cd831bed8b960b83.tar.bz2 forums-c40642b8274c9afa39af6b34cd831bed8b960b83.tar.xz forums-c40642b8274c9afa39af6b34cd831bed8b960b83.zip |
[ticket/14943] Fix template loop access by index
Allows inserting elements in a loop specified as 'outer[3].inner'.
This was coded, but malfunctioning. Name incorrectly set on insert.
Added tests.
PHPBB3-14943
Diffstat (limited to 'tests/template/template_test.php')
-rw-r--r-- | tests/template/template_test.php | 121 |
1 files changed, 119 insertions, 2 deletions
diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0bbfe3848d..92de5d3fac 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -528,22 +528,139 @@ EOT ), array( 'outer', + array('VARIABLE' => 'changed'), + 0, + 'change', + <<<EOT +outer - 0 - changed +middle - 0 +middle - 1 +outer - 1 +middle - 0 +middle - 1 +outer - 2 +middle - 0 +middle - 1 +EOT +, + 'Test changing at 0 on top level block', + ), + array( + 'outer', + array('VARIABLE' => 'changed'), + array('S_ROW_NUM' => 2), + 'change', + <<<EOT +outer - 0 +middle - 0 +middle - 1 +outer - 1 +middle - 0 +middle - 1 +outer - 2 - changed +middle - 0 +middle - 1 +EOT +, + 'Test changing at KEY on top level block', + ), + array( + 'outer.middle', + array('VARIABLE' => 'before'), + false, + 'insert', + <<<EOT +outer - 0 +middle - 0 +middle - 1 +outer - 1 +middle - 0 +middle - 1 +outer - 2 +middle - 0 - before +middle - 1 +middle - 2 +EOT +, + 'Test inserting before on middle level block', + ), + array( + 'outer.middle', + array('VARIABLE' => 'after'), + true, + 'insert', + <<<EOT +outer - 0 +middle - 0 +middle - 1 +outer - 1 +middle - 0 +middle - 1 +outer - 2 +middle - 0 +middle - 1 +middle - 2 - after +EOT +, + 'Test inserting after on middle level block', + ), + array( + 'outer[1].middle', array('VARIABLE' => 'pos #1'), + 1, + 'insert', + <<<EOT +outer - 0 +middle - 0 +middle - 1 +outer - 1 +middle - 0 +middle - 1 - pos #1 +middle - 2 +outer - 2 +middle - 0 +middle - 1 +EOT +, + 'Test inserting at 1 on middle level block', + ), + array( + 'outer[].middle', + array('VARIABLE' => 'changed'), 0, 'change', <<<EOT -outer - 0 - pos #1 +outer - 0 middle - 0 middle - 1 outer - 1 middle - 0 middle - 1 outer - 2 +middle - 0 - changed +middle - 1 +EOT +, + 'Test changing at beginning of last top level block', + ), + array( + 'outer.middle', + array('VARIABLE' => 'changed'), + array('S_ROW_NUM' => 1), + 'change', + <<<EOT +outer - 0 middle - 0 middle - 1 +outer - 1 +middle - 0 +middle - 1 +outer - 2 +middle - 0 +middle - 1 - changed EOT , - 'Test inserting at 1 on top level block', + 'Test changing at beginning of last top level block', ), ); } |