Skip to content

Commit 673a138

Browse files
committed
MAGE-1044 Include sort direction in test
1 parent 6483c8d commit 673a138

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Test/Integration/Product/ReplicaIndexingTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public function setUp(): void
2424
$this->indicesConfigurator = $this->getObjectManager()->get(IndicesConfigurator::class);
2525
$this->indexSuffix = 'products';
2626

27+
// Replicas will not get created if InstantSearch is not used
28+
$this->setConfig('algoliasearch_instant/instant/is_instant_enabled', 1);
2729
}
2830

2931
protected function getIndexName(string $storeIndexPart): string
@@ -36,28 +38,27 @@ public function processFullReindexProducts(): void
3638
$this->processFullReindex($this->productIndexer, $this->indexSuffix);
3739
}
3840

39-
public function testReplicaIndex(): void
41+
public function testReplicaConfig(): void
4042
{
4143
$sorting = $this->configHelper->getSorting();
4244
$sortAttr = 'created_at';
45+
$sortDir = 'desc';
4346

4447
// Has created_at sort
4548
$this->assertTrue(
4649
(bool)
4750
array_filter(
4851
$sorting,
49-
function($sort) use ($sortAttr) {
50-
return $sort['attribute'] == $sortAttr;
52+
function($sort) use ($sortAttr, $sortDir) {
53+
return $sort['attribute'] == $sortAttr
54+
&& $sort['sort'] == $sortDir;
5155
}
5256
)
5357
);
5458

5559
// Expected replica max
5660
$this->assertEquals($this->replicaManager->getMaxVirtualReplicasPerIndex(), 20);
5761

58-
// Replicas will not get created if InstantSearch is not used
59-
$this->setConfig('algoliasearch_instant/instant/is_instant_enabled', 1);
60-
6162
$this->indicesConfigurator->saveConfigurationToAlgolia(1);
6263
$this->algoliaHelper->waitLastTask();
6364

@@ -70,10 +71,16 @@ function($sort) use ($sortAttr) {
7071
(bool)
7172
array_filter(
7273
$currentSettings['replicas'],
73-
function($replicaIndex) use ($indexName, $sortAttr) {
74-
return str_contains($replicaIndex, $indexName . '_' . $sortAttr);
74+
function($replicaIndex) use ($indexName, $sortAttr, $sortDir) {
75+
return str_contains($replicaIndex, $indexName . '_' . $sortAttr . '_' . $sortDir);
7576
}
7677
)
7778
);
79+
80+
}
81+
82+
public function tearDown(): void
83+
{
84+
$this->setConfig('algoliasearch_instant/instant/is_instant_enabled', 0);
7885
}
7986
}

0 commit comments

Comments
 (0)