@@ -75,19 +75,21 @@ public function testDependenceHtml()
75
75
76
76
/**
77
77
* @covers \Magento\Config\Block\System\Config\Form::initFields
78
- * @param bool $useConfigField uses the test_field_use_config field if true
78
+ * @param string $fieldId uses the test_field_use_config field if true
79
79
* @param bool $isConfigDataEmpty if the config data array should be empty or not
80
- * @param $configDataValue the value that the field path should be set to in the config data
80
+ * @param string $configDataValue The value that the field path should be set to in the config data
81
+ * @param int $valueSelCtr Number of time that value is selected
81
82
* @param bool $expectedUseDefault
82
83
* @dataProvider initFieldsUseDefaultCheckboxDataProvider
83
84
*/
84
85
public function testInitFieldsUseDefaultCheckbox (
85
- $ useConfigField ,
86
+ $ fieldId ,
86
87
$ isConfigDataEmpty ,
87
88
$ configDataValue ,
88
- $ expectedUseDefault
89
+ $ expectedUseDefault ,
90
+ $ valueSelCtr = 1
89
91
) {
90
- $ this ->_setupFieldsInheritCheckbox ($ useConfigField , $ isConfigDataEmpty , $ configDataValue );
92
+ $ this ->_setupFieldsInheritCheckbox ($ fieldId , $ isConfigDataEmpty , $ configDataValue );
91
93
92
94
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
93
95
'Magento\Framework\Config\ScopeInterface '
@@ -126,12 +128,17 @@ public function testInitFieldsUseDefaultCheckbox(
126
128
$ fieldsetHtml = $ fieldset ->getElementHtml ();
127
129
128
130
$ this ->assertSelectCount ($ fieldsetSel , true , $ fieldsetHtml , 'Fieldset HTML is invalid ' );
129
- $ this ->assertSelectCount ($ valueSel , true , $ fieldsetHtml , 'Field input not found in fieldset HTML ' );
131
+ $ this ->assertSelectCount (
132
+ $ valueSel ,
133
+ $ valueSelCtr ,
134
+ $ fieldsetHtml ,
135
+ 'Field input should appear ' . $ valueSelCtr . ' times in fieldset HTML '
136
+ );
130
137
$ this ->assertSelectCount (
131
138
$ useDefaultSel ,
132
- true ,
139
+ $ valueSelCtr ,
133
140
$ fieldsetHtml ,
134
- '"Use Default" checkbox not found in fieldset HTML '
141
+ '"Use Default" checkbox should appear ' . $ valueSelCtr . ' times in fieldset HTML. '
135
142
);
136
143
137
144
if ($ expectedUseDefault ) {
@@ -159,25 +166,27 @@ public function testInitFieldsUseDefaultCheckbox(
159
166
public static function initFieldsUseDefaultCheckboxDataProvider ()
160
167
{
161
168
return [
162
- [false , true , null , true ],
163
- [false , false , null , false ],
164
- [false , false , '' , false ],
165
- [false , false , 'value ' , false ],
166
- [true , false , 'config value ' , false ]
169
+ ['test_field ' , true , null , true ],
170
+ ['test_field ' , false , null , false ],
171
+ ['test_field ' , false , '' , false ],
172
+ ['test_field ' , false , 'value ' , false ],
173
+ ['test_field_use_config_module_1 ' , false , 'config value ' , false ],
174
+ ['test_field_use_config_module_0 ' , false , 'config value ' , false , 0 ],
167
175
];
168
176
}
169
177
170
178
/**
171
179
* @covers \Magento\Config\Block\System\Config\Form::initFields
172
- * @param bool $useConfigField uses the test_field_use_config field if true
180
+ * @param string $fieldId uses the test_field_use_config field if true
173
181
* @param bool $isConfigDataEmpty if the config data array should be empty or not
174
- * @param $configDataValue the value that the field path should be set to in the config data
182
+ * @param string $configDataValue Value that the field path should be set to in the config data
183
+ * @param int $valueSelCtr Number of time that value is selected
175
184
* @dataProvider initFieldsUseConfigPathDataProvider
176
185
* @magentoConfigFixture default/test_config_section/test_group_config_node/test_field_value config value
177
186
*/
178
- public function testInitFieldsUseConfigPath ($ useConfigField , $ isConfigDataEmpty , $ configDataValue )
187
+ public function testInitFieldsUseConfigPath ($ fieldId , $ isConfigDataEmpty , $ configDataValue, $ valueSelCtr = 1 )
179
188
{
180
- $ this ->_setupFieldsInheritCheckbox ($ useConfigField , $ isConfigDataEmpty , $ configDataValue );
189
+ $ this ->_setupFieldsInheritCheckbox ($ fieldId , $ isConfigDataEmpty , $ configDataValue );
181
190
182
191
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
183
192
'Magento\Framework\Config\ScopeInterface '
@@ -208,7 +217,12 @@ public function testInitFieldsUseConfigPath($useConfigField, $isConfigDataEmpty,
208
217
$ fieldsetHtml = $ fieldset ->getElementHtml ();
209
218
210
219
$ this ->assertSelectCount ($ fieldsetSel , true , $ fieldsetHtml , 'Fieldset HTML is invalid ' );
211
- $ this ->assertSelectCount ($ valueSel , true , $ fieldsetHtml , 'Field input not found in fieldset HTML ' );
220
+ $ this ->assertSelectCount (
221
+ $ valueSel ,
222
+ $ valueSelCtr ,
223
+ $ fieldsetHtml ,
224
+ 'Field input should appear ' . $ valueSelCtr . ' times in fieldset HTML '
225
+ );
212
226
}
213
227
214
228
/**
@@ -217,20 +231,21 @@ public function testInitFieldsUseConfigPath($useConfigField, $isConfigDataEmpty,
217
231
public static function initFieldsUseConfigPathDataProvider ()
218
232
{
219
233
return [
220
- [false , true , null ],
221
- [false , false , null ],
222
- [false , false , '' ],
223
- [false , false , 'value ' ],
224
- [true , false , 'config value ' ]
234
+ ['test_field ' , true , null ],
235
+ ['test_field ' , false , null ],
236
+ ['test_field ' , false , '' ],
237
+ ['test_field ' , false , 'value ' ],
238
+ ['test_field_use_config_module_1 ' , false , 'config value ' ],
239
+ ['test_field_use_config_module_0 ' , false , 'config value ' , 0 ]
225
240
];
226
241
}
227
242
228
243
/**
229
- * @param bool $useConfigField uses the test_field_use_config field if true
244
+ * @param string $fieldId uses the test_field_use_config field if true
230
245
* @param bool $isConfigDataEmpty if the config data array should be empty or not
231
- * @param $configDataValue the value that the field path should be set to in the config data
246
+ * @param string $configDataValue the value that the field path should be set to in the config data
232
247
*/
233
- protected function _setupFieldsInheritCheckbox ($ useConfigField , $ isConfigDataEmpty , $ configDataValue )
248
+ protected function _setupFieldsInheritCheckbox ($ fieldId , $ isConfigDataEmpty , $ configDataValue )
234
249
{
235
250
\Magento \TestFramework \Helper \Bootstrap::getInstance ()->reinitialize ([
236
251
State::PARAM_BAN_CACHE => true ,
@@ -273,11 +288,8 @@ protected function _setupFieldsInheritCheckbox($useConfigField, $isConfigDataEmp
273
288
274
289
$ this ->_group = $ structure ->getElement ('test_section/test_group ' );
275
290
276
- if ($ useConfigField ) {
277
- $ this ->_field = $ structure ->getElement ('test_section/test_group/test_field_use_config ' );
278
- } else {
279
- $ this ->_field = $ structure ->getElement ('test_section/test_group/test_field ' );
280
- }
291
+ $ this ->_field = $ structure ->getElement ('test_section/test_group/ ' . $ fieldId );
292
+
281
293
$ fieldPath = $ this ->_field ->getConfigPath ();
282
294
283
295
if ($ isConfigDataEmpty ) {
0 commit comments