Skip to content

Commit 377da7b

Browse files
author
mastiuhin-olexandr
committed
MC-33288: [2.4][MSI][MFTF] StorefrontLoggedInCustomerCreateOrderAllOptionQuantityConfigurableProductCustomStockTest fails because of bad design
1 parent 12b1321 commit 377da7b

File tree

1 file changed

+36
-0
lines changed
  • dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product

1 file changed

+36
-0
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/RelationTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,41 @@ public function testGetRelationsByChildren(): void
105105
$this->assertArrayHasKey($childId, $result);
106106
$this->assertContains($result[$childId], $parentIdsOfChildIds[$childId]);
107107
}
108+
109+
$parentIdsOfChildIds = [];
110+
111+
foreach ($childSkusOfParentSkus as $parentSku => $childSkus) {
112+
foreach ($childSkus as $childSku) {
113+
$childId = $configurableIdsOfSkus[$childSku];
114+
$parentIdsOfChildIds[$childId][] = $configurableIdsOfSkus[$parentSku];
115+
}
116+
}
117+
118+
/**
119+
* Assert there are parent configurable products ids in result of getRelationsByChildren method
120+
* and they are related to child ids.
121+
*/
122+
$result = $this->model->getRelationsByChildren($childIds);
123+
$sortedResult = $this->sortParentIdsOfChildIds($result);
124+
$sortedExpected = $this->sortParentIdsOfChildIds($parentIdsOfChildIds);
125+
126+
$this->assertEquals($sortedExpected, $sortedResult);
127+
}
128+
129+
/**
130+
* Sorts the "Parent Ids Of Child Ids" type of the array
131+
*
132+
* @param array $array
133+
* @return array
134+
*/
135+
private function sortParentIdsOfChildIds(array $array): array
136+
{
137+
foreach ($array as $childId => &$parentIds) {
138+
sort($parentIds, SORT_NUMERIC);
139+
}
140+
141+
ksort($array, SORT_NUMERIC);
142+
143+
return $array;
108144
}
109145
}

0 commit comments

Comments
 (0)