@@ -115,11 +115,10 @@ public function addToCart(BundleProduct $product, CatalogProductView $catalogPro
115
115
* Get product options
116
116
*
117
117
* @param FixtureInterface $product
118
- * @param bool $showSelected
119
118
* @return array
120
119
* @throws \Exception
121
120
*/
122
- public function getOptions (FixtureInterface $ product, bool $ showSelected = false )
121
+ public function getOptions (FixtureInterface $ product )
123
122
{
124
123
/** @var BundleProduct $product */
125
124
$ this ->product = $ product ;
@@ -140,9 +139,7 @@ public function getOptions(FixtureInterface $product, bool $showSelected = false
140
139
$ optionElement = $ listFormOptions [$ title ];
141
140
$ getTypeData = 'get ' . $ this ->optionNameConvert ($ option ['frontend_type ' ]) . 'Data ' ;
142
141
143
- $ optionData = $ showSelected
144
- ? $ this ->$ getTypeData ($ optionElement , $ showSelected )
145
- : $ this ->$ getTypeData ($ optionElement );
142
+ $ optionData = $ this ->$ getTypeData ($ optionElement );
146
143
$ optionData ['title ' ] = $ title ;
147
144
$ optionData ['type ' ] = $ option ['frontend_type ' ];
148
145
$ optionData ['is_require ' ] = $ optionElement ->find ($ this ->required , Locator::SELECTOR_XPATH )->isVisible ()
@@ -206,13 +203,12 @@ protected function getDropdownData(SimpleElement $option)
206
203
* Get data of "Multiple select" option
207
204
*
208
205
* @param SimpleElement $option
209
- * @param bool $showSelected
210
206
* @return array
211
207
*/
212
- protected function getMultipleselectData (SimpleElement $ option, bool $ showSelected = false )
208
+ protected function getMultipleselectData (SimpleElement $ option )
213
209
{
214
210
$ multiselect = $ option ->find ($ this ->selectOption , Locator::SELECTOR_XPATH , 'multiselect ' );
215
- $ data = $ this ->getSelectOptionsData ($ multiselect , 1 , $ showSelected );
211
+ $ data = $ this ->getSelectOptionsData ($ multiselect , 1 );
216
212
217
213
foreach ($ data ['options ' ] as $ key => $ option ) {
218
214
$ option ['title ' ] = trim (preg_replace ('/^[\d]+ x/ ' , '' , $ option ['title ' ]));
@@ -265,24 +261,21 @@ protected function getCheckboxData(SimpleElement $option)
265
261
*
266
262
* @param SimpleElement $element
267
263
* @param int $firstOption
268
- * @param bool $showSelected
269
264
* @return array
270
265
*/
271
- protected function getSelectOptionsData (SimpleElement $ element , $ firstOption = 1 , bool $ showSelected = false )
266
+ protected function getSelectOptionsData (SimpleElement $ element , $ firstOption = 1 )
272
267
{
273
268
$ listOptions = [];
274
269
275
270
$ count = $ firstOption ;
276
271
$ selectOption = $ element ->find (sprintf ($ this ->option , $ count ), Locator::SELECTOR_XPATH );
277
272
while ($ selectOption ->isVisible ()) {
278
- if ($ showSelected ) {
279
- $ listOptions [] = $ this ->parseOptionText (
280
- $ selectOption ->getText (),
281
- $ selectOption ->getAttribute ('selected ' )
282
- );
283
- } else {
284
- $ listOptions [] = $ this ->parseOptionText ($ selectOption ->getText ());
273
+ $ option = $ this ->parseOptionText ($ selectOption ->getText ());
274
+ $ selected = $ selectOption ->getAttribute ('selected ' );
275
+ if ($ selected ) {
276
+ $ option ['selected ' ] = $ selected ;
285
277
}
278
+ $ listOptions [] = $ option ;
286
279
++$ count ;
287
280
$ selectOption = $ element ->find (sprintf ($ this ->option , $ count ), Locator::SELECTOR_XPATH );
288
281
}
@@ -294,10 +287,9 @@ protected function getSelectOptionsData(SimpleElement $element, $firstOption = 1
294
287
* Parse option text to title, price and optionally add selected attribute value.
295
288
*
296
289
* @param string $optionText
297
- * @param string|null $selected
298
290
* @return array
299
291
*/
300
- protected function parseOptionText ($ optionText, $ selected = null )
292
+ protected function parseOptionText ($ optionText )
301
293
{
302
294
preg_match ('`^(.*?)\+ ?\$(\d.*?)$`sim ' , $ optionText , $ match );
303
295
$ optionPrice = isset ($ match [2 ]) ? str_replace (', ' , '' , $ match [2 ]) : 0 ;
@@ -306,9 +298,6 @@ protected function parseOptionText($optionText, $selected = null)
306
298
'title ' => $ optionTitle ,
307
299
'price ' => $ optionPrice
308
300
];
309
- if ($ selected ) {
310
- $ option ['selected ' ] = true ;
311
- }
312
301
313
302
return $ option ;
314
303
}
0 commit comments