@@ -127,18 +127,20 @@ protected function setUp(): void
127
127
* @param string $orderStatus
128
128
* @param bool $userHasResource
129
129
* @param bool $expectedNotify
130
+ * @param string $expectedOrderStatus
130
131
*
131
132
* @dataProvider executeWillNotifyCustomerDataProvider
132
133
*/
133
134
public function testExecuteWillNotifyCustomer (
134
135
array $ historyData ,
135
136
string $ orderStatus ,
136
137
bool $ userHasResource ,
137
- bool $ expectedNotify
138
+ bool $ expectedNotify ,
139
+ string $ expectedOrderStatus
138
140
) {
139
141
$ orderId = 30 ;
140
142
$ this ->requestMock ->expects ($ this ->once ())->method ('getParam ' )->with ('order_id ' )->willReturn ($ orderId );
141
- $ this ->orderMock ->expects ($ this ->atLeastOnce ())->method ('getDataByKey ' )
143
+ $ this ->orderMock ->expects ($ this ->any ())->method ('getDataByKey ' )
142
144
->with ('status ' )->willReturn ($ orderStatus );
143
145
$ this ->orderRepositoryMock ->expects ($ this ->once ())
144
146
->method ('get ' )
@@ -152,6 +154,12 @@ public function testExecuteWillNotifyCustomer(
152
154
$ this ->objectManagerMock ->expects ($ this ->once ())->method ('create ' )->willReturn (
153
155
$ this ->createMock (OrderCommentSender::class)
154
156
);
157
+
158
+ // Verify the getOrderStatus method call
159
+ $ this ->orderMock ->expects ($ this ->once ())->method ('setStatus ' )->with ($ expectedOrderStatus );
160
+ $ this ->orderMock ->expects ($ this ->once ())->method ('save ' );
161
+ $ this ->statusHistoryCommentMock ->expects ($ this ->once ())->method ('save ' );
162
+
155
163
$ this ->addCommentController ->execute ();
156
164
}
157
165
@@ -167,57 +175,63 @@ public function executeWillNotifyCustomerDataProvider()
167
175
'is_customer_notified ' => true ,
168
176
'status ' => 'processing '
169
177
],
170
- 'orderStatus ' =>'processing ' ,
178
+ 'orderStatus ' => 'processing ' ,
171
179
'userHasResource ' => true ,
172
- 'expectedNotify ' => true
180
+ 'expectedNotify ' => true ,
181
+ 'expectedOrderStatus ' => 'processing '
173
182
],
174
183
'User Has Access - Notify False ' => [
175
184
'postData ' => [
176
185
'comment ' => 'Great Product! ' ,
177
186
'is_customer_notified ' => false ,
178
187
'status ' => 'processing '
179
188
],
180
- 'orderStatus ' =>'processing ' ,
189
+ 'orderStatus ' => 'processing ' ,
181
190
'userHasResource ' => true ,
182
- 'expectedNotify ' => false
191
+ 'expectedNotify ' => false ,
192
+ 'expectedOrderStatus ' => 'processing '
183
193
],
184
194
'User Has Access - Notify Unset ' => [
185
195
'postData ' => [
186
196
'comment ' => 'Great Product! ' ,
187
197
'status ' => 'processing '
188
198
],
189
- 'orderStatus ' =>'fraud ' ,
199
+ 'orderStatus ' => 'fraud ' ,
190
200
'userHasResource ' => true ,
191
- 'expectedNotify ' => false
201
+ 'expectedNotify ' => false ,
202
+ 'expectedOrderStatus ' => 'processing '
192
203
],
193
204
'User No Access - Notify True ' => [
194
205
'postData ' => [
195
206
'comment ' => 'Great Product! ' ,
196
207
'is_customer_notified ' => true ,
197
208
'status ' => 'fraud '
198
209
],
199
- 'orderStatus ' =>'processing ' ,
210
+ 'orderStatus ' => 'processing ' ,
200
211
'userHasResource ' => false ,
201
- 'expectedNotify ' => false
212
+ 'expectedNotify ' => false ,
213
+ 'expectedOrderStatus ' => 'fraud '
202
214
],
203
215
'User No Access - Notify False ' => [
204
216
'postData ' => [
205
217
'comment ' => 'Great Product! ' ,
206
218
'is_customer_notified ' => false ,
207
219
'status ' => 'processing '
208
220
],
209
- 'orderStatus ' =>'complete ' ,
221
+ 'orderStatus ' => 'complete ' ,
210
222
'userHasResource ' => false ,
211
- 'expectedNotify ' => false
223
+ 'expectedNotify ' => false ,
224
+ 'expectedOrderStatus ' => 'processing '
212
225
],
213
226
'User No Access - Notify Unset ' => [
214
227
'postData ' => [
215
228
'comment ' => 'Great Product! ' ,
216
229
'status ' => 'processing '
217
230
],
218
- 'orderStatus ' =>'complete ' ,
231
+ 'orderStatus ' => 'complete ' ,
219
232
'userHasResource ' => false ,
220
- 'expectedNotify ' => false
233
+ 'expectedNotify ' => false ,
234
+ 'expectedOrderStatus ' => 'processing '
221
235
],
222
236
];
223
237
}
0 commit comments