[ticket/14950] Add possibility to delete a template block

Adds a new mode to alter_block_array to allow for the deletion of
a certain block of template variables.  The selection method is the
same as for the other modes for alter_block_array.  The passed in
vararray is ignored, and an out of bounds index is considered an error.
Added tests for the new function, fixed.

PHPBB3-14950
This commit is contained in:
javiexin 2017-01-08 01:19:22 +01:00
parent 696724ac1b
commit 7f8dd6b007

View file

@ -636,9 +636,14 @@ EOT
$this->template->alter_block_array('outer', array(), 1, 'delete');
$expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]';
$expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|3]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at top level');
$this->template->alter_block_array('outer.middle', array(), 1, 'delete');
$expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Deleting by index at middle level');
$this->template->alter_block_array('outer', array(), 4, 'delete');
$expect = 'outer - 0 - one[outer|2]outer - 1 - three[outer|2]middle - 0 - 3A[middle|2]middle - 1 - 3C[middle|2]';