Skip to content

Commit c03084c

Browse files
author
Bohdan Shevchenko
committed
MC-6425: [API] Order with state STATE_HOLDED should not be canceled
1 parent 3495a05 commit c03084c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,28 @@ public function testOrderCancel()
3636
$result = $this->_webApiCall($serviceInfo, $requestData);
3737
$this->assertTrue($result);
3838
}
39+
40+
/**
41+
* @magentoApiDataFixture Magento/Sales/_files/order_state_hold.php
42+
*/
43+
public function testOrderWithStateHoldedShouldNotBeCanceled()
44+
{
45+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
46+
$order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
47+
$serviceInfo = [
48+
'rest' => [
49+
'resourcePath' => '/V1/orders/' . $order->getId() . '/cancel',
50+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
51+
],
52+
'soap' => [
53+
'service' => self::SERVICE_NAME,
54+
'serviceVersion' => self::SERVICE_VERSION,
55+
'operation' => self::SERVICE_NAME . 'cancel',
56+
],
57+
];
58+
59+
$requestData = ['id' => $order->getId()];
60+
$result = $this->_webApiCall($serviceInfo, $requestData);
61+
$this->assertFalse($result);
62+
}
3963
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Sales\Model\Order;
8+
9+
require 'order.php';
10+
11+
/** @var Order $order */
12+
$order->setState(Order::STATE_HOLDED);
13+
$order->setStatus(Order::STATE_HOLDED);
14+
$order->save();

0 commit comments

Comments
 (0)