Skip to content

Commit 91dfa0c

Browse files
author
Leonid Poluianov
committed
MC-32201: Reorder functionality
1 parent 7fb673c commit 91dfa0c

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/ReorderTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,41 @@ public function testSimpleProductOutOfStock()
116116
$this->assertWithDeletedProduct($productRepository, $product);
117117
}
118118

119+
/**
120+
* Test reorder when simple product qty is 0, with allowed backorders configured to below 0
121+
*
122+
* @magentoConfigFixture admin_store cataloginventory/item_options/backorders 1
123+
* @magentoConfigFixture admin_store cataloginventory/item_options/use_deferred_stock_update 0
124+
* @magentoApiDataFixture Magento/Sales/_files/order_with_zero_qty_product.php
125+
* @throws \Exception
126+
*/
127+
public function testBackorderWithOutOfStock()
128+
{
129+
$response = $this->makeReorderForDefaultCustomer();
130+
$expectedResponse = [
131+
'userInputErrors' => [],
132+
'cart' => [
133+
'email' => 'customer@example.com',
134+
'total_quantity' => 2,
135+
'items' => [
136+
[
137+
'quantity' => 1,
138+
'product' => [
139+
'sku' => 'simple'
140+
]
141+
],
142+
[
143+
'quantity' => 1,
144+
'product' => [
145+
'sku' => 'simple-2'
146+
]
147+
]
148+
],
149+
],
150+
];
151+
$this->assertResponseFields($response['reorderItems'], $expectedResponse);
152+
}
153+
119154
/**
120155
* Assert that simple product is not available.
121156
*/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\TestFramework\Helper\Bootstrap;
8+
9+
require __DIR__ . '/../../../Magento/Sales/_files/order_with_two_simple_products.php';
10+
11+
$customerIdFromFixture = 1;
12+
/** @var $order \Magento\Sales\Model\Order */
13+
$order->setCustomerId($customerIdFromFixture)->setCustomerIsGuest(false)->save();
14+
15+
// load product and set it out of stock
16+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $repository */
17+
$productRepository = Bootstrap::getObjectManager()->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
18+
$productSku = 'simple';
19+
/** @var \Magento\Catalog\Model\Product $product */
20+
$product = $productRepository->get($productSku);
21+
// set product qty to zero
22+
$product->setStockData(
23+
[
24+
'use_config_manage_stock' => 1,
25+
'qty' => 0,
26+
]
27+
);
28+
$productRepository->save($product);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require __DIR__ . '/../../../Magento/Sales/_files/order_with_two_simple_products_rollback.php';

0 commit comments

Comments
 (0)