From 3a00cb0c081efff55fd7b1c55c8990c8682e7b8d Mon Sep 17 00:00:00 2001 From: Mario Skouat Date: Sat, 23 Mar 2013 13:48:46 +0100 Subject: [PATCH 1/4] [ticket/10910] Allow setting size selects in build_cfg_template() PHPBB3-10910 --- phpBB/includes/functions_acp.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index b9210114ef..ca116372ba 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -363,7 +363,9 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) if ($tpl_type[0] == 'select') { - $tpl = ''; + $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; + + $tpl = ''; } else { From 9861cd21dd1e60943dbba7d5b2dc64c272ccd20d Mon Sep 17 00:00:00 2001 From: Mario Skouat Date: Sun, 31 Mar 2013 18:50:52 +0200 Subject: [PATCH 2/4] [ticket/10910] Add unit tests for select PHPBB3-10910 --- .../functions_acp/build_cfg_template_test.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index acf4da1bd6..d4bd80e4c2 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -234,4 +234,39 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); } + + public function build_cfg_template_select_data() + { + return array( + array( + array('select'), + 'key_name', + array('config_key_name' => '0'), + 'config_key_name', + array(), + '', + ), + array( + array('select', 8), + 'key_name', + array('config_key_name' => '1'), + 'config_key_name', + array(), + '', + ), + ); + } + + /** + * @dataProvider build_cfg_template_select_data + */ + public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected) + { + global $user, $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user->lang = new phpbb_mock_lang(); + + $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); + } } From 8c73c9658e70f8cbdf52a89899f4fc094586b229 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 22 Nov 2013 15:51:22 +0100 Subject: [PATCH 3/4] [ticket/10910] Fix unit tests PHPBB3-10910 --- .../functions_acp/build_cfg_template_test.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php index d4bd80e4c2..7f8db799c5 100644 --- a/tests/functions_acp/build_cfg_template_test.php +++ b/tests/functions_acp/build_cfg_template_test.php @@ -243,16 +243,16 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case 'key_name', array('config_key_name' => '0'), 'config_key_name', - array(), - '', + array('method' => 'select_helper'), + '', ), array( array('select', 8), 'key_name', array('config_key_name' => '1'), 'config_key_name', - array(), - '', + array('method' => 'select_helper'), + '', ), ); } @@ -262,11 +262,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case */ public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected) { - global $user, $phpbb_dispatcher; + global $module, $user, $phpbb_dispatcher; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user = new phpbb_mock_user(); $user->lang = new phpbb_mock_lang(); + $user->module = $this; + $module = $user; $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars)); } + + public function select_helper() + { + return build_select( + array( + '1' => 'First_Option', + '2' => 'Second_Option', + '3' => 'Third_Option', + ), + '2' + ); + } } From 2f4d15015e7a0e8d8f9a76b60c5c8c0091e399ca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 22 Nov 2013 15:51:56 +0100 Subject: [PATCH 4/4] [ticket/10910] Do not add size when its 1 (default) PHPBB3-10910 --- phpBB/includes/functions_acp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index ca116372ba..cb44ed2794 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -365,7 +365,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars) { $size = (isset($tpl_type[1])) ? (int) $tpl_type[1] : 1; - $tpl = ''; + $tpl = ''; } else {