[ticket/17151] Fix tests

PHPBB3-17151
This commit is contained in:
rxu 2023-09-19 15:30:52 +07:00
parent 52517a5efd
commit 7b04e411b6
No known key found for this signature in database
GPG key ID: 955F0567380E586A
6 changed files with 180 additions and 24 deletions

View file

@ -970,10 +970,10 @@ class acp_board
{
list($available, $value) = $data;
$act_options[] = [
'value' => $value,
'selected' => $selected_value == $value,
'label' => $user->lang($key),
'disabled' => !$available,
'value' => $value,
'selected' => $selected_value == $value,
'label' => $user->lang($key),
'class' => !$available ? 'disabled-option' : '',
];
}

View file

@ -24,14 +24,14 @@
<option
value="{{ option.value }}"
{% if option.selected %}selected="selected"{% endif %}
{% if option.disabled %} disabled="disabled" class="disabled-option"{% endif %}>{{ option.label }}</option>
{% if option.disabled %} disabled="disabled"{% endif %}{% if option.class %} class="{{ option.class }}"{% endif %}>{{ option.label }}</option>
{% endfor %}
</optgroup>
{% else %}
<option
value="{{ element.value }}"
{% if element.selected %} selected="selected"{% endif %}
{% if element.disabled %} disabled="disabled" class="disabled-option"{% endif %}
{% if element.disabled %} disabled="disabled"{% endif %}{% if element.class %} class="{{ element.class }}"{% endif %}
{% if element.data %}{% for key, value in element.data %} data-{{ key }}="{{ value }}"{% endfor %}{% endif %}>{{ element.label }}</option>
{% endif %}
{% endfor %}

View file

@ -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',
],
]
],
]
],
];
}

View file

@ -125,11 +125,25 @@ class main_module
function create_select()
{
return '
<option value="1" selected="selected">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
';
return [
'options' => [
[
'value' => 1,
'selected' => true,
'label' => 'Option 1',
],
[
'value' => 2,
'selected' => false,
'label' => 'Option 2',
],
[
'value' => 3,
'selected' => false,
'label' => 'Option 3',
],
]
];
}
function submit_button()

View file

@ -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',
],
]
],
];
}
/**

View file

@ -431,8 +431,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 +453,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 +466,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 +488,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
'selected' => false,
]
],
'toggleable' => false,
'group_only' => false,
'size' => 8,
'multiple' => false,
],
],
];