@@ -92,71 +92,9 @@ public function testGetOrderItemFromFactory()
92
92
$ this ->assertInstanceOf ('Magento\Sales\Model\Order\Item ' , $ result );
93
93
}
94
94
95
- /**
96
- * @expectedException \Magento\Framework\Exception\LocalizedException
97
- * @expectedExceptionMessage We found an invalid quantity to refund item "test_item_name".
98
- */
99
- public function testSetQtyDecimalException ()
100
- {
101
- $ qty = 100 ;
102
- $ orderItemQty = 10 ;
103
- $ name = 'test_item_name ' ;
104
-
105
- $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
106
- ->disableOriginalConstructor ()
107
- ->getMock ();
108
- $ orderItemMock ->expects ($ this ->once ())
109
- ->method ('getIsQtyDecimal ' )
110
- ->willReturn (true );
111
- $ orderItemMock ->expects ($ this ->once ())
112
- ->method ('getQtyToRefund ' )
113
- ->willReturn ($ orderItemQty );
114
- $ this ->item ->setData (CreditmemoItemInterface::NAME , $ name );
115
- $ this ->item ->setOrderItem ($ orderItemMock );
116
- $ this ->item ->setQty ($ qty );
117
- $ this ->item ->getQty ();
118
- }
119
-
120
- /**
121
- * @expectedException \Magento\Framework\Exception\LocalizedException
122
- * @expectedExceptionMessage We found an invalid quantity to refund item "test_item_name2".
123
- */
124
- public function testSetQtyNumericException ()
125
- {
126
- $ qty = 100 ;
127
- $ orderItemQty = 10 ;
128
- $ name = 'test_item_name2 ' ;
129
-
130
- $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
131
- ->disableOriginalConstructor ()
132
- ->getMock ();
133
- $ orderItemMock ->expects ($ this ->once ())
134
- ->method ('getIsQtyDecimal ' )
135
- ->willReturn (false );
136
- $ orderItemMock ->expects ($ this ->once ())
137
- ->method ('getQtyToRefund ' )
138
- ->willReturn ($ orderItemQty );
139
- $ this ->item ->setData (CreditmemoItemInterface::NAME , $ name );
140
- $ this ->item ->setOrderItem ($ orderItemMock );
141
- $ this ->item ->setQty ($ qty );
142
- $ this ->item ->getQty ();
143
- }
144
-
145
95
public function testSetQty ()
146
96
{
147
97
$ qty = 10 ;
148
- $ orderItemQty = 100 ;
149
-
150
- $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
151
- ->disableOriginalConstructor ()
152
- ->getMock ();
153
- $ orderItemMock ->expects ($ this ->once ())
154
- ->method ('getIsQtyDecimal ' )
155
- ->willReturn (false );
156
- $ orderItemMock ->expects ($ this ->once ())
157
- ->method ('getQtyToRefund ' )
158
- ->willReturn ($ orderItemQty );
159
- $ this ->item ->setOrderItem ($ orderItemMock );
160
98
$ this ->item ->setQty ($ qty );
161
99
$ this ->assertEquals ($ qty , $ this ->item ->getQty ());
162
100
}
@@ -210,6 +148,26 @@ public function testRegister()
210
148
$ this ->assertInstanceOf ('Magento\Sales\Model\Order\Creditmemo\Item ' , $ result );
211
149
}
212
150
151
+ /**
152
+ * @expectedException \Magento\Framework\Exception\LocalizedException
153
+ * @expectedExceptionMessage We found an invalid quantity to refund item "test".
154
+ */
155
+ public function testRegisterWithException ()
156
+ {
157
+ $ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
158
+ ->disableOriginalConstructor ()
159
+ ->setMethods (['getQtyRefunded ' ])
160
+ ->getMock ();
161
+ $ orderItemMock ->expects ($ this ->once ())
162
+ ->method ('getQtyRefunded ' )
163
+ ->willReturn (1 );
164
+ $ this ->item ->setQty (2 );
165
+ $ this ->item ->setOrderItem ($ orderItemMock );
166
+ $ this ->item ->setName ('test ' );
167
+ $ result = $ this ->item ->register ();
168
+ $ this ->assertInstanceOf ('Magento\Sales\Model\Order\Creditmemo\Item ' , $ result );
169
+ }
170
+
213
171
public function testCancel ()
214
172
{
215
173
$ orderItemMock = $ this ->getMockBuilder ('Magento\Sales\Model\Order\Item ' )
@@ -336,38 +294,4 @@ public function calcRowTotalDataProvider()
336
294
'qty 0 ' => [0 ],
337
295
];
338
296
}
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
- }
373
297
}
0 commit comments