@@ -75,12 +75,10 @@ public function testUpdateBundleProductWithOptions(): void
7575 $ bundleOptions = $ this ->generateBundleOptionUid ((int ) $ optionId , (int ) $ selectionId , $ optionQty );
7676
7777 // Add product to wishlist
78- $ this ->addProductToWishlist ();
79-
80- $ wishlist = $ this ->getBundleWishlist ();
81- $ wishlistId = $ wishlist ['customer ' ]['wishlists ' ][0 ]['id ' ];
82- $ wishlistItemId = $ wishlist ['customer ' ]['wishlists ' ][0 ]['items_v2 ' ][0 ]['id ' ];
83- $ itemsCount = $ wishlist ['customer ' ]['wishlists ' ][0 ]['items_count ' ];
78+ $ wishlist = $ this ->addProductToWishlist ();
79+ $ wishlistId = $ wishlist ['addProductsToWishlist ' ]['wishlist ' ]['id ' ];
80+ $ wishlistItemId = $ wishlist ['addProductsToWishlist ' ]['wishlist ' ]['items_v2 ' ][0 ]['id ' ];
81+ $ itemsCount = $ wishlist ['addProductsToWishlist ' ]['wishlist ' ]['items_count ' ];
8482
8583 $ query = $ this ->getBundleQuery ((int )$ wishlistItemId , $ qty , $ bundleOptions , (int )$ wishlistId );
8684 $ response = $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
@@ -112,50 +110,6 @@ private function getHeaderMap(string $username = 'customer@example.com', string
112110 return ['Authorization ' => 'Bearer ' . $ customerToken ];
113111 }
114112
115- /**
116- * Get Bundle wishlist result
117- *
118- * @param string $username
119- * @return array
120- *
121- * @throws Exception
122- */
123- private function getBundleWishlist (string $ username = 'customer@example.com ' ): array
124- {
125- return $ this ->graphQlQuery ($ this ->getCustomerBundleWishlistQuery (), [], '' , $ this ->getHeaderMap ($ username ));
126- }
127-
128- private function getCustomerBundleWishlistQuery (): string
129- {
130- return <<<QUERY
131- query {
132- customer {
133- wishlists {
134- id
135- items_count
136- items_v2 {
137- id
138- quantity
139- ... on BundleWishlistItem{
140- bundle_options{
141- id
142- label
143- type
144- values {
145- id
146- label
147- quantity
148- price
149- }
150- }
151- }
152- }
153- }
154- }
155- }
156- QUERY ;
157- }
158-
159113 /**
160114 * Returns GraphQl mutation string
161115 *
@@ -236,8 +190,9 @@ private function generateBundleOptionUid(int $optionId, int $selectionId, int $q
236190 * @magentoApiDataFixture Magento/Bundle/_files/product_1.php
237191 *
238192 * @throws Exception
193+ * return array
239194 */
240- private function addProductToWishlist (): void
195+ private function addProductToWishlist (): array
241196 {
242197 $ sku = 'bundle-product ' ;
243198 $ product = $ this ->productRepository ->get ($ sku );
@@ -256,7 +211,7 @@ private function addProductToWishlist(): void
256211 $ bundleOptions = $ this ->generateBundleOptionUid ((int ) $ optionId , (int ) $ selectionId , $ optionQty );
257212
258213 $ query = $ this ->addQuery ($ sku , $ qty , $ bundleOptions );
259- $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
214+ return $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
260215 }
261216
262217 /**
@@ -321,6 +276,5 @@ private function addQuery(
321276}
322277MUTATION ;
323278 }
324-
325279}
326280
0 commit comments