@@ -1448,11 +1448,12 @@ public function testFilterProductsForExactMatchingName()
1448
1448
*/
1449
1449
public function testFilteringForProductsFromMultipleCategories ()
1450
1450
{
1451
+ $ categoriesIds = ["4 " ,"5 " ,"12 " ];
1451
1452
$ query
1452
1453
= <<<QUERY
1453
1454
{
1454
1455
products(filter:{
1455
- category_id :{in:["4 ","5 ","12 "]}
1456
+ category_id :{in:[" { $ categoriesIds [ 0 ]} "," { $ categoriesIds [ 1 ]} "," { $ categoriesIds [ 2 ]} "]}
1456
1457
})
1457
1458
{
1458
1459
items
@@ -1478,6 +1479,20 @@ public function testFilteringForProductsFromMultipleCategories()
1478
1479
$ response = $ this ->graphQlQuery ($ query );
1479
1480
/** @var ProductRepositoryInterface $productRepository */
1480
1481
$ this ->assertEquals (3 , $ response ['products ' ]['total_count ' ]);
1482
+ $ actualProducts = [];
1483
+ foreach ($ categoriesIds as $ categoriesId ) {
1484
+ /** @var CategoryLinkManagement $productLinks */
1485
+ $ productLinks = ObjectManager::getInstance ()->get (CategoryLinkManagement::class);
1486
+ $ links = $ productLinks ->getAssignedProducts ($ categoriesId );
1487
+ $ links = array_reverse ($ links );
1488
+ foreach ($ links as $ linkProduct ) {
1489
+ $ productRepository = ObjectManager::getInstance ()->get (ProductRepositoryInterface::class);
1490
+ /** @var ProductInterface $product */
1491
+ $ product = $ productRepository ->get ($ linkProduct ->getSku ());
1492
+ $ actualProducts [$ linkProduct ->getSku ()] = $ product ->getName ();
1493
+ }
1494
+ }
1495
+ $ this ->assertEquals (array_column ($ response ['products ' ]['items ' ],"name " ,"sku " ), $ actualProducts );
1481
1496
}
1482
1497
1483
1498
/**
0 commit comments