Skip to content

Commit 73af54a

Browse files
committed
Correcting Unit tests
1 parent 02dc040 commit 73af54a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testCollect()
7474
$this->orderMock->expects($this->once())
7575
->method('getBaseShippingDiscountAmount')
7676
->willReturn(1);
77-
$this->orderMock->expects($this->exactly(2))
77+
$this->orderMock->expects($this->exactly(3))
7878
->method('getBaseShippingAmount')
7979
->willReturn(1);
8080
$this->orderMock->expects($this->once())
@@ -150,7 +150,7 @@ public function testCollectNoBaseShippingAmount()
150150
$this->orderMock->expects($this->once())
151151
->method('getBaseShippingDiscountAmount')
152152
->willReturn(1);
153-
$this->orderMock->expects($this->exactly(2))
153+
$this->orderMock->expects($this->exactly(3))
154154
->method('getBaseShippingAmount')
155155
->willReturn(1);
156156
$this->orderMock->expects($this->once())
@@ -269,4 +269,30 @@ public function testCollectZeroShipping()
269269
);
270270
$this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
271271
}
272+
273+
/**
274+
* @expectedException \Magento\Framework\Exception\LocalizedException
275+
* @expectedExceptionMessage You can not refund shipping if there is no shipping amount.
276+
*/
277+
public function testCollectNonZeroShipping()
278+
{
279+
$this->creditmemoMock->expects($this->once())
280+
->method('setDiscountAmount')
281+
->willReturnSelf();
282+
$this->creditmemoMock->expects($this->once())
283+
->method('setBaseDiscountAmount')
284+
->willReturnSelf();
285+
$this->creditmemoMock->expects($this->once())
286+
->method('getOrder')
287+
->willReturn($this->orderMock);
288+
$this->creditmemoMock->expects($this->once())
289+
->method('getBaseShippingAmount')
290+
->willReturn('10.0000');
291+
$this->orderMock->expects($this->never())
292+
->method('getBaseShippingDiscountAmount');
293+
$this->orderMock->expects($this->once())
294+
->method('getBaseShippingAmount')
295+
->willReturn( '0.0000');
296+
$this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
297+
}
272298
}

0 commit comments

Comments
 (0)