File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
api-functional/testsuite/Magento/GraphQl/Sales
integration/testsuite/Magento/Sales/_files Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,41 @@ public function testSimpleProductOutOfStock()
116
116
$ this ->assertWithDeletedProduct ($ productRepository , $ product );
117
117
}
118
118
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
+
119
154
/**
120
155
* Assert that simple product is not available.
121
156
*/
Original file line number Diff line number Diff line change
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 );
Original file line number Diff line number Diff line change
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 ' ;
You can’t perform that action at this time.
0 commit comments