Skip to content

Commit e56b9da

Browse files
author
Anna Bukatar
committed
ACP2E-1155: Refunding Issue Rest API
1 parent a069662 commit e56b9da

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Validation/QuantityValidatorTest.php

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function testValidateWithoutItems()
6868
{
6969
$creditmemoMock = $this->getMockBuilder(CreditmemoInterface::class)
7070
->disableOriginalConstructor()
71+
->addMethods(['isValidGrandTotal'])
7172
->getMockForAbstractClass();
7273
$creditmemoMock->expects($this->exactly(2))->method('getOrderId')
7374
->willReturn(1);
@@ -83,8 +84,8 @@ public function testValidateWithoutItems()
8384
->method('get')
8485
->with(1)
8586
->willReturn($orderMock);
86-
$creditmemoMock->expects($this->once())->method('getGrandTotal')
87-
->willReturn(0);
87+
$creditmemoMock->expects($this->once())->method('isValidGrandTotal')
88+
->willReturn(false);
8889
$this->assertEquals(
8990
[
9091
__('The credit memo\'s total must be positive.')
@@ -113,7 +114,10 @@ public function testValidateWithWrongItemId()
113114
$orderItemId = 1;
114115
$creditmemoMock = $this->getMockBuilder(CreditmemoInterface::class)
115116
->disableOriginalConstructor()
117+
->addMethods(['isValidGrandTotal'])
116118
->getMockForAbstractClass();
119+
$creditmemoMock->expects($this->once())->method('isValidGrandTotal')
120+
->willReturn(true);
117121
$creditmemoMock->expects($this->exactly(2))->method('getOrderId')
118122
->willReturn($orderId);
119123
$creditmemoItemMock = $this->getMockBuilder(
@@ -138,8 +142,6 @@ public function testValidateWithWrongItemId()
138142
->method('get')
139143
->with($orderId)
140144
->willReturn($orderMock);
141-
$creditmemoMock->expects($this->once())->method('getGrandTotal')
142-
->willReturn(12);
143145

144146
$this->assertEquals(
145147
[
@@ -171,15 +173,17 @@ public function testValidate(
171173
$sku,
172174
$total,
173175
array $expected,
174-
bool $isQtyDecimalAllowed
176+
bool $isQtyDecimalAllowed,
177+
bool $isValidGrandTotal
175178
) {
176179
$creditmemoMock = $this->getMockBuilder(CreditmemoInterface::class)
177180
->disableOriginalConstructor()
181+
->addMethods(['isValidGrandTotal'])
178182
->getMockForAbstractClass();
179183
$creditmemoMock->expects($this->exactly(2))->method('getOrderId')
180184
->willReturn($orderId);
181-
$creditmemoMock->expects($this->once())->method('getGrandTotal')
182-
->willReturn($total);
185+
$creditmemoMock->expects($this->once())->method('isValidGrandTotal')
186+
->willReturn($isValidGrandTotal);
183187
$creditmemoItemMock = $this->getMockBuilder(
184188
CreditmemoItemInterface::class
185189
)->disableOriginalConstructor()
@@ -239,7 +243,8 @@ public function dataProviderForValidateQty()
239243
'sku',
240244
'total' => 15,
241245
'expected' => [],
242-
'isQtyDecimalAllowed' => false
246+
'isQtyDecimalAllowed' => false,
247+
'isValidGrandTotal' => true
243248
],
244249
[
245250
'orderId' => 1,
@@ -249,7 +254,8 @@ public function dataProviderForValidateQty()
249254
'sku',
250255
'total' => 15,
251256
'expected' => [],
252-
'isQtyDecimalAllowed' => false
257+
'isQtyDecimalAllowed' => false,
258+
'isValidGrandTotal' => true
253259
],
254260
[
255261
'orderId' => 1,
@@ -264,7 +270,8 @@ public function dataProviderForValidateQty()
264270
$sku
265271
)
266272
],
267-
'isQtyDecimalAllowed' => false
273+
'isQtyDecimalAllowed' => false,
274+
'isValidGrandTotal' => true
268275
],
269276
[
270277
'orderId' => 1,
@@ -281,8 +288,20 @@ public function dataProviderForValidateQty()
281288
),
282289
__('The credit memo\'s total must be positive.')
283290
],
284-
'isQtyDecimalAllowed' => false
291+
'isQtyDecimalAllowed' => false,
292+
'isValidGrandTotal' => false
285293
],
294+
[
295+
'orderId' => 1,
296+
'orderItemId' => 1,
297+
'qtyToRequest' => 1,
298+
'qtyToRefund' => 1,
299+
'sku',
300+
'total' => 0,
301+
'expected' => [],
302+
'isQtyDecimalAllowed' => false,
303+
'isValidGrandTotal' => true
304+
]
286305
];
287306
}
288307
}

app/code/Magento/Sales/Test/Unit/Model/Order/Validation/CanRefundTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testCanCreditmemoNoMoney()
102102
$this->orderMock->expects($this->any())
103103
->method('getState')
104104
->willReturn(Order::STATE_PROCESSING);
105-
$this->orderMock->expects($this->once())
105+
$this->orderMock->expects($this->any())
106106
->method('getTotalPaid')
107107
->willReturn(15);
108108
$this->orderMock->expects($this->once())

0 commit comments

Comments
 (0)