@@ -111,15 +111,10 @@ public function testSetQtyDecimalException()
111
111
$ orderItemMock ->expects ($ this ->once ())
112
112
->method ('getQtyToRefund ' )
113
113
->willReturn ($ orderItemQty );
114
- $ orderItemMock ->expects ($ this ->atLeastOnce ())
115
- ->method ('load ' )
116
- ->willReturnSelf ();
117
- $ this ->orderItemFactoryMock ->expects ($ this ->atLeastOnce ())
118
- ->method ('create ' )
119
- ->willReturn ($ orderItemMock );
120
114
$ this ->item ->setData (CreditmemoItemInterface::NAME , $ name );
121
115
$ this ->item ->setOrderItem ($ orderItemMock );
122
116
$ this ->item ->setQty ($ qty );
117
+ $ this ->item ->getQty ();
123
118
}
124
119
125
120
/**
@@ -141,15 +136,10 @@ public function testSetQtyNumericException()
141
136
$ orderItemMock ->expects ($ this ->once ())
142
137
->method ('getQtyToRefund ' )
143
138
->willReturn ($ orderItemQty );
144
- $ orderItemMock ->expects ($ this ->atLeastOnce ())
145
- ->method ('load ' )
146
- ->willReturnSelf ();
147
- $ this ->orderItemFactoryMock ->expects ($ this ->atLeastOnce ())
148
- ->method ('create ' )
149
- ->willReturn ($ orderItemMock );
150
139
$ this ->item ->setData (CreditmemoItemInterface::NAME , $ name );
151
140
$ this ->item ->setOrderItem ($ orderItemMock );
152
141
$ this ->item ->setQty ($ qty );
142
+ $ this ->item ->getQty ();
153
143
}
154
144
155
145
public function testSetQty ()
@@ -166,12 +156,6 @@ public function testSetQty()
166
156
$ orderItemMock ->expects ($ this ->once ())
167
157
->method ('getQtyToRefund ' )
168
158
->willReturn ($ orderItemQty );
169
- $ orderItemMock ->expects ($ this ->atLeastOnce ())
170
- ->method ('load ' )
171
- ->willReturnSelf ();
172
- $ this ->orderItemFactoryMock ->expects ($ this ->atLeastOnce ())
173
- ->method ('create ' )
174
- ->willReturn ($ orderItemMock );
175
159
$ this ->item ->setOrderItem ($ orderItemMock );
176
160
$ this ->item ->setQty ($ qty );
177
161
$ this ->assertEquals ($ qty , $ this ->item ->getQty ());
@@ -209,19 +193,19 @@ public function testRegister()
209
193
$ orderItemMock ->expects ($ this ->once ())
210
194
->method ('getBaseDiscountRefunded ' )
211
195
->willReturn (1 );
212
- $ data = [
213
- 'qty ' => 1 ,
214
- 'tax_amount ' => 1 ,
215
- 'base_tax_amount ' => 1 ,
216
- 'discount_tax_compensation_amount ' => 1 ,
217
- 'base_discount_tax_compensation_amount ' => 1 ,
218
- 'row_total ' => 1 ,
219
- 'base_row_total ' => 1 ,
220
- 'discount_amount ' => 1 ,
221
- 'base_discount_amount ' => 1
222
- ];
196
+ $ orderItemMock ->expects ($ this ->once ())
197
+ ->method ('getQtyToRefund ' )
198
+ ->willReturn (1 );
199
+ $ this ->item ->setQty (1 );
200
+ $ this ->item ->setTaxAmount (1 );
201
+ $ this ->item ->setBaseTaxAmount (1 );
202
+ $ this ->item ->setDiscountTaxCompensationAmount (1 );
203
+ $ this ->item ->setBaseDiscountTaxCompensationAmount (1 );
204
+ $ this ->item ->setRowTotal (1 );
205
+ $ this ->item ->setBaseRowTotal (1 );
206
+ $ this ->item ->setDiscountAmount (1 );
207
+ $ this ->item ->setBaseDiscountAmount (1 );
223
208
$ this ->item ->setOrderItem ($ orderItemMock );
224
- $ this ->item ->setData ($ data );
225
209
$ result = $ this ->item ->register ();
226
210
$ this ->assertInstanceOf ('Magento\Sales\Model\Order\Creditmemo\Item ' , $ result );
227
211
}
@@ -230,19 +214,6 @@ public function testCancel()
230
214
{
231
215
$ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
232
216
->disableOriginalConstructor ()
233
- ->setMethods (
234
- [
235
- 'setQtyRefunded ' ,
236
- 'getQtyRefunded ' ,
237
- 'getTaxRefunded ' ,
238
- 'getBaseTaxAmount ' ,
239
- 'getQtyOrdered ' ,
240
- 'setTaxRefunded ' ,
241
- 'setDiscountTaxCompensationRefunded ' ,
242
- 'getDiscountTaxCompensationRefunded ' ,
243
- 'getDiscountTaxCompensationAmount '
244
- ]
245
- )
246
217
->getMock ();
247
218
$ orderItemMock ->expects ($ this ->once ())
248
219
->method ('getQtyRefunded ' )
@@ -272,8 +243,11 @@ public function testCancel()
272
243
$ orderItemMock ->expects ($ this ->once ())
273
244
->method ('getDiscountTaxCompensationAmount ' )
274
245
->willReturn (10 );
246
+ $ orderItemMock ->expects ($ this ->once ())
247
+ ->method ('getQtyToRefund ' )
248
+ ->willReturn (1 );
275
249
276
- $ this ->item ->setData ( ' qty ' , 1 );
250
+ $ this ->item ->setQty ( 1 );
277
251
$ this ->item ->setOrderItem ($ orderItemMock );
278
252
$ result = $ this ->item ->cancel ();
279
253
$ this ->assertInstanceOf ('Magento\Sales\Model\Order\Creditmemo\Item ' , $ result );
@@ -342,7 +316,7 @@ function ($arg) {
342
316
->method ('getQtyToRefund ' )
343
317
->willReturn ($ qtyAvailable );
344
318
345
- $ this ->item ->setData ( ' qty ' , $ qty );
319
+ $ this ->item ->setQty ( $ qty );
346
320
$ this ->item ->setCreditmemo ($ creditmemoMock );
347
321
$ this ->item ->setOrderItem ($ orderItemMock );
348
322
$ result = $ this ->item ->calcRowTotal ();
@@ -362,4 +336,38 @@ public function calcRowTotalDataProvider()
362
336
'qty 0 ' => [0 ],
363
337
];
364
338
}
339
+
340
+ public function testSetQtyWithProcess ()
341
+ {
342
+ $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
343
+ ->disableOriginalConstructor ()
344
+ ->setMethods (['getQtyToRefund ' ])
345
+ ->getMock ();
346
+ $ orderItemMock ->expects ($ this ->once ())
347
+ ->method ('getQtyToRefund ' )
348
+ ->willReturn (2 );
349
+
350
+ $ this ->item ->setOrderItem ($ orderItemMock );
351
+
352
+ $ this ->item ->setQty (2 );
353
+ $ this ->assertEquals (2 , $ this ->item ->getQty ());
354
+ }
355
+
356
+ public function testSetQtyWithProcessDecimal ()
357
+ {
358
+ $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
359
+ ->disableOriginalConstructor ()
360
+ ->setMethods (['getQtyToRefund ' , 'getIsQtyDecimal ' ])
361
+ ->getMock ();
362
+ $ orderItemMock ->expects ($ this ->once ())
363
+ ->method ('getQtyToRefund ' )
364
+ ->willReturn (3.3 );
365
+ $ orderItemMock ->expects ($ this ->once ())
366
+ ->method ('getIsQtyDecimal ' )
367
+ ->willReturn (true );
368
+ $ this ->item ->setOrderItem ($ orderItemMock );
369
+
370
+ $ this ->item ->setQty (3.3 );
371
+ $ this ->assertEquals (3.3 , $ this ->item ->getQty ());
372
+ }
365
373
}
0 commit comments