mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge pull request #6533 from rxu/ticket/17151-2
[ticket/17151] Make settings forms use macros
This commit is contained in:
@@ -22,8 +22,36 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case
|
||||
public static function select_auth_method_data()
|
||||
{
|
||||
return [
|
||||
['acp_board_valid', '<option value="acp_board_valid" selected="selected" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'],
|
||||
['acp_board_invalid', '<option value="acp_board_valid" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'],
|
||||
[
|
||||
'acp_board_valid',
|
||||
[
|
||||
'options' => [
|
||||
0 => [
|
||||
'value' => 'acp_board_valid',
|
||||
'label' => 'Acp_board_valid',
|
||||
'selected' => true,
|
||||
'data' => [
|
||||
'toggle-setting' => '#auth_acp_board_valid_settings',
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'acp_board_invalid',
|
||||
[
|
||||
'options' => [
|
||||
0 => [
|
||||
'value' => 'acp_board_valid',
|
||||
'label' => 'Acp_board_valid',
|
||||
'selected' => false,
|
||||
'data' => [
|
||||
'toggle-setting' => '#auth_acp_board_valid_settings',
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -191,9 +191,14 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
{
|
||||
$avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar);
|
||||
|
||||
$expected_settings = array(
|
||||
'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
|
||||
);
|
||||
$expected_settings = [
|
||||
'allow_avatar_' . get_class($this->avatar_foobar) => [
|
||||
'lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)),
|
||||
'validate' => 'bool',
|
||||
'type' => 'radio:yes_no',
|
||||
'explain' => true
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($expected_settings, $avatar_settings);
|
||||
}
|
||||
|
@@ -28,4 +28,42 @@ class phpbb_functional_acp_main_test extends phpbb_functional_test_case
|
||||
$this->assertContainsLang('DATABASE_SIZE', $crawler->filter('tbody > tr')->eq(2)->filter('td[class="tabled"]')->eq(0)->text());
|
||||
$this->assertNotContainsLang('NOT_AVAILABLE', $crawler->filter('tbody > tr')->eq(2)->filter('td[class="tabled"]')->eq(1)->text());
|
||||
}
|
||||
|
||||
public function test_all_acp_module_links()
|
||||
{
|
||||
$this->add_lang('common');
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
// Browse ACP main page
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$crawler = self::$client->click($crawler->selectLink($this->lang('ACP_SHORT'))->link());
|
||||
|
||||
// Get all ACP module URLs array
|
||||
$acp_modules = $crawler->filter('.tabs a')->each(
|
||||
function ($node, $i)
|
||||
{
|
||||
return $node->link();
|
||||
}
|
||||
);
|
||||
|
||||
// Browse all ACP modules and get their mode URLs array
|
||||
$acp_submodules = [];
|
||||
foreach ($acp_modules as $module)
|
||||
{
|
||||
$crawler = self::$client->click($module);
|
||||
$acp_submodules = array_merge($acp_submodules, $crawler->filter('.menu-block > ul a')->each(
|
||||
function ($node, $i)
|
||||
{
|
||||
return $node->link();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
// Browse all ACP submodules' modes
|
||||
foreach ($acp_submodules as $acp_submodule)
|
||||
{
|
||||
self::$client->click($acp_submodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||
|
||||
public function test_acp()
|
||||
{
|
||||
$this->add_lang('common');
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
@@ -64,43 +65,86 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||
$this->assertStringContainsString('SETTING_0', $crawler->filter('dl')->eq(0)->filter('dt > label[for="setting_0"]')->text());
|
||||
$this->assertStringContainsString('SETTING_0_EXPLAIN', $crawler->filter('dl')->eq(0)->filter('dt > span')->text());
|
||||
$this->assertEquals(2, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->count());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->eq(0)->attr('value'));
|
||||
$this->assertEquals(17, $crawler->filter('dl')->eq(0)->filter('dd > input[type="number"]')->eq(1)->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_1', $crawler->filter('dl')->eq(1)->filter('dt > label[for="setting_1"]')->text());
|
||||
$this->assertStringContainsString('CUSTOM_LANG_EXPLAIN', $crawler->filter('dl')->eq(1)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(1)->filter('dd > input[type="submit"]')->count());
|
||||
$this->assertEquals('Test submit button', $crawler->filter('dl')->eq(1)->filter('dd > input[type="submit"]')->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_2', $crawler->filter('dl')->eq(2)->filter('dt > label[for="setting_2"]')->text());
|
||||
$this->assertEquals(0, $crawler->filter('dl')->eq(2)->filter('dt > span')->count());
|
||||
$this->assertEquals(2, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->count());
|
||||
$this->assertContainsLang('YES', $crawler->filter('dl')->eq(2)->filter('dd > label')->eq(0)->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value'));
|
||||
$this->assertEquals('checked', $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(0)->attr('checked'));
|
||||
$this->assertContainsLang('NO', $crawler->filter('dl')->eq(2)->filter('dd > label')->eq(1)->text());
|
||||
$this->assertEquals(0, $crawler->filter('dl')->eq(2)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_3', $crawler->filter('dl')->eq(3)->filter('dt > label[for="setting_3"]')->text());
|
||||
$this->assertStringContainsString('SETTING_3_EXPLAIN', $crawler->filter('dl')->eq(3)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(3)->filter('dd > input[type="number"]')->count());
|
||||
$this->assertEquals(15, $crawler->filter('dl')->eq(3)->filter('dd > input[type="number"]')->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_4', $crawler->filter('dl')->eq(4)->filter('dt > label[for="setting_4"]')->text());
|
||||
$this->assertStringContainsString('SETTING_4_EXPLAIN', $crawler->filter('dl')->eq(4)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(4)->filter('dd > select[id="setting_4"]')->count());
|
||||
$this->assertEquals(3, $crawler->filter('dl')->eq(4)->filter('dd > select > option')->count());
|
||||
$this->assertEquals(2, $crawler->filter('dl')->eq(4)->filter('dd > select > option')->eq(1)->attr('value'));
|
||||
$this->assertEquals('selected', $crawler->filter('dl')->eq(4)->filter('dd > select > option')->eq(1)->attr('selected'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_5', $crawler->filter('dl')->eq(5)->filter('dt > label[for="setting_5"]')->text());
|
||||
$this->assertStringContainsString('SETTING_5_EXPLAIN', $crawler->filter('dl')->eq(5)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(5)->filter('dd > input[type="text"]')->count());
|
||||
$this->assertEquals('Setting 5', $crawler->filter('dl')->eq(5)->filter('dd > input[type="text"]')->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_6', $crawler->filter('dl')->eq(6)->filter('dt > label[for="setting_6"]')->text());
|
||||
$this->assertStringContainsString('SETTING_6_EXPLAIN', $crawler->filter('dl')->eq(6)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(6)->filter('dd > input[type="password"]')->count());
|
||||
$this->assertEquals('********', $crawler->filter('dl')->eq(6)->filter('dd > input[type="password"]')->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_7', $crawler->filter('dl')->eq(7)->filter('dt > label[for="setting_7"]')->text());
|
||||
$this->assertStringContainsString('SETTING_7_EXPLAIN', $crawler->filter('dl')->eq(7)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(7)->filter('dd > input[type="email"]')->count());
|
||||
$this->assertEquals('test@example.dom', $crawler->filter('dl')->eq(7)->filter('dd > input[type="email"]')->attr('value'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_8', $crawler->filter('dl')->eq(8)->filter('dt > label[for="setting_8"]')->text());
|
||||
$this->assertStringContainsString('SETTING_8_EXPLAIN', $crawler->filter('dl')->eq(8)->filter('dt > span')->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(8)->filter('dd > textarea[name="config[setting_8]"]')->count());
|
||||
$this->assertEquals('Textarea', $crawler->filter('dl')->eq(8)->filter('dd > textarea[name="config[setting_8]"]')->text());
|
||||
|
||||
$this->assertStringContainsString('SETTING_9', $crawler->filter('dl')->eq(9)->filter('dt > label[for="setting_9"]')->text());
|
||||
$this->assertStringContainsString('SETTING_9_EXPLAIN', $crawler->filter('dl')->eq(9)->filter('dt > span')->text());
|
||||
$this->assertEquals(2, $crawler->filter('dl')->eq(9)->filter('dd > label > input[type="radio"]')->count());
|
||||
$this->assertEquals('checked', $crawler->filter('dl')->eq(9)->filter('dd > label > input[type="radio"]')->eq(0)->attr('checked'));
|
||||
|
||||
$this->assertStringContainsString('SETTING_10', $crawler->filter('dl')->eq(10)->filter('dt > label[for="setting_10"]')->text());
|
||||
$this->assertStringContainsString('SETTING_10_EXPLAIN', $crawler->filter('dl')->eq(10)->filter('dt > span')->text());
|
||||
$this->assertEquals(3, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->count());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value'));
|
||||
$this->assertStringContainsString('LABEL_1', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(0)->text());
|
||||
$this->assertEquals(3, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value'));
|
||||
$this->assertEquals('checked', $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked'));
|
||||
$this->assertStringContainsString('LABEL_3', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(1)->text());
|
||||
$this->assertEquals(2, $crawler->filter('dl')->eq(10)->filter('dd > label > input[type="radio"]')->eq(2)->attr('value'));
|
||||
$this->assertStringContainsString('LABEL_2', $crawler->filter('dl')->eq(10)->filter('dd > label')->eq(2)->text());
|
||||
|
||||
$this->assertStringContainsString('SETTING_11', $crawler->filter('dl')->eq(11)->filter('dt > label[for="setting_11"]')->text());
|
||||
$this->assertStringContainsString('SETTING_11_EXPLAIN', $crawler->filter('dl')->eq(11)->filter('dt > span')->text());
|
||||
$this->assertEquals('1', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value'));
|
||||
$this->assertEquals('0', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value'));
|
||||
$this->assertEquals('checked', $crawler->filter('dl')->eq(11)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked'));
|
||||
$this->assertContainsLang('YES', $crawler->filter('dl')->eq(11)->filter('dd > label')->eq(0)->text());
|
||||
$this->assertContainsLang('NO', $crawler->filter('dl')->eq(11)->filter('dd > label')->eq(1)->text());
|
||||
|
||||
$this->assertStringContainsString('SETTING_12', $crawler->filter('dl')->eq(12)->filter('dt > label[for="setting_12"]')->text());
|
||||
$this->assertStringContainsString('SETTING_12_EXPLAIN', $crawler->filter('dl')->eq(12)->filter('dt > span')->text());
|
||||
$this->assertContainsLang('ENABLED', $crawler->filter('dl')->eq(12)->filter('dd > label')->eq(0)->text());
|
||||
$this->assertEquals(1, $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(0)->attr('value'));
|
||||
$this->assertContainsLang('DISABLED', $crawler->filter('dl')->eq(12)->filter('dd > label')->eq(1)->text());
|
||||
$this->assertEquals(0, $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(1)->attr('value'));
|
||||
$this->assertEquals('checked', $crawler->filter('dl')->eq(12)->filter('dd > label > input[type="radio"]')->eq(1)->attr('checked'));
|
||||
}
|
||||
|
||||
public function test_ucp()
|
||||
|
@@ -41,18 +41,39 @@ class main_module
|
||||
'setting_0_height' => ['lang' => 'SETTING_0', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false],
|
||||
'setting_0' => ['lang' => 'SETTING_0', 'validate' => 'int:0:16', 'type' => 'dimension:0:999', 'explain' => true, 'append' => ' ' . $language->lang('PIXEL')],
|
||||
'setting_1' => ['lang' => 'SETTING_1', 'validate' => 'bool', 'type' => 'custom', 'method' => 'submit_button', 'lang_explain' => 'CUSTOM_LANG_EXPLAIN', 'explain' => true],
|
||||
'setting_2' => ['lang' => 'SETTING_2', 'validate' => 'bool', 'type' => 'radio:yes_no'],
|
||||
'setting_2' => ['lang' => 'SETTING_2', 'validate' => 'bool', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'YES', 0 => 'NO']]],
|
||||
'setting_3' => ['lang' => 'SETTING_3', 'validate' => 'int:0:99999','type' => 'number:0:99999', 'explain' => true],
|
||||
'setting_4' => ['lang' => 'SETTING_4', 'validate' => 'string', 'type' => 'select', 'method' => 'create_select', 'explain' => true],
|
||||
'setting_5' => ['lang' => 'SETTING_5', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true],
|
||||
'setting_6' => ['lang' => 'SETTING_6', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true],
|
||||
'setting_7' => ['lang' => 'SETTING_7', 'validate' => 'email', 'type' => 'email:0:100', 'explain' => true],
|
||||
'setting_8' => ['lang' => 'SETTING_8', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true],
|
||||
'setting_9' => ['lang' => 'SETTING_9', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true],
|
||||
'setting_9' => ['lang' => 'SETTING_9', 'validate' => 'bool', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'ENABLED', 0 => 'DISABLED']], 'explain' => true],
|
||||
'setting_10'=> ['lang' => 'SETTING_10', 'validate' => 'int', 'type' => 'radio', 'function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'LABEL_1', 3 => 'LABEL_3', 2 => 'LABEL_2']], 'explain' => true],
|
||||
'setting_11'=> ['lang' => 'SETTING_11', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true],
|
||||
'setting_12'=> ['lang' => 'SETTING_12', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true],
|
||||
]
|
||||
];
|
||||
|
||||
$this->new_config = $cfg_array = $error = [];
|
||||
$config = new \phpbb\config\config([
|
||||
'setting_0_width' => '1',
|
||||
'setting_0_height' => '17',
|
||||
'setting_0' => '10',
|
||||
'setting_2' => '1',
|
||||
'setting_3' => '15',
|
||||
'setting_4' => '2',
|
||||
'setting_5' => 'Setting 5',
|
||||
'setting_6' => 'password',
|
||||
'setting_7' => 'test@example.dom',
|
||||
'setting_8' => 'Textarea',
|
||||
'setting_9' => '1',
|
||||
'setting_10' => '3',
|
||||
'setting_11' => '0',
|
||||
'setting_12' => '0',
|
||||
]);
|
||||
$this->new_config = clone $config;
|
||||
$cfg_array = (isset($_REQUEST['config'])) ? $request->variable('config', ['' => ''], true) : $this->new_config;
|
||||
$error = [];
|
||||
|
||||
validate_config_vars($display_vars['vars'], $cfg_array, $error);
|
||||
|
||||
@@ -104,7 +125,7 @@ class main_module
|
||||
$l_explain = $language->lang($vars['lang_explain'] ?: $vars['lang'] . '_EXPLAIN');
|
||||
}
|
||||
|
||||
$content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
|
||||
$content = phpbb_build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
|
||||
|
||||
if (empty($content))
|
||||
{
|
||||
@@ -123,13 +144,15 @@ class main_module
|
||||
}
|
||||
}
|
||||
|
||||
function create_select()
|
||||
function create_select($value)
|
||||
{
|
||||
return '
|
||||
<option value="1" selected="selected">Option 1</option>
|
||||
<option value="2">Option 2</option>
|
||||
<option value="3">Option 3</option>
|
||||
';
|
||||
$options = [
|
||||
1 => 'Option 1',
|
||||
2 => 'Option 2',
|
||||
3 => 'Option 3',
|
||||
];
|
||||
|
||||
return ['options' => build_select($options, $value)];
|
||||
}
|
||||
|
||||
function submit_button()
|
||||
|
@@ -20,14 +20,119 @@ class phpbb_functions_style_select_test extends phpbb_database_test_case
|
||||
|
||||
static public function style_select_data()
|
||||
{
|
||||
return array(
|
||||
array('', false, '<option value="1">prosilver</option><option value="2">subsilver2</option>'),
|
||||
array('', true, '<option value="1">prosilver</option><option value="2">subsilver2</option><option value="3">zoo</option>'),
|
||||
array('1', false, '<option value="1" selected="selected">prosilver</option><option value="2">subsilver2</option>'),
|
||||
array('1', true, '<option value="1" selected="selected">prosilver</option><option value="2">subsilver2</option><option value="3">zoo</option>'),
|
||||
array('3', false, '<option value="1">prosilver</option><option value="2">subsilver2</option>'),
|
||||
array('3', true, '<option value="1">prosilver</option><option value="2">subsilver2</option><option value="3" selected="selected">zoo</option>'),
|
||||
);
|
||||
return [
|
||||
[
|
||||
'',
|
||||
false,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => false,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'',
|
||||
true,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => false,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
[
|
||||
'value' => '3',
|
||||
'selected' => false,
|
||||
'label' => 'zoo',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'1',
|
||||
false,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => true,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'1',
|
||||
true,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => true,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
[
|
||||
'value' => '3',
|
||||
'selected' => false,
|
||||
'label' => 'zoo',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'3',
|
||||
false,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => false,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'3',
|
||||
true,
|
||||
[
|
||||
[
|
||||
'value' => '1',
|
||||
'selected' => false,
|
||||
'label' => 'prosilver',
|
||||
],
|
||||
[
|
||||
'value' => '2',
|
||||
'selected' => false,
|
||||
'label' => 'subsilver2',
|
||||
],
|
||||
[
|
||||
'value' => '3',
|
||||
'selected' => true,
|
||||
'label' => 'zoo',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -81,7 +81,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$language = new phpbb_mock_lang();
|
||||
$user->lang = $language;
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_dimension_data()
|
||||
@@ -151,7 +151,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$user = new phpbb_mock_user();
|
||||
$user->lang = new phpbb_mock_lang();
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_number_data()
|
||||
@@ -219,7 +219,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$user = new phpbb_mock_user();
|
||||
$user->lang = new phpbb_mock_lang();
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_textarea_data()
|
||||
@@ -254,18 +254,18 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$user = new phpbb_mock_user();
|
||||
$user->lang = new phpbb_mock_lang();
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_radio_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array('radio', 'enabled_disabled'),
|
||||
return [
|
||||
[
|
||||
['radio', 'enabled_disabled'],
|
||||
'key_name',
|
||||
array('config_key_name' => '0'),
|
||||
['config_key_name' => '0'],
|
||||
'config_key_name',
|
||||
array(),
|
||||
[],
|
||||
[
|
||||
'tag' => 'radio',
|
||||
'buttons' => [
|
||||
@@ -286,13 +286,40 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
array(
|
||||
array('radio', 'enabled_disabled'),
|
||||
],
|
||||
[
|
||||
['radio'],
|
||||
'key_name',
|
||||
array('config_key_name' => '1'),
|
||||
['config_key_name' => '0'],
|
||||
'config_key_name',
|
||||
array(),
|
||||
['function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'ENABLED', 0 => 'DISABLED']]],
|
||||
[
|
||||
'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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['radio', 'enabled_disabled'],
|
||||
'key_name',
|
||||
['config_key_name' => '1'],
|
||||
'config_key_name',
|
||||
[],
|
||||
[
|
||||
'tag' => 'radio',
|
||||
'buttons' => [
|
||||
@@ -313,13 +340,40 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
array(
|
||||
array('radio', 'yes_no'),
|
||||
],
|
||||
[
|
||||
['radio'],
|
||||
'key_name',
|
||||
array('config_key_name' => '0'),
|
||||
['config_key_name' => '1'],
|
||||
'config_key_name',
|
||||
array(),
|
||||
['function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'ENABLED', 0 => 'DISABLED']]],
|
||||
[
|
||||
'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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['radio', 'yes_no'],
|
||||
'key_name',
|
||||
['config_key_name' => '0'],
|
||||
'config_key_name',
|
||||
[],
|
||||
[
|
||||
'tag' => 'radio',
|
||||
'buttons' => [
|
||||
@@ -340,13 +394,40 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
array(
|
||||
array('radio', 'yes_no'),
|
||||
],
|
||||
[
|
||||
['radio'],
|
||||
'key_name',
|
||||
array('config_key_name' => '1'),
|
||||
['config_key_name' => '0'],
|
||||
'config_key_name',
|
||||
array(),
|
||||
['function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'YES', 0 => 'NO']]],
|
||||
[
|
||||
'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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
['radio', 'yes_no'],
|
||||
'key_name',
|
||||
['config_key_name' => '1'],
|
||||
'config_key_name',
|
||||
[],
|
||||
[
|
||||
'tag' => 'radio',
|
||||
'buttons' => [
|
||||
@@ -367,8 +448,35 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
],
|
||||
[
|
||||
['radio'],
|
||||
'key_name',
|
||||
['config_key_name' => '1'],
|
||||
'config_key_name',
|
||||
['function' => 'phpbb_build_radio', 'params' => ['{CONFIG_VALUE}', '{KEY}', [1 => 'YES', 0 => 'NO']]],
|
||||
[
|
||||
'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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,7 +489,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$language = new \phpbb_mock_lang();
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_append_data()
|
||||
@@ -417,7 +525,7 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$user = new phpbb_mock_user();
|
||||
$user->lang = new phpbb_mock_lang();
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
}
|
||||
|
||||
public function build_cfg_template_select_data()
|
||||
@@ -431,8 +539,11 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
['method' => 'select_helper'],
|
||||
[
|
||||
'tag' => 'select',
|
||||
'class' => false,
|
||||
'id' => 'key_name',
|
||||
'data' => [],
|
||||
'name' => 'config[config_key_name]',
|
||||
'toggleable' => false,
|
||||
'options' => [
|
||||
[
|
||||
'value' => 1,
|
||||
@@ -450,7 +561,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
'selected' => false,
|
||||
]
|
||||
],
|
||||
'toggleable' => false,
|
||||
'group_only' => false,
|
||||
'size' => 1,
|
||||
'multiple' => false,
|
||||
],
|
||||
],
|
||||
[
|
||||
@@ -461,9 +574,11 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
['method' => 'select_helper'],
|
||||
[
|
||||
'tag' => 'select',
|
||||
'class' => false,
|
||||
'id' => 'key_name',
|
||||
'data' => [],
|
||||
'name' => 'config[config_key_name]',
|
||||
'size' => 8,
|
||||
'toggleable' => false,
|
||||
'options' => [
|
||||
[
|
||||
'value' => 1,
|
||||
@@ -481,7 +596,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
'selected' => false,
|
||||
]
|
||||
],
|
||||
'toggleable' => false,
|
||||
'group_only' => false,
|
||||
'size' => 8,
|
||||
'multiple' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -501,18 +618,19 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
|
||||
$user->module = $this;
|
||||
$module = $user;
|
||||
|
||||
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
|
||||
$this->assertEquals($expected, phpbb_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'
|
||||
);
|
||||
return [
|
||||
'options' => build_select(
|
||||
[
|
||||
'1' => 'First_Option',
|
||||
'2' => 'Second_Option',
|
||||
'3' => 'Third_Option',
|
||||
],
|
||||
'2'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../phpBB/includes/functions_acp.php';
|
||||
|
||||
class phpbb_functions_acp_h_radio_test extends phpbb_test_case
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
global $user;
|
||||
|
||||
$user = new phpbb_mock_user();
|
||||
$user->lang = new phpbb_mock_lang();
|
||||
}
|
||||
|
||||
public function h_radio_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'<label><input type="radio" name="test_name" value="test" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
'test',
|
||||
false,
|
||||
false,
|
||||
'<label><input type="radio" name="test_name" value="test" checked="checked" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
false,
|
||||
'test_id',
|
||||
false,
|
||||
'<label><input type="radio" name="test_name" id="test_id" value="test" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
'test',
|
||||
'test_id',
|
||||
false,
|
||||
'<label><input type="radio" name="test_name" id="test_id" value="test" checked="checked" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
false,
|
||||
false,
|
||||
'k',
|
||||
'<label><input type="radio" name="test_name" value="test" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
'test',
|
||||
false,
|
||||
'k',
|
||||
'<label><input type="radio" name="test_name" value="test" checked="checked" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
false,
|
||||
'test_id',
|
||||
'k',
|
||||
'<label><input type="radio" name="test_name" id="test_id" value="test" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
array(
|
||||
'test_name',
|
||||
array(
|
||||
'test' => 'TEST',
|
||||
'second' => 'SEC_OPTION',
|
||||
),
|
||||
'test',
|
||||
'test_id',
|
||||
'k',
|
||||
'<label><input type="radio" name="test_name" id="test_id" value="test" checked="checked" accesskey="k" class="radio" /> TEST</label><label><input type="radio" name="test_name" value="second" accesskey="k" class="radio" /> SEC_OPTION</label>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider h_radio_data
|
||||
*/
|
||||
public function test_h_radio($name, $input_ary, $input_default, $id, $key, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, h_radio($name, $input_ary, $input_default, $id, $key));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user