20
20
use Sylius \Behat \Context \Api \Resources ;
21
21
use Sylius \Behat \Service \SharedStorageInterface ;
22
22
use Sylius \Component \Core \Model \ProductVariantInterface ;
23
+ use Sylius \Component \Core \Repository \ProductVariantRepositoryInterface ;
23
24
use Symfony \Component \HttpFoundation \Request as HttpRequest ;
24
25
use Webmozart \Assert \Assert ;
25
26
@@ -30,6 +31,7 @@ public function __construct(
30
31
private readonly ApiClientInterface $ client ,
31
32
private readonly RequestFactoryInterface $ requestFactory ,
32
33
private readonly ResponseCheckerInterface $ responseChecker ,
34
+ private readonly ProductVariantRepositoryInterface $ productVariantRepository ,
33
35
) {
34
36
}
35
37
@@ -116,8 +118,11 @@ public function iShouldHaveProductInBundledItems(ProductInterface $product): voi
116
118
/**
117
119
* @When I should have product variant :productVariant in bundled items
118
120
*/
119
- public function iShouldHaveProductVariantInBundledItems (ProductVariantInterface $ productVariant ): void
121
+ public function iShouldHaveProductVariantInBundledItems (string $ productVariant ): void
120
122
{
123
+ $ productVariant = $ this ->productVariantRepository ->findOneBy (['code ' => $ productVariant ]);
124
+ Assert::isInstanceOf ($ productVariant , ProductVariantInterface::class);
125
+
121
126
$ response = $ this ->client ->show (Resources::ORDERS , $ this ->sharedStorage ->get ('cart_token ' ));
122
127
123
128
$ productBundleOrderItems = $ this ->responseChecker ->getValue ($ response , 'items ' )[0 ]['productBundleOrderItems ' ];
@@ -133,8 +138,11 @@ public function iShouldHaveProductVariantInBundledItems(ProductVariantInterface
133
138
/**
134
139
* @When I should not have product variant :productVariant in bundled items
135
140
*/
136
- public function iShouldNotHaveProductVariantInBundledItems (ProductVariantInterface $ productVariant ): void
141
+ public function iShouldNotHaveProductVariantInBundledItems (string $ productVariant ): void
137
142
{
143
+ $ productVariant = $ this ->productVariantRepository ->findOneBy (['code ' => $ productVariant ]);
144
+ Assert::isInstanceOf ($ productVariant , ProductVariantInterface::class);
145
+
138
146
$ response = $ this ->client ->show (Resources::ORDERS , $ this ->sharedStorage ->get ('cart_token ' ));
139
147
140
148
$ productBundleOrderItems = $ this ->responseChecker ->getValue ($ response , 'items ' )[0 ]['productBundleOrderItems ' ];
0 commit comments