From d29514f3e795374a653d3b9fa96c80dbefff449f Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 24 Feb 2014 17:05:01 +0800 Subject: [ticket/12224] Add assign_block_vars_array() test. Add tests, also change return value to null. PHPBB3-12224 --- tests/template/template_test.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/template/template_test.php') diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 6e9b7d3ee9..aaf55fd15c 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -562,6 +562,40 @@ EOT $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); } + public function assign_block_vars_array_data() + { + return array( + array( + array( + 'outer' => array( + array('VARIABLE' => 'Test assigning block vars array loop 0:'), + array('VARIABLE' => 'Test assigning block vars array loop 1:'), + ), + 'outer.middle' => array( + array('VARIABLE' => '1st iteration',), + array('VARIABLE' => '2nd iteration',), + array('VARIABLE' => '3rd iteration',), + ), + ) + ) + ); + } + + /** + * @dataProvider assign_block_vars_array_data + */ + public function test_assign_block_vars_array($block_data) + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + foreach ($block_data as $blockname => $block_vars_array) + { + $this->template->assign_block_vars_array($blockname, $block_vars_array); + } + + $this->assertEquals("outer - 0 - Test assigning block vars array loop 0:outer - 1 - Test assigning block vars array loop 1:middle - 0 - 1st iterationmiddle - 1 - 2nd iterationmiddle - 2 - 3rd iteration", $this->display('test'), 'Ensuring assigning block vars array to template is working correctly'); + } + /** * @expectedException Twig_Error_Syntax */ -- cgit v1.2.1