Skip to content

Commit ab52d4b

Browse files
author
Joan He
committed
MC-5570: Different Order Status of two created credit memo orders
- fix tests
1 parent ecee1df commit ab52d4b

File tree

9 files changed

+49
-31
lines changed

9 files changed

+49
-31
lines changed

app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ class StateTest extends \PHPUnit\Framework\TestCase
2424

2525
protected function setUp()
2626
{
27-
$this->orderMock = $this->createPartialMock(\Magento\Sales\Model\Order::class, [
27+
$this->orderMock = $this->createPartialMock(
28+
\Magento\Sales\Model\Order::class,
29+
[
2830
'__wakeup',
2931
'getId',
3032
'hasCustomerNoteNotify',
@@ -41,7 +43,8 @@ protected function setUp()
4143
'hasForcedCanCreditmemo',
4244
'getIsInProcess',
4345
'getConfig',
44-
]);
46+
]
47+
);
4548
$this->orderMock->expects($this->any())
4649
->method('getConfig')
4750
->willReturnSelf();
@@ -64,6 +67,7 @@ protected function setUp()
6467
* @param string $expectedState
6568
* @param int $callSetStateNum
6669
* @dataProvider stateCheckDataProvider
70+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6771
*/
6872
public function testCheck(
6973
bool $canCreditmemo,

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,21 @@ public function testOrdersQuery()
8383
$actualData = $response['customerOrders']['items'];
8484

8585
foreach ($expectedData as $key => $data) {
86-
$this->assertEquals($data['increment_id'], $actualData[$key]['increment_id']);
87-
$this->assertEquals($data['grand_total'], $actualData[$key]['grand_total']);
88-
$this->assertEquals($data['status'], $actualData[$key]['status']);
86+
$this->assertEquals(
87+
$data['increment_id'],
88+
$actualData[$key]['increment_id'],
89+
"increment_id is different than the expected for order - " . $data['increment_id']
90+
);
91+
$this->assertEquals(
92+
$data['grand_total'],
93+
$actualData[$key]['grand_total'],
94+
"grand_total is different than the expected for order - " . $data['increment_id']
95+
);
96+
$this->assertEquals(
97+
$data['status'],
98+
$actualData[$key]['status'],
99+
"status is different than the expected for order - " . $data['increment_id']
100+
);
89101
}
90102
}
91103

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function testInvoke()
116116
$this->assertNotEmpty($result);
117117
$order = $this->objectManager->get(OrderRepositoryInterface::class)->get($order->getId());
118118
//Totally refunded orders still can be processed and shipped.
119-
$this->assertEquals(Order::STATE_PROCESSING, $order->getState());
119+
$this->assertEquals(Order::STATE_CLOSED, $order->getState());
120120
}
121121

122122
private function getItemsForRest($order)
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,15 @@
1111
use Magento\Mtf\Constraint\AbstractConstraint;
1212

1313
/**
14-
* Class AssertOrderCancelAndSuccessMassActionFailMessage
14+
* Class AssertOrderCancelMassActionFailMessage
1515
* Assert cancel fail message is displayed on order index page
1616
*/
17-
class AssertOrderCancelMassActionPartialFailMessage extends AbstractConstraint
17+
class AssertOrderCancelMassActionFailMessage extends AbstractConstraint
1818
{
19-
/**
20-
* Message displayed after cancel order from archive
21-
*/
22-
const SUCCESS_MESSAGE = 'We canceled 1 order(s).';
23-
2419
/**
2520
* Text value to be checked
2621
*/
27-
const FAIL_CANCEL_MESSAGE = '1 order(s) cannot be canceled.';
22+
const FAIL_CANCEL_MESSAGE = 'You cannot cancel the order(s).';
2823

2924
/**
3025
* Assert cancel fail message is displayed on order index page
@@ -38,10 +33,6 @@ public function processAssert(OrderIndex $orderIndex)
3833
self::FAIL_CANCEL_MESSAGE,
3934
$orderIndex->getMessagesBlock()->getErrorMessage()
4035
);
41-
\PHPUnit\Framework\Assert::assertEquals(
42-
self::SUCCESS_MESSAGE,
43-
$orderIndex->getMessagesBlock()->getSuccessMessage()
44-
);
4536
}
4637

4738
/**
@@ -51,6 +42,6 @@ public function processAssert(OrderIndex $orderIndex)
5142
*/
5243
public function toString()
5344
{
54-
return 'Cancel and success fail message is displayed on order index page.';
45+
return 'Cancel fail message is displayed on order index page.';
5546
}
5647
}

dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCorrect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function processAssert(
3939
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
4040
$infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
4141
\PHPUnit\Framework\Assert::assertEquals(
42-
$infoTab->getOrderStatus(),
43-
$orderStatus
42+
$orderStatus,
43+
$infoTab->getOrderStatus()
4444
);
4545
}
4646

dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.xml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
99
<testCase name="Magento\Sales\Test\TestCase\MassOrdersUpdateTest" summary="Mass Update Orders" ticketId="MAGETWO-27897">
1010
<variation name="MassOrdersUpdateTestVariation1">
11-
<data name="tag" xsi:type="string">stable:no</data>
1211
<data name="description" xsi:type="string">cancel orders in status Pending and Processing</data>
1312
<data name="steps" xsi:type="string">-</data>
1413
<data name="action" xsi:type="string">Cancel</data>
@@ -18,21 +17,21 @@
1817
<constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" />
1918
</variation>
2019
<variation name="MassOrdersUpdateTestVariation2">
21-
<data name="description" xsi:type="string">try to cancel orders in status Complete, Canceled</data>
20+
<data name="description" xsi:type="string">try to cancel orders in status Complete, Closed</data>
2221
<data name="steps" xsi:type="string">invoice, shipment|invoice, credit memo</data>
2322
<data name="action" xsi:type="string">Cancel</data>
2423
<data name="ordersCount" xsi:type="string">2</data>
25-
<data name="resultStatuses" xsi:type="string">Complete,Canceled</data>
26-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionPartialFailMessage" />
24+
<data name="resultStatuses" xsi:type="string">Complete,Closed</data>
25+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionFailMessage" />
2726
<constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" />
2827
</variation>
2928
<variation name="MassOrdersUpdateTestVariation3">
30-
<data name="description" xsi:type="string">try to cancel orders in status Pending, Closed</data>
29+
<data name="description" xsi:type="string">try to cancel orders in status Processing, Closed</data>
3130
<data name="steps" xsi:type="string">invoice|invoice, credit memo</data>
3231
<data name="action" xsi:type="string">Cancel</data>
3332
<data name="ordersCount" xsi:type="string">2</data>
34-
<data name="resultStatuses" xsi:type="string">Processing,Canceled</data>
35-
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionPartialFailMessage" />
33+
<data name="resultStatuses" xsi:type="string">Processing,Closed</data>
34+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionFailMessage" />
3635
<constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" />
3736
</variation>
3837
<variation name="MassOrdersUpdateTestVariation4">
@@ -45,7 +44,6 @@
4544
<constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" />
4645
</variation>
4746
<variation name="MassOrdersUpdateTestVariation5">
48-
<data name="tag" xsi:type="string">stable:no</data>
4947
<data name="description" xsi:type="string">Try to put order in status Complete on Hold</data>
5048
<data name="steps" xsi:type="string">invoice, shipment</data>
5149
<data name="action" xsi:type="string">Hold</data>

dev/tests/integration/testsuite/Magento/Paypal/Model/IpnTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testProcessIpnRequestFullRefund()
6565
$creditmemo = current($creditmemoItems);
6666

6767
//Totally refunded orders still can be shipped
68-
$this->assertEquals(Order::STATE_PROCESSING, $order->getState()) ;
68+
$this->assertEquals(Order::STATE_CLOSED, $order->getState()) ;
6969
$this->assertEquals(1, count($creditmemoItems));
7070
$this->assertEquals(Creditmemo::STATE_REFUNDED, $creditmemo->getState());
7171
$this->assertEquals(10, $order->getSubtotalRefunded());
@@ -148,7 +148,7 @@ public function testProcessIpnRequestRestRefund()
148148
$creditmemoItems = $order->getCreditmemosCollection()->getItems();
149149

150150
//Totally refunded orders still can be shipped
151-
$this->assertEquals(Order::STATE_PROCESSING, $order->getState()) ;
151+
$this->assertEquals(Order::STATE_CLOSED, $order->getState()) ;
152152
$this->assertEquals(1, count($creditmemoItems));
153153
$this->assertEquals(10, $order->getSubtotalRefunded());
154154
$this->assertEquals(10, $order->getBaseSubtotalRefunded());

dev/tests/integration/testsuite/Magento/Sales/_files/order_with_shipping_and_invoice.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
$items[$orderItem->getId()] = $orderItem->getQtyOrdered();
4545
}
4646
$shipment = $objectManager->get(ShipmentFactory::class)->create($order, $items);
47+
$shipment->register();
4748

4849
$transaction->addObject($invoice)->addObject($shipment)->addObject($order)->save();

dev/tests/integration/testsuite/Magento/Sales/_files/orders_with_customer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
'grand_total' => 130.00,
3434
'base_grand_total' => 130.00,
3535
'subtotal' => 130.00,
36+
'total_paid' => 130.00,
3637
'store_id' => 0,
3738
'website_id' => 0,
3839
'payment' => $payment
@@ -55,6 +56,7 @@
5556
'grand_total' => 150.00,
5657
'base_grand_total' => 150.00,
5758
'subtotal' => 150.00,
59+
'total_paid' => 150.00,
5860
'store_id' => 1,
5961
'website_id' => 1,
6062
'payment' => $payment
@@ -66,6 +68,7 @@
6668
'grand_total' => 160.00,
6769
'base_grand_total' => 160.00,
6870
'subtotal' => 160.00,
71+
'total_paid' => 160.00,
6972
'store_id' => 1,
7073
'website_id' => 1,
7174
'payment' => $payment
@@ -89,6 +92,15 @@
8992
$shippingAddress = clone $billingAddress;
9093
$shippingAddress->setId(null)->setAddressType('shipping');
9194

95+
/** @var Order\Item $orderItem */
96+
$orderItem = $objectManager->create(Order\Item::class);
97+
$orderItem->setProductId($product->getId())
98+
->setQtyOrdered(2)
99+
->setBasePrice($product->getPrice())
100+
->setPrice($product->getPrice())
101+
->setRowTotal($product->getPrice())
102+
->setProductType('simple');
103+
92104
$order
93105
->setData($orderData)
94106
->addItem($orderItem)

0 commit comments

Comments
 (0)