Skip to content

Commit cbe8296

Browse files
committed
MC-42545: Some of the sub categories are not shown on layered navigation due to the bucket size limit
- Add test coverage
1 parent ecc5275 commit cbe8296

File tree

1 file changed

+31
-0
lines changed
  • dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter

1 file changed

+31
-0
lines changed

dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/CategoryTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,35 @@ public function testGetItems()
134134
$this->assertEquals(13, $item->getValue());
135135
$this->assertEquals(2, $item->getCount());
136136
}
137+
138+
/**
139+
* Check that only children category of current category are aggregated
140+
*
141+
* @magentoDbIsolation disabled
142+
*/
143+
public function testCategoryAggregation(): void
144+
{
145+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
146+
$request = $objectManager->get(\Magento\TestFramework\Request::class);
147+
$request->setParam('cat', 3);
148+
$this->_model->apply($request);
149+
150+
/** @var $category \Magento\Catalog\Model\Category */
151+
$category = $objectManager->get(\Magento\Framework\Registry::class)->registry(self::CURRENT_CATEGORY_FILTER);
152+
$this->assertInstanceOf(\Magento\Catalog\Model\Category::class, $category);
153+
$this->assertEquals(3, $category->getId());
154+
$metrics = $this->_model->getLayer()->getProductCollection()->getFacetedData('category');
155+
$this->assertIsArray($metrics);
156+
$actual = [];
157+
foreach ($metrics as $categoryId => $metric) {
158+
$actual[$categoryId] = $metric['count'];
159+
}
160+
$this->assertEquals(
161+
[
162+
4 => 2,
163+
13 => 2
164+
],
165+
$actual
166+
);
167+
}
137168
}

0 commit comments

Comments
 (0)