@@ -68,6 +68,7 @@ public function testValidateWithoutItems()
68
68
{
69
69
$ creditmemoMock = $ this ->getMockBuilder (CreditmemoInterface::class)
70
70
->disableOriginalConstructor ()
71
+ ->addMethods (['isValidGrandTotal ' ])
71
72
->getMockForAbstractClass ();
72
73
$ creditmemoMock ->expects ($ this ->exactly (2 ))->method ('getOrderId ' )
73
74
->willReturn (1 );
@@ -83,8 +84,8 @@ public function testValidateWithoutItems()
83
84
->method ('get ' )
84
85
->with (1 )
85
86
->willReturn ($ orderMock );
86
- $ creditmemoMock ->expects ($ this ->once ())->method ('getGrandTotal ' )
87
- ->willReturn (0 );
87
+ $ creditmemoMock ->expects ($ this ->once ())->method ('isValidGrandTotal ' )
88
+ ->willReturn (false );
88
89
$ this ->assertEquals (
89
90
[
90
91
__ ('The credit memo \'s total must be positive. ' )
@@ -113,7 +114,10 @@ public function testValidateWithWrongItemId()
113
114
$ orderItemId = 1 ;
114
115
$ creditmemoMock = $ this ->getMockBuilder (CreditmemoInterface::class)
115
116
->disableOriginalConstructor ()
117
+ ->addMethods (['isValidGrandTotal ' ])
116
118
->getMockForAbstractClass ();
119
+ $ creditmemoMock ->expects ($ this ->once ())->method ('isValidGrandTotal ' )
120
+ ->willReturn (true );
117
121
$ creditmemoMock ->expects ($ this ->exactly (2 ))->method ('getOrderId ' )
118
122
->willReturn ($ orderId );
119
123
$ creditmemoItemMock = $ this ->getMockBuilder (
@@ -138,8 +142,6 @@ public function testValidateWithWrongItemId()
138
142
->method ('get ' )
139
143
->with ($ orderId )
140
144
->willReturn ($ orderMock );
141
- $ creditmemoMock ->expects ($ this ->once ())->method ('getGrandTotal ' )
142
- ->willReturn (12 );
143
145
144
146
$ this ->assertEquals (
145
147
[
@@ -171,15 +173,17 @@ public function testValidate(
171
173
$ sku ,
172
174
$ total ,
173
175
array $ expected ,
174
- bool $ isQtyDecimalAllowed
176
+ bool $ isQtyDecimalAllowed ,
177
+ bool $ isValidGrandTotal
175
178
) {
176
179
$ creditmemoMock = $ this ->getMockBuilder (CreditmemoInterface::class)
177
180
->disableOriginalConstructor ()
181
+ ->addMethods (['isValidGrandTotal ' ])
178
182
->getMockForAbstractClass ();
179
183
$ creditmemoMock ->expects ($ this ->exactly (2 ))->method ('getOrderId ' )
180
184
->willReturn ($ orderId );
181
- $ creditmemoMock ->expects ($ this ->once ())->method ('getGrandTotal ' )
182
- ->willReturn ($ total );
185
+ $ creditmemoMock ->expects ($ this ->once ())->method ('isValidGrandTotal ' )
186
+ ->willReturn ($ isValidGrandTotal );
183
187
$ creditmemoItemMock = $ this ->getMockBuilder (
184
188
CreditmemoItemInterface::class
185
189
)->disableOriginalConstructor ()
@@ -239,7 +243,8 @@ public function dataProviderForValidateQty()
239
243
'sku ' ,
240
244
'total ' => 15 ,
241
245
'expected ' => [],
242
- 'isQtyDecimalAllowed ' => false
246
+ 'isQtyDecimalAllowed ' => false ,
247
+ 'isValidGrandTotal ' => true
243
248
],
244
249
[
245
250
'orderId ' => 1 ,
@@ -249,7 +254,8 @@ public function dataProviderForValidateQty()
249
254
'sku ' ,
250
255
'total ' => 15 ,
251
256
'expected ' => [],
252
- 'isQtyDecimalAllowed ' => false
257
+ 'isQtyDecimalAllowed ' => false ,
258
+ 'isValidGrandTotal ' => true
253
259
],
254
260
[
255
261
'orderId ' => 1 ,
@@ -264,7 +270,8 @@ public function dataProviderForValidateQty()
264
270
$ sku
265
271
)
266
272
],
267
- 'isQtyDecimalAllowed ' => false
273
+ 'isQtyDecimalAllowed ' => false ,
274
+ 'isValidGrandTotal ' => true
268
275
],
269
276
[
270
277
'orderId ' => 1 ,
@@ -281,8 +288,20 @@ public function dataProviderForValidateQty()
281
288
),
282
289
__ ('The credit memo \'s total must be positive. ' )
283
290
],
284
- 'isQtyDecimalAllowed ' => false
291
+ 'isQtyDecimalAllowed ' => false ,
292
+ 'isValidGrandTotal ' => false
285
293
],
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
+ ]
286
305
];
287
306
}
288
307
}
0 commit comments