@@ -24,6 +24,8 @@ public function setUp(): void
24
24
$ this ->indicesConfigurator = $ this ->getObjectManager ()->get (IndicesConfigurator::class);
25
25
$ this ->indexSuffix = 'products ' ;
26
26
27
+ // Replicas will not get created if InstantSearch is not used
28
+ $ this ->setConfig ('algoliasearch_instant/instant/is_instant_enabled ' , 1 );
27
29
}
28
30
29
31
protected function getIndexName (string $ storeIndexPart ): string
@@ -36,28 +38,27 @@ public function processFullReindexProducts(): void
36
38
$ this ->processFullReindex ($ this ->productIndexer , $ this ->indexSuffix );
37
39
}
38
40
39
- public function testReplicaIndex (): void
41
+ public function testReplicaConfig (): void
40
42
{
41
43
$ sorting = $ this ->configHelper ->getSorting ();
42
44
$ sortAttr = 'created_at ' ;
45
+ $ sortDir = 'desc ' ;
43
46
44
47
// Has created_at sort
45
48
$ this ->assertTrue (
46
49
(bool )
47
50
array_filter (
48
51
$ 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 ;
51
55
}
52
56
)
53
57
);
54
58
55
59
// Expected replica max
56
60
$ this ->assertEquals ($ this ->replicaManager ->getMaxVirtualReplicasPerIndex (), 20 );
57
61
58
- // Replicas will not get created if InstantSearch is not used
59
- $ this ->setConfig ('algoliasearch_instant/instant/is_instant_enabled ' , 1 );
60
-
61
62
$ this ->indicesConfigurator ->saveConfigurationToAlgolia (1 );
62
63
$ this ->algoliaHelper ->waitLastTask ();
63
64
@@ -70,10 +71,16 @@ function($sort) use ($sortAttr) {
70
71
(bool )
71
72
array_filter (
72
73
$ 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 );
75
76
}
76
77
)
77
78
);
79
+
80
+ }
81
+
82
+ public function tearDown (): void
83
+ {
84
+ $ this ->setConfig ('algoliasearch_instant/instant/is_instant_enabled ' , 0 );
78
85
}
79
86
}
0 commit comments