File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -105,5 +105,41 @@ public function testGetRelationsByChildren(): void
105
105
$ this ->assertArrayHasKey ($ childId , $ result );
106
106
$ this ->assertContains ($ result [$ childId ], $ parentIdsOfChildIds [$ childId ]);
107
107
}
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 ;
108
144
}
109
145
}
You can’t perform that action at this time.
0 commit comments