Skip to content

Commit d01976a

Browse files
committed
MC-19432: REST API returns 404 error instead of 400
1 parent 73f98af commit d01976a

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

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

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
namespace Magento\Quote\Api;
88

9-
use Magento\Catalog\Api\ProductRepositoryInterface;
109
use Magento\Catalog\Model\CustomOptions\CustomOptionProcessor;
1110
use Magento\Framework\Webapi\Rest\Request;
1211
use Magento\Quote\Model\Quote;
@@ -84,10 +83,9 @@ public function testGetList()
8483
*/
8584
public function testAddItem()
8685
{
87-
$productSku = 'custom-design-simple-product';
88-
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
89-
$product = $productRepository->get($productSku);
90-
86+
/** @var \Magento\Catalog\Model\Product $product */
87+
$product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(2);
88+
$productSku = $product->getSku();
9189
/** @var Quote $quote */
9290
$quote = $this->objectManager->create(Quote::class);
9391
$quote->load('test_order_1', 'reserved_order_id');
@@ -112,59 +110,10 @@ public function testAddItem()
112110
],
113111
];
114112
$this->_webApiCall($serviceInfo, $requestData);
115-
$this->assertTrue($quote->hasProductId($product->getId()));
113+
$this->assertTrue($quote->hasProductId(2));
116114
$this->assertEquals(7, $quote->getItemByProduct($product)->getQty());
117115
}
118116

119-
/**
120-
* @expectedException \Exception
121-
* @expectedExceptionCode 400
122-
* @dataProvider failedAddItemDataProvider
123-
* @param array|null $cartItem
124-
*/
125-
public function testFailedAddItem(?array $cartItem)
126-
{
127-
$serviceInfo = [
128-
'rest' => [
129-
'resourcePath' => self::RESOURCE_PATH . 'mine/items',
130-
'httpMethod' => Request::HTTP_METHOD_POST,
131-
],
132-
'soap' => [
133-
'service' => self::SERVICE_NAME,
134-
'serviceVersion' => self::SERVICE_VERSION,
135-
'operation' => self::SERVICE_NAME . 'Save',
136-
],
137-
];
138-
$requestData = [
139-
'cartItem' => $cartItem,
140-
];
141-
142-
$this->expectException(\Exception::class);
143-
$this->expectExceptionCode(TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP ? 0 : 400);
144-
$this->_webApiCall($serviceInfo, $requestData);
145-
}
146-
147-
/**
148-
* @return array
149-
*/
150-
public function failedAddItemDataProvider(): array
151-
{
152-
return [
153-
'absent cart item' => [
154-
null,
155-
],
156-
'empty cart item' => [
157-
[],
158-
],
159-
'absent cart id' => [
160-
[
161-
'sku' => 'custom-design-simple-product',
162-
'qty' => 7,
163-
],
164-
],
165-
];
166-
}
167-
168117
/**
169118
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
170119
*/

0 commit comments

Comments
 (0)