@@ -199,6 +199,39 @@ public function testAddProductWithWrongQuantity(int $quantity, string $message)
199
199
);
200
200
}
201
201
202
+ /**
203
+ * @magentoApiDataFixture Magento/Catalog/_files/products_with_websites_and_stores.php
204
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
205
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote_not_default_website.php
206
+ * @dataProvider addProductNotAssignedToWebsiteDataProvider
207
+ * @param string $reservedOrderId
208
+ * @param string $sku
209
+ * @param array $headerMap
210
+ */
211
+ public function testAddProductNotAssignedToWebsite (string $ reservedOrderId , string $ sku , array $ headerMap )
212
+ {
213
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ reservedOrderId );
214
+ $ query = $ this ->getAddToCartMutation ($ maskedQuoteId , 1 , $ sku );
215
+ $ response = $ this ->graphQlMutation ($ query , [], '' , $ headerMap );
216
+ self ::assertEmpty ($ response ['addProductsToCart ' ]['cart ' ]['items ' ]);
217
+ self ::assertArrayHasKey ('user_errors ' , $ response ['addProductsToCart ' ]);
218
+ self ::assertCount (1 , $ response ['addProductsToCart ' ]['user_errors ' ]);
219
+ self ::assertStringContainsString ($ sku , $ response ['addProductsToCart ' ]['user_errors ' ][0 ]['message ' ]);
220
+ self ::assertEquals ('PRODUCT_NOT_FOUND ' , $ response ['addProductsToCart ' ]['user_errors ' ][0 ]['code ' ]);
221
+ }
222
+
223
+ /**
224
+ * @return array
225
+ */
226
+ public function addProductNotAssignedToWebsiteDataProvider (): array
227
+ {
228
+ return [
229
+ ['test_order_1 ' , 'simple-2 ' , []],
230
+ ['test_order_1 ' , 'simple-2 ' , ['Store ' => 'default ' ]],
231
+ ['test_order_2 ' , 'simple-1 ' , ['Store ' => 'fixture_second_store ' ]],
232
+ ];
233
+ }
234
+
202
235
/**
203
236
* @return array
204
237
*/
@@ -246,7 +279,7 @@ private function getAddToCartMutation(
246
279
string $ maskedQuoteId ,
247
280
int $ qty ,
248
281
string $ sku ,
249
- string $ customizableOptions
282
+ string $ customizableOptions = ''
250
283
): string {
251
284
return <<<MUTATION
252
285
mutation {
@@ -279,6 +312,7 @@ private function getAddToCartMutation(
279
312
}
280
313
},
281
314
user_errors {
315
+ code
282
316
message
283
317
}
284
318
}
0 commit comments