Skip to content

Commit b868bcd

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-59477-Attribute-Weighting-MySql' into Okapis-PR
2 parents 70c8334 + dacdb24 commit b868bcd

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
@@ -123,6 +123,20 @@ private function assertProductIds($queryResponse, $expectedIds)
123123
$this->assertEquals($expectedIds, $actualIds);
124124
}
125125

126+
/**
127+
* @param \Magento\Framework\Search\Response\QueryResponse $queryResponse
128+
* @param array $expectedIds
129+
*/
130+
private function assertOrderedProductIds($queryResponse, $expectedIds)
131+
{
132+
$actualIds = [];
133+
foreach ($queryResponse as $document) {
134+
/** @var \Magento\Framework\Api\Search\Document $document */
135+
$actualIds[] = $document->getId();
136+
}
137+
$this->assertEquals($expectedIds, $actualIds);
138+
}
139+
126140
/**
127141
* @magentoConfigFixture current_store catalog/search/engine mysql
128142
*/
@@ -136,6 +150,24 @@ public function testMatchQuery()
136150
$this->assertEquals(1, $queryResponse->count());
137151
}
138152

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

0 commit comments

Comments
 (0)