File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -134,4 +134,35 @@ public function testGetItems()
134
134
$ this ->assertEquals (13 , $ item ->getValue ());
135
135
$ this ->assertEquals (2 , $ item ->getCount ());
136
136
}
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
+ }
137
168
}
You can’t perform that action at this time.
0 commit comments