Skip to content

Commit bdfe7ec

Browse files
27845 test when not all params specified in grouped_options
1 parent 0ace0c3 commit bdfe7ec

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

dev/tests/api-functional/testsuite/Magento/Quote/Api/CartAddingItemsTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,57 @@ public function testAddToCartGroupedCustomQuantity(): void
165165
}
166166
}
167167

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+
168219
/**
169220
* Returns service info add to cart
170221
*

0 commit comments

Comments
 (0)