diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index ff7673155c..b6c9c7b39d 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -380,7 +380,7 @@ function phpbb_build_cfg_template(array $tpl_type, string $key, &$new_ary, $conf
'type' => 'radio',
'name' => $name,
'value' => 1,
- 'checked' => $new_ary[$config_key],
+ 'checked' => (bool) $new_ary[$config_key],
'label' => $type_no ? $language->lang('YES') : $language->lang('ENABLED'),
];
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
index 339a9a1d61..9d3b244bc0 100644
--- a/tests/functions_acp/build_cfg_template_test.php
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -24,7 +24,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '1'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'key_name',
+ 'type' => 'text',
+ 'name' => 'config[config_key_name]',
+ 'size' => 20,
+ 'maxlength' => 255,
+ 'value' => '1',
+ ],
),
array(
array('password', 20, 128),
@@ -32,7 +40,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '2'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'key_name',
+ 'type' => 'password',
+ 'name' => 'config[config_key_name]',
+ 'size' => 20,
+ 'maxlength' => 128,
+ 'value' => '********',
+ ],
),
array(
array('text', 0, 255),
@@ -40,7 +56,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '3'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'key_name',
+ 'type' => 'text',
+ 'name' => 'config[config_key_name]',
+ 'maxlength' => 255,
+ 'value' => '3',
+ 'size' => '',
+ ],
),
);
}
@@ -68,7 +92,24 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name_width' => 10, 'config_key_name_height' => 20),
'config_key_name',
array(),
- ' x ',
+ [
+ 'tag' => 'dimension',
+ 'width' => [
+ 'id' => 'number_key_name',
+ 'type' => 'number',
+ 'name' => 'config[config_key_name_width]',
+ 'min' => 5,
+ 'max' => 15,
+ 'value' => 10,
+ ],
+ 'height' => [
+ 'type' => 'number',
+ 'name' => 'config[config_key_name_height]',
+ 'min' => 5,
+ 'max' => 15,
+ 'value' => 20,
+ ],
+ ],
),
array(
array('dimension', 0, 15),
@@ -76,7 +117,24 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name_width' => 10, 'config_key_name_height' => 20),
'config_key_name',
array(),
- ' x ',
+ [
+ 'tag' => 'dimension',
+ 'width' => [
+ 'id' => 'number_key_name',
+ 'type' => 'number',
+ 'name' => 'config[config_key_name_width]',
+ 'min' => 0,
+ 'max' => 15,
+ 'value' => 10,
+ ],
+ 'height' => [
+ 'type' => 'number',
+ 'name' => 'config[config_key_name_height]',
+ 'min' => 0,
+ 'max' => 15,
+ 'value' => 20,
+ ],
+ ],
),
);
}
@@ -104,7 +162,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => 10),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'number_key_name',
+ 'type' => 'number',
+ 'name' => 'config[config_key_name]',
+ 'min' => 5,
+ 'max' => 15,
+ 'value' => 10,
+ ],
),
array(
array('number', -1, 9999),
@@ -112,7 +178,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => 10),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'number_key_name',
+ 'type' => 'number',
+ 'name' => 'config[config_key_name]',
+ 'min' => -1,
+ 'max' => 9999,
+ 'value' => 10,
+ ],
),
array(
array('number', 0, 9999),
@@ -120,7 +194,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => 10),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'input',
+ 'id' => 'number_key_name',
+ 'type' => 'number',
+ 'name' => 'config[config_key_name]',
+ 'min' => 0,
+ 'max' => 9999,
+ 'value' => 10,
+ ],
),
);
}
@@ -148,7 +230,14 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => 'phpBB'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'textarea',
+ 'id' => 'key_name',
+ 'name' => 'config[config_key_name]',
+ 'rows' => 5,
+ 'cols' => 30,
+ 'content' => 'phpBB',
+ ]
),
);
}
@@ -176,7 +265,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '0'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'radio',
+ 'buttons' => [
+ [
+ 'id' => 'key_name',
+ 'type' => 'radio',
+ 'value' => 1,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'ENABLED',
+ 'checked' => false,
+ ],
+ [
+ 'type' => 'radio',
+ 'value' => 0,
+ 'checked' => true,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'DISABLED',
+ ],
+ ],
+ ],
),
array(
array('radio', 'enabled_disabled'),
@@ -184,7 +292,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '1'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'radio',
+ 'buttons' => [
+ [
+ 'id' => 'key_name',
+ 'type' => 'radio',
+ 'value' => 1,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'ENABLED',
+ 'checked' => true,
+ ],
+ [
+ 'type' => 'radio',
+ 'value' => 0,
+ 'checked' => false,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'DISABLED',
+ ],
+ ],
+ ],
),
array(
array('radio', 'yes_no'),
@@ -192,7 +319,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '0'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'radio',
+ 'buttons' => [
+ [
+ 'id' => 'key_name',
+ 'type' => 'radio',
+ 'value' => 1,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'YES',
+ 'checked' => false,
+ ],
+ [
+ 'type' => 'radio',
+ 'value' => 0,
+ 'checked' => true,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'NO',
+ ],
+ ],
+ ],
),
array(
array('radio', 'yes_no'),
@@ -200,7 +346,26 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => '1'),
'config_key_name',
array(),
- '',
+ [
+ 'tag' => 'radio',
+ 'buttons' => [
+ [
+ 'id' => 'key_name',
+ 'type' => 'radio',
+ 'value' => 1,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'YES',
+ 'checked' => true,
+ ],
+ [
+ 'type' => 'radio',
+ 'value' => 0,
+ 'checked' => false,
+ 'name' => 'config[config_key_name]',
+ 'label' => 'NO',
+ ],
+ ],
+ ],
),
);
}
@@ -210,11 +375,10 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_radio($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user, $phpbb_dispatcher;
+ global $language, $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = new phpbb_mock_user();
- $user->lang = new phpbb_mock_lang();
+ $language = new \phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
}
@@ -228,7 +392,15 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
array('config_key_name' => 'phpBB'),
'config_key_name',
array('append' => 'Bertie is cool!'),
- 'Bertie is cool!',
+ [
+ 'tag' => 'textarea',
+ 'id' => 'key_name',
+ 'name' => 'config[config_key_name]',
+ 'rows' => 5,
+ 'cols' => 30,
+ 'content' => 'phpBB',
+ 'append' => 'Bertie is cool!',
+ ]
),
);
}