@@ -17,17 +17,13 @@ class ReplicaIndexingTest extends IndexingTestCase
17
17
18
18
protected ?string $ indexSuffix = null ;
19
19
20
- protected ?array $ ogSortingState = null ;
21
-
22
20
public function setUp (): void
23
21
{
24
22
parent ::setUp ();
25
23
$ this ->productIndexer = $ this ->objectManager ->get (ProductIndexer::class);
26
24
$ this ->replicaManager = $ this ->objectManager ->get (ReplicaManagerInterface::class);
27
25
$ this ->indicesConfigurator = $ this ->objectManager ->get (IndicesConfigurator::class);
28
26
$ this ->indexSuffix = 'products ' ;
29
-
30
- $ this ->ogSortingState = $ this ->configHelper ->getSorting ();
31
27
}
32
28
33
29
protected function getIndexName (string $ storeIndexPart ): string
@@ -40,28 +36,6 @@ public function processFullReindexProducts(): void
40
36
$ this ->processFullReindex ($ this ->productIndexer , $ this ->indexSuffix );
41
37
}
42
38
43
- protected function hasSortingAttribute ($ sortAttr , $ sortDir ): bool
44
- {
45
- $ sorting = $ this ->configHelper ->getSorting ();
46
- return (bool ) array_filter (
47
- $ sorting ,
48
- function ($ sort ) use ($ sortAttr , $ sortDir ) {
49
- return $ sort ['attribute ' ] == $ sortAttr
50
- && $ sort ['sort ' ] == $ sortDir ;
51
- }
52
- );
53
- }
54
-
55
- protected function assertSortingAttribute ($ sortAttr , $ sortDir ): void
56
- {
57
- $ this ->assertTrue ($ this ->hasSortingAttribute ($ sortAttr , $ sortDir ));
58
- }
59
-
60
- protected function assertNoSortingAttribute ($ sortAttr , $ sortDir ): void
61
- {
62
- $ this ->assertFalse ($ this ->hasSortingAttribute ($ sortAttr , $ sortDir ));
63
- }
64
-
65
39
public function testReplicaLimits ()
66
40
{
67
41
$ this ->assertEquals (20 , $ this ->replicaManager ->getMaxVirtualReplicasPerIndex ());
@@ -101,13 +75,16 @@ public function testStandardReplicaConfig(): void
101
75
}
102
76
103
77
/**
78
+ * This test involves verifying modifications in the database
79
+ * so it must be responsible for its own set up and tear down
104
80
* @magentoDbIsolation disabled
105
81
* @group virtual
106
82
*/
107
83
public function testVirtualReplicaConfig (): void
108
84
{
109
85
$ indexName = $ this ->getIndexName ('default_ ' );
110
86
$ ogAlgoliaSettings = $ this ->algoliaHelper ->getSettings ($ indexName );
87
+ $ ogSortingState = $ this ->configHelper ->getSorting ();
111
88
112
89
$ this ->assertFalse (array_key_exists ('replicas ' , $ ogAlgoliaSettings ));
113
90
@@ -160,8 +137,8 @@ public function testVirtualReplicaConfig(): void
160
137
161
138
// Restore prior state (for this test only)
162
139
$ this ->algoliaHelper ->setSettings ($ indexName , $ ogAlgoliaSettings );
140
+ $ this ->configHelper ->setSorting ($ ogSortingState );
163
141
$ this ->setConfig ('algoliasearch_instant/instant/is_instant_enabled ' , 0 );
164
-
165
142
}
166
143
167
144
/**
@@ -190,8 +167,31 @@ function ($replica) use ($replicaIndexName) {
190
167
);
191
168
}
192
169
170
+ protected function hasSortingAttribute ($ sortAttr , $ sortDir ): bool
171
+ {
172
+ $ sorting = $ this ->configHelper ->getSorting ();
173
+ return (bool ) array_filter (
174
+ $ sorting ,
175
+ function ($ sort ) use ($ sortAttr , $ sortDir ) {
176
+ return $ sort ['attribute ' ] == $ sortAttr
177
+ && $ sort ['sort ' ] == $ sortDir ;
178
+ }
179
+ );
180
+ }
181
+
182
+ protected function assertSortingAttribute ($ sortAttr , $ sortDir ): void
183
+ {
184
+ $ this ->assertTrue ($ this ->hasSortingAttribute ($ sortAttr , $ sortDir ));
185
+ }
186
+
187
+ protected function assertNoSortingAttribute ($ sortAttr , $ sortDir ): void
188
+ {
189
+ $ this ->assertFalse ($ this ->hasSortingAttribute ($ sortAttr , $ sortDir ));
190
+ }
191
+
193
192
public function tearDown (): void
194
193
{
195
- $ this -> configHelper -> setSorting ( $ this -> ogSortingState );
194
+ parent :: tearDown ( );
196
195
}
196
+
197
197
}
0 commit comments