[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; list($available, $value) = $data;
$act_options[] = [ $act_options[] = [
'value' => $value, 'value' => $value,
'selected' => $selected_value == $value, 'selected' => $selected_value == $value,
'label' => $user->lang($key), 'label' => $user->lang($key),
'disabled' => !$available, 'class' => !$available ? 'disabled-option' : '',
]; ];
} }

View file

@ -24,14 +24,14 @@
<option <option
value="{{ option.value }}" value="{{ option.value }}"
{% if option.selected %}selected="selected"{% endif %} {% 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 %} {% endfor %}
</optgroup> </optgroup>
{% else %} {% else %}
<option <option
value="{{ element.value }}" value="{{ element.value }}"
{% if element.selected %} selected="selected"{% endif %} {% 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> {% if element.data %}{% for key, value in element.data %} data-{{ key }}="{{ value }}"{% endfor %}{% endif %}>{{ element.label }}</option>
{% endif %} {% endif %}
{% endfor %} {% 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() public static function select_auth_method_data()
{ {
return [ 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() function create_select()
{ {
return ' return [
<option value="1" selected="selected">Option 1</option> 'options' => [
<option value="2">Option 2</option> [
<option value="3">Option 3</option> 'value' => 1,
'; 'selected' => true,
'label' => 'Option 1',
],
[
'value' => 2,
'selected' => false,
'label' => 'Option 2',
],
[
'value' => 3,
'selected' => false,
'label' => 'Option 3',
],
]
];
} }
function submit_button() 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() static public function style_select_data()
{ {
return array( return [
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>'), false,
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>'), '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'], ['method' => 'select_helper'],
[ [
'tag' => 'select', 'tag' => 'select',
'class' => false,
'id' => 'key_name', 'id' => 'key_name',
'data' => [],
'name' => 'config[config_key_name]', 'name' => 'config[config_key_name]',
'toggleable' => false,
'options' => [ 'options' => [
[ [
'value' => 1, 'value' => 1,
@ -450,7 +453,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
'selected' => false, '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'], ['method' => 'select_helper'],
[ [
'tag' => 'select', 'tag' => 'select',
'class' => false,
'id' => 'key_name', 'id' => 'key_name',
'data' => [],
'name' => 'config[config_key_name]', 'name' => 'config[config_key_name]',
'size' => 8, 'toggleable' => false,
'options' => [ 'options' => [
[ [
'value' => 1, 'value' => 1,
@ -481,7 +488,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
'selected' => false, 'selected' => false,
] ]
], ],
'toggleable' => false, 'group_only' => false,
'size' => 8,
'multiple' => false,
], ],
], ],
]; ];