@@ -88,6 +88,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
88
88
],
89
89
'feed_hash ' => 'hash ' ,
90
90
'feed_id ' => 'feed_id_1 ' ,
91
+ "source_entity_id " => 1 ,
91
92
'operation ' => IndexStateProvider::INSERT_OPERATION
92
93
],
93
94
[
@@ -102,6 +103,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
102
103
],
103
104
'feed_hash ' => 'hash ' ,
104
105
'feed_id ' => 'feed_id_2 ' ,
106
+ "source_entity_id " => 2 ,
105
107
'operation ' => IndexStateProvider::INSERT_OPERATION
106
108
],
107
109
[
@@ -116,6 +118,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
116
118
],
117
119
'feed_hash ' => 'hash ' ,
118
120
'feed_id ' => 'feed_id_3 ' ,
121
+ "source_entity_id " => 3 ,
119
122
'operation ' => IndexStateProvider::INSERT_OPERATION
120
123
],
121
124
];
@@ -171,6 +174,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
171
174
],
172
175
'feed_hash ' => 'hash ' ,
173
176
'feed_id ' => 'feed_id_1 ' ,
177
+ "source_entity_id " => 1 ,
174
178
'operation ' => IndexStateProvider::INSERT_OPERATION
175
179
],
176
180
[
@@ -185,6 +189,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
185
189
],
186
190
'feed_hash ' => 'hash ' ,
187
191
'feed_id ' => 'feed_id_2 ' ,
192
+ "source_entity_id " => 2 ,
188
193
'operation ' => IndexStateProvider::INSERT_OPERATION
189
194
190
195
],
@@ -200,6 +205,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
200
205
],
201
206
'feed_hash ' => 'hash ' ,
202
207
'feed_id ' => 'feed_id_3 ' ,
208
+ "source_entity_id " => 3 ,
203
209
'operation ' => IndexStateProvider::INSERT_OPERATION
204
210
],
205
211
];
@@ -243,19 +249,21 @@ private function prepareExpectedData(
243
249
$ status = $ exportStatus ->getStatus ()->getValue ();
244
250
foreach ($ feedItems as $ position => $ item ) {
245
251
$ feed = $ item ['feed_data ' ];
252
+ $ finalStatus = $ failedSkuPosition === $ position ? ExportStatusCodeProvider::FAILED_ITEM_ERROR : $ status ;
253
+ $ errors = $ failedSkuPosition === $ position ? $ failedStatus ['message ' ] : '' ;
246
254
$ expected [] = [
247
255
'is_deleted ' => $ feed ['deleted ' ],
248
- 'status ' => $ failedSkuPosition
249
- ? ($ failedSkuPosition === $ position ? ExportStatusCodeProvider::FAILED_ITEM_ERROR : $ status )
250
- : $ status ,
251
- 'errors ' => $ failedSkuPosition
252
- ? ($ failedSkuPosition === $ position ? $ failedStatus ['message ' ] : '' )
253
- : $ exportStatus ->getReasonPhrase (),
256
+ 'status ' => $ failedSkuPosition ? $ finalStatus : $ status ,
257
+ 'errors ' => $ failedSkuPosition ? $ errors : $ exportStatus ->getReasonPhrase (),
254
258
'feed_data ' => $ this ->jsonSerializer ->serialize ($ feed ),
255
259
'feed_hash ' => $ item ['feed_hash ' ],
256
260
'feed_id ' => $ item ['feed_id ' ],
257
261
'source_entity_id ' => $ feed ['productId ' ]
258
262
];
263
+ $ currentKey = array_key_last ($ expected );
264
+ if (empty ($ expected [$ currentKey ]['errors ' ])) {
265
+ unset($ expected [$ currentKey ]['errors ' ]);
266
+ }
259
267
}
260
268
return $ expected ;
261
269
}
0 commit comments