From c40642b8274c9afa39af6b34cd831bed8b960b83 Mon Sep 17 00:00:00 2001 From: javiexin Date: Sat, 7 Jan 2017 19:57:22 +0100 Subject: [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 --- tests/template/template_test.php | 121 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) (limited to 'tests/template/template_test.php') 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', + << 'changed'), + array('S_ROW_NUM' => 2), + 'change', + << 'before'), + false, + 'insert', + << 'after'), + true, + 'insert', + << 'pos #1'), + 1, + 'insert', + << 'changed'), 0, 'change', << 'changed'), + array('S_ROW_NUM' => 1), + 'change', + << Date: Sat, 7 Jan 2017 20:12:32 +0100 Subject: [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 more tests. PHPBB3-14943 --- tests/template/template_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/template/template_test.php') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 92de5d3fac..7231f71511 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -718,6 +718,16 @@ EOT $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); + + $this->template->alter_block_array('outer.middle', array()); + + $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|4]middle - 1[middle|4]middle - 2[middle|4]middle - 3[middle|4]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion at middle level'); + + $this->template->alter_block_array('outer.middle', array('VARIABLE' => 'test'), 2, 'change'); + + $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|4]middle - 1[middle|4]middle - 2 - test[middle|4]middle - 3[middle|4]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification at middle level'); } public function assign_block_vars_array_data() -- cgit v1.2.1