Skip to content

Commit f1b1f66

Browse files
authored
MDEE-968: [PoC] Deliver MDEE relate changes from PoC to main branches (#474)
* MDEE-968: [PoC] Deliver MDEE relate changes from PoC to main branches
1 parent ea929e5 commit f1b1f66

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

CatalogDataExporter/Test/Integration/ProductDataSerializerTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
8888
],
8989
'feed_hash' => 'hash',
9090
'feed_id' => 'feed_id_1',
91+
"source_entity_id" => 1,
9192
'operation' => IndexStateProvider::INSERT_OPERATION
9293
],
9394
[
@@ -102,6 +103,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
102103
],
103104
'feed_hash' => 'hash',
104105
'feed_id' => 'feed_id_2',
106+
"source_entity_id" => 2,
105107
'operation' => IndexStateProvider::INSERT_OPERATION
106108
],
107109
[
@@ -116,6 +118,7 @@ public function testSecondFeedItemHasErrorInExportStatus(): void
116118
],
117119
'feed_hash' => 'hash',
118120
'feed_id' => 'feed_id_3',
121+
"source_entity_id" => 3,
119122
'operation' => IndexStateProvider::INSERT_OPERATION
120123
],
121124
];
@@ -171,6 +174,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
171174
],
172175
'feed_hash' => 'hash',
173176
'feed_id' => 'feed_id_1',
177+
"source_entity_id" => 1,
174178
'operation' => IndexStateProvider::INSERT_OPERATION
175179
],
176180
[
@@ -185,6 +189,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
185189
],
186190
'feed_hash' => 'hash',
187191
'feed_id' => 'feed_id_2',
192+
"source_entity_id" => 2,
188193
'operation' => IndexStateProvider::INSERT_OPERATION
189194

190195
],
@@ -200,6 +205,7 @@ public function testAllItemsHaveErrorsInExportStatus(): void
200205
],
201206
'feed_hash' => 'hash',
202207
'feed_id' => 'feed_id_3',
208+
"source_entity_id" => 3,
203209
'operation' => IndexStateProvider::INSERT_OPERATION
204210
],
205211
];
@@ -243,19 +249,21 @@ private function prepareExpectedData(
243249
$status = $exportStatus->getStatus()->getValue();
244250
foreach ($feedItems as $position => $item) {
245251
$feed = $item['feed_data'];
252+
$finalStatus = $failedSkuPosition === $position ? ExportStatusCodeProvider::FAILED_ITEM_ERROR : $status;
253+
$errors = $failedSkuPosition === $position ? $failedStatus['message'] : '';
246254
$expected[] = [
247255
'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(),
254258
'feed_data' => $this->jsonSerializer->serialize($feed),
255259
'feed_hash' => $item['feed_hash'],
256260
'feed_id' => $item['feed_id'],
257261
'source_entity_id' => $feed['productId']
258262
];
263+
$currentKey = array_key_last($expected);
264+
if (empty($expected[$currentKey]['errors'])) {
265+
unset($expected[$currentKey]['errors']);
266+
}
259267
}
260268
return $expected;
261269
}

InventoryDataExporter/Test/Integration/ExportStockStatusWithoutFeedProcessingTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public function testExportStockStatusesWithoutFeedPersisting()
7474
$actualStockStatuses = $this->getFeedData($productsSkus);
7575
foreach ($this->getExpectedStockStatusMandatoryFeedsOnly() as $stockId => $stockStatuses) {
7676
foreach ($stockStatuses as $sku => $stockStatus) {
77-
$stockStatus['productId'] = $productIds[$sku] ?? null;
7877
if (!isset($actualStockStatuses[$stockId][$sku])) {
7978
self::fail("Cannot find stock status for stock $stockId & sku $sku");
8079
}
@@ -127,7 +126,6 @@ public function testExportStockStatusesWithoutFeedPersistingProductsDeleted()
127126
$actualStockStatuses = $this->getFeedData($productsSkus);
128127
foreach ($this->getExpectedStockStatusMandatoryFeedsOnlyDeletedProducts() as $stockId => $stockStatuses) {
129128
foreach ($stockStatuses as $sku => $stockStatus) {
130-
$stockStatus['productId'] = $productIds[$sku] ?? null;
131129
if (!isset($actualStockStatuses[$stockId][$sku])) {
132130
self::fail("Cannot find stock status for stock $stockId & sku $sku");
133131
}

0 commit comments

Comments
 (0)