9
9
10
10
use Magento \Sales \Model \Order ;
11
11
use Magento \Sales \Model \Order \Address ;
12
+ use Magento \Sales \Model \Order \Item ;
12
13
use Magento \Sales \Model \ResourceModel \Order \Address \Collection ;
13
14
use Magento \Sales \Model \ResourceModel \Order \Handler \State ;
14
15
use PHPUnit \Framework \MockObject \MockObject ;
@@ -45,7 +46,8 @@ protected function setUp(): void
45
46
'getIsVirtual ' ,
46
47
'getIsNotVirtual ' ,
47
48
'getStatus ' ,
48
- 'getAllItems '
49
+ 'getAllItems ' ,
50
+ 'getTotalQtyOrdered '
49
51
]
50
52
)
51
53
->disableOriginalConstructor ()
@@ -105,14 +107,25 @@ public function testCheck(
105
107
->willReturn ($ isInProcess );
106
108
$ this ->orderMock ->method ('getIsNotVirtual ' )
107
109
->willReturn ($ isNotVirtual );
110
+ $ shippedItem = $ this ->createMock (Item::class);
111
+ $ shippedItem ->expects ($ this ->any ())->method ('getQtyShipped ' )->willReturn (1 );
112
+ $ shippedItem ->expects ($ this ->any ())->method ('getQtyRefunded ' )->willReturn (1 );
113
+ $ shippedItem ->expects ($ this ->any ())->method ('getProductType ' )->willReturn ('simple ' );
114
+ $ shippedItem ->expects ($ this ->any ())->method ('canShip ' )->willReturn (false );
115
+ $ shippableItem = $ this ->createMock (Item::class);
116
+ $ shippableItem ->expects ($ this ->any ())->method ('getQtyShipped ' )->willReturn (0 );
117
+ $ shippableItem ->expects ($ this ->any ())->method ('getQtyRefunded ' )->willReturn (0 );
118
+ $ shippableItem ->expects ($ this ->any ())->method ('getProductType ' )->willReturn ('simple ' );
119
+ $ shippableItem ->expects ($ this ->any ())->method ('canShip ' )->willReturn (true );
108
120
$ this ->orderMock ->method ('getAllItems ' )
109
- ->willReturn ([]);
121
+ ->willReturn ([$ shippedItem , $ shippableItem ]);
110
122
if (!$ isNotVirtual ) {
111
123
$ this ->orderMock ->method ('getIsVirtual ' )
112
124
->willReturn (!$ isNotVirtual );
113
125
$ this ->orderMock ->method ('getStatus ' )
114
126
->willReturn ($ expectedState );
115
127
}
128
+ $ this ->orderMock ->expects ($ this ->any ())->method ('getTotalQtyOrdered ' )->willReturn (2 );
116
129
$ this ->state ->check ($ this ->orderMock );
117
130
$ this ->assertEquals ($ expectedState , $ this ->orderMock ->getState ());
118
131
}
@@ -126,6 +139,20 @@ public function testCheck(
126
139
public function stateCheckDataProvider ()
127
140
{
128
141
return [
142
+ 'processing - partiallyRefundedOrderShipped = true, hasPendingShipmentItems = true -> processing ' => [
143
+ 'can_credit_memo ' => false ,
144
+ 'can_credit_memo_invoke_count ' => 1 ,
145
+ 'can_ship ' => true ,
146
+ 'call_can_skip_num ' => 2 ,
147
+ 'current_state ' => Order::STATE_PROCESSING ,
148
+ 'expected_state ' => Order::STATE_PROCESSING ,
149
+ 'is_in_process ' => false ,
150
+ 'get_is_in_process_invoke_count ' => 0 ,
151
+ 'is_canceled ' => false ,
152
+ 'can_unhold ' => false ,
153
+ 'is_not_virtual ' => true ,
154
+ 'isPartiallyRefundedOrderShipped ' => false
155
+ ],
129
156
'processing - !canCreditmemo!canShip -> closed ' => [
130
157
'can_credit_memo ' => false ,
131
158
'can_credit_memo_invoke_count ' => 1 ,
0 commit comments