Skip to content

Commit d6c826c

Browse files
committed
GraphQL-139: [BugFix] Show only active categories
-- fix static tests
1 parent 62fd888 commit d6c826c

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
* See COPYING.txt for license details.
55
*/
66
declare(strict_types=1);
7+
78
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider;
9+
810
use Magento\CatalogGraphQl\Model\Category\Hydrator;
911
use Magento\Catalog\Api\Data\CategoryInterface;
12+
1013
/**
1114
* Extract data from category tree
1215
*/
@@ -16,14 +19,17 @@ class ExtractDataFromCategoryTree
1619
* @var Hydrator
1720
*/
1821
private $categoryHydrator;
22+
1923
/**
20-
* @var CategoryInterface;
24+
* @var CategoryInterface
2125
*/
2226
private $iteratingCategory;
27+
2328
/**
2429
* @var int
2530
*/
2631
private $startCategoryFetchLevel = 1;
32+
2733
/**
2834
* @param Hydrator $categoryHydrator
2935
*/
@@ -32,6 +38,7 @@ public function __construct(
3238
) {
3339
$this->categoryHydrator = $categoryHydrator;
3440
}
41+
3542
/**
3643
* Extract data from category tree
3744
*
@@ -58,6 +65,7 @@ public function execute(\Iterator $iterator): array
5865
}
5966
return $tree;
6067
}
68+
6169
/**
6270
* Merge together complex categories trees
6371
*
@@ -77,6 +85,7 @@ private function mergeCategoriesTrees(array &$tree1, array &$tree2): array
7785
}
7886
return $mergedTree;
7987
}
88+
8089
/**
8190
* Recursive method to generate tree for one category path
8291
*
@@ -99,4 +108,4 @@ private function explodePathToArray(array $pathElements, int $index): array
99108
}
100109
return $tree;
101110
}
102-
}
111+
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44
* See COPYING.txt for license details.
55
*/
66
declare(strict_types=1);
7+
78
namespace Magento\GraphQl\Catalog;
9+
810
use Magento\Catalog\Api\Data\CategoryInterface;
911
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
1012
use Magento\Framework\DataObject;
1113
use Magento\TestFramework\TestCase\GraphQlAbstract;
1214
use Magento\Catalog\Api\Data\ProductInterface;
1315
use Magento\Catalog\Api\ProductRepositoryInterface;
1416
use Magento\TestFramework\ObjectManager;
17+
1518
class CategoryTest extends GraphQlAbstract
1619
{
1720
/**
1821
* @var \Magento\TestFramework\ObjectManager
1922
*/
2023
private $objectManager;
24+
2125
protected function setUp()
2226
{
2327
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
2428
}
29+
2530
/**
2631
* @magentoApiDataFixture Magento/Customer/_files/customer.php
2732
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
@@ -104,6 +109,7 @@ public function testCategoriesTree()
104109
$responseDataObject->getData('category/children/0/children/1/id')
105110
);
106111
}
112+
107113
/**
108114
* @magentoApiDataFixture Magento/Customer/_files/customer.php
109115
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
@@ -139,6 +145,7 @@ public function testGetCategoryById()
139145
$responseDataObject->getData('category/id')
140146
);
141147
}
148+
142149
/**
143150
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
144151
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -344,6 +351,7 @@ public function testAnchorCategory()
344351
];
345352
$this->assertEquals($expectedResponse, $response);
346353
}
354+
347355
/**
348356
* @param ProductInterface $product
349357
* @param array $actualResponse
@@ -385,6 +393,7 @@ private function assertBaseFields($product, $actualResponse)
385393
];
386394
$this->assertResponseFields($actualResponse, $assertionMap);
387395
}
396+
388397
/**
389398
* @param ProductInterface $product
390399
* @param array $actualResponse
@@ -403,6 +412,7 @@ private function assertWebsites($product, $actualResponse)
403412
];
404413
$this->assertEquals($actualResponse, $assertionMap);
405414
}
415+
406416
/**
407417
* @param array $actualResponse
408418
*/
@@ -428,4 +438,4 @@ private function assertAttributes($actualResponse)
428438
$this->assertArrayHasKey($eavAttribute, $actualResponse);
429439
}
430440
}
431-
}
441+
}

0 commit comments

Comments
 (0)