@@ -187,34 +187,6 @@ public function iAddThisProductWithToTheCart(
187187 $ this ->cartsClient ->executeCustomRequest ($ request );
188188 }
189189
190- /**
191- * @Given /^(this product) should have ([^"]+) "([^"]+)"$/
192- */
193- public function thisItemShouldHaveOptionValue (ProductInterface $ product , string $ optionName , string $ optionValue ): void
194- {
195- $ item = $ this ->sharedStorage ->get ('item ' );
196-
197- $ variantData = json_decode ($ this ->cartsClient ->showByIri (urldecode ($ item ['variant ' ]))->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
198-
199- foreach ($ variantData ['optionValues ' ] as $ valueIri ) {
200- $ optionValueData = json_decode ($ this ->cartsClient ->showByIri ($ valueIri )->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
201-
202- if ($ optionValueData ['value ' ] !== $ optionValue ) {
203- continue ;
204- }
205-
206- $ optionData = json_decode ($ this ->cartsClient ->showByIri ($ optionValueData ['option ' ])->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
207-
208- if ($ optionData ['name ' ] !== $ optionName ) {
209- continue ;
210- }
211-
212- return ;
213- }
214-
215- throw new \DomainException (sprintf ('Could not find item with option "%s" set to "%s" ' , $ optionName , $ optionValue ));
216- }
217-
218190 /**
219191 * @When /^I change (product "[^"]+") quantity to (\d+) in my (cart)$/
220192 * @When /^the (?:visitor|customer) change (product "[^"]+") quantity to (\d+) in his (cart)$/
@@ -532,6 +504,34 @@ public function iShouldHaveEmptyCart(string $tokenValue): void
532504 Assert::same (count ($ items ), 0 , 'There should be an empty cart ' );
533505 }
534506
507+ /**
508+ * @Then /^(this product) should have ([^"]+) "([^"]+)"$/
509+ */
510+ public function thisItemShouldHaveOptionValue (ProductInterface $ product , string $ optionName , string $ optionValue ): void
511+ {
512+ $ item = $ this ->sharedStorage ->get ('item ' );
513+
514+ $ variantData = json_decode ($ this ->cartsClient ->showByIri (urldecode ($ item ['variant ' ]))->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
515+
516+ foreach ($ variantData ['optionValues ' ] as $ valueIri ) {
517+ $ optionValueData = json_decode ($ this ->cartsClient ->showByIri ($ valueIri )->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
518+
519+ if ($ optionValueData ['value ' ] !== $ optionValue ) {
520+ continue ;
521+ }
522+
523+ $ optionData = json_decode ($ this ->cartsClient ->showByIri ($ optionValueData ['option ' ])->getContent (), true , 512 , \JSON_THROW_ON_ERROR );
524+
525+ if ($ optionData ['name ' ] !== $ optionName ) {
526+ continue ;
527+ }
528+
529+ return ;
530+ }
531+
532+ throw new \DomainException (sprintf ('Could not find item with option "%s" set to "%s" ' , $ optionName , $ optionValue ));
533+ }
534+
535535 private function pickupCart (?string $ localeCode = null ): string
536536 {
537537 $ this ->cartsClient ->buildCreateRequest ();
0 commit comments