@@ -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}
0 commit comments