Skip to content

Commit dacdb24

Browse files
author
Eric Bohanon
committed
MAGETWO-59477: [Search] Attribute Weighting Works Incorrect for MySQL Adapter
1 parent 0c69ba5 commit dacdb24

File tree

5 files changed

+547
-7
lines changed

5 files changed

+547
-7
lines changed

dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ private function assertProductIds($queryResponse, $expectedIds)
120120
$this->assertEquals($expectedIds, $actualIds);
121121
}
122122

123+
/**
124+
* @param \Magento\Framework\Search\Response\QueryResponse $queryResponse
125+
* @param array $expectedIds
126+
*/
127+
private function assertOrderedProductIds($queryResponse, $expectedIds)
128+
{
129+
$actualIds = [];
130+
foreach ($queryResponse as $document) {
131+
/** @var \Magento\Framework\Api\Search\Document $document */
132+
$actualIds[] = $document->getId();
133+
}
134+
$this->assertEquals($expectedIds, $actualIds);
135+
}
136+
123137
/**
124138
* @magentoConfigFixture current_store catalog/search/engine mysql
125139
*/
@@ -133,6 +147,24 @@ public function testMatchQuery()
133147
$this->assertEquals(1, $queryResponse->count());
134148
}
135149

150+
/**
151+
* @magentoDataFixture Magento/Framework/Search/_files/products_multi_option.php
152+
* @magentoConfigFixture current_store catalog/search/engine mysql
153+
*/
154+
public function testMatchOrderedQuery()
155+
{
156+
$expectedIds = [8, 7, 6, 5, 2];
157+
158+
//Verify that MySql randomized result of equal-weighted results
159+
//consistently ordered by entity_id after multiple calls
160+
$this->requestBuilder->bind('fulltext_search_query', 'shorts');
161+
$this->requestBuilder->setRequestName('one_match');
162+
$queryResponse = $this->executeQuery();
163+
164+
$this->assertEquals(5, $queryResponse->count());
165+
$this->assertOrderedProductIds($queryResponse, $expectedIds);
166+
}
167+
136168
/**
137169
* @magentoConfigFixture current_store catalog/search/engine mysql
138170
*/

0 commit comments

Comments
 (0)