@@ -165,6 +165,57 @@ public function testAddToCartGroupedCustomQuantity(): void
165
165
}
166
166
}
167
167
168
+ /**
169
+ * Test adding grouped product when qty for grouped_options not specified.
170
+ *
171
+ * @magentoApiDataFixture Magento/GroupedProduct/_files/product_grouped_with_simple.php
172
+ * @magentoApiDataFixture Magento/Customer/_files/customer_one_address.php
173
+ * @return void
174
+ */
175
+ public function testAddToCartGroupedCustomQuantityNotAllParamsSpecified (): void
176
+ {
177
+ $ this ->_markTestAsRestOnly ();
178
+
179
+ $ productId = $ this ->productResource ->getIdBySku ('simple_11 ' );
180
+
181
+ // Get customer ID token
182
+ /** @var CustomerTokenServiceInterface $customerTokenService */
183
+ $ customerTokenService = $ this ->objectManager ->create (CustomerTokenServiceInterface::class);
184
+ $ token = $ customerTokenService ->createCustomerAccessToken (
185
+
186
+ 'password '
187
+ );
188
+
189
+ // Creating empty cart for registered customer.
190
+ $ serviceInfo = [
191
+ 'rest ' => ['resourcePath ' => '/V1/carts/mine ' , 'httpMethod ' => Request::HTTP_METHOD_POST , 'token ' => $ token ]
192
+ ];
193
+
194
+ $ quoteId = $ this ->_webApiCall ($ serviceInfo , ['customerId ' => 999 ]); // customerId 999 will get overridden
195
+ $ this ->assertGreaterThan (0 , $ quoteId );
196
+
197
+ // Adding item to the cart
198
+ $ requestData = [
199
+ 'cartItem ' => [
200
+ 'quote_id ' => $ quoteId ,
201
+ 'sku ' => 'grouped ' ,
202
+ 'qty ' => 1 ,
203
+ 'product_option ' => [
204
+ 'extension_attributes ' => [
205
+ 'grouped_options ' => [
206
+ ['id ' => $ productId ],
207
+ ]
208
+ ]
209
+ ]
210
+ ]
211
+ ];
212
+
213
+ $ this ->expectException (\Exception::class);
214
+ $ this ->expectExceptionMessage ('Please specify id and qty for grouped options. ' );
215
+
216
+ $ this ->_webApiCall ($ this ->getServiceInfoAddToCart ($ token ), $ requestData );
217
+ }
218
+
168
219
/**
169
220
* Returns service info add to cart
170
221
*
0 commit comments