Skip to content

Commit bc7a29a

Browse files
committed
MAGE-1050: code updated as per code review suggestions.
1 parent 1bf6151 commit bc7a29a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Test/Integration/Search/SearchTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ public function testSearchBySku()
6161
public function testCategorySearch()
6262
{
6363
// Get products by categoryId
64-
$results = $this->search('', 1, [
64+
list($results, $totalHits, $facetsFromAlgolia) = $this->search('', 1, [
6565
'facetFilters' => ['categoryIds:' . $this->assertValues->expectedCategory]
6666
]);
67-
$result = $this->getFirstResult($results);
6867
// Category filter returns result
69-
$this->assertNotEmpty($result, "Category filter didn't return result");
68+
$this->assertNotEmpty($results, "Category filter didn't return result");
69+
70+
$collection = $this->objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
71+
$collection
72+
->addAttributeToSelect('*')
73+
->addAttributeToFilter('status',\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
74+
->addAttributeToFilter('visibility', \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
75+
->addCategoriesFilter(["in" => $this->assertValues->expectedCategory])
76+
->setStore(1);
77+
// Products in category count matches
78+
$this->assertEquals(count($results), $collection->count(), "Indexed number of products in a category doesn't match with DB");
7079
}
7180

7281
/**
@@ -82,6 +91,7 @@ protected function getFirstResult(array $results): array
8291
/**
8392
* @param string $query
8493
* @param int $storeId
94+
* @param array $params
8595
* @return array
8696
*/
8797
protected function search(string $query = '', int $storeId = 1, array $params = []): array

0 commit comments

Comments
 (0)