6
6
use Algolia \AlgoliaSearch \Console \Command \ReplicaRebuildCommand ;
7
7
use Algolia \AlgoliaSearch \Console \Command \ReplicaSyncCommand ;
8
8
use Algolia \AlgoliaSearch \Helper \ConfigHelper ;
9
+ use Algolia \AlgoliaSearch \Service \Product \IndexOptionsBuilder ;
9
10
use Algolia \AlgoliaSearch \Service \Product \SortingTransformer ;
10
11
use Algolia \AlgoliaSearch \Test \Integration \Indexing \Config \Traits \ConfigAssertionsTrait ;
11
12
use Algolia \AlgoliaSearch \Test \Integration \Indexing \MultiStoreTestCase ;
@@ -32,11 +33,14 @@ class MultiStoreReplicaTest extends MultiStoreTestCase
32
33
33
34
protected ?SerializerInterface $ serializer = null ;
34
35
36
+ protected ?IndexOptionsBuilder $ indexOptionsBuilder = null ;
37
+
35
38
protected function setUp (): void
36
39
{
37
40
parent ::setUp ();
38
41
$ this ->replicaManager = $ this ->objectManager ->get (ReplicaManagerInterface::class);
39
42
$ this ->serializer = $ this ->objectManager ->get (SerializerInterface::class);
43
+ $ this ->indexOptionsBuilder = $ this ->objectManager ->get (IndexOptionsBuilder::class);
40
44
41
45
$ stores = $ this ->storeManager ->getStores ();
42
46
@@ -72,7 +76,7 @@ public function testCustomerGroupsConfig()
72
76
// Enable customer groups for second fixture store and save configuration
73
77
$ this ->setConfig ( ConfigHelper::CUSTOMER_GROUPS_ENABLE , 1 , $ fixtureSecondStore ->getCode ());
74
78
$ this ->indicesConfigurator ->saveConfigurationToAlgolia ($ fixtureSecondStore ->getId ());
75
- $ this ->algoliaHelper ->waitLastTask ($ fixtureSecondStore ->getId ());
79
+ $ this ->algoliaConnector ->waitLastTask ($ fixtureSecondStore ->getId ());
76
80
77
81
// 7 indices for default store and third store:
78
82
// - 1 for categories
@@ -95,8 +99,8 @@ public function testReplicaCommands()
95
99
$ defaultStore = $ this ->storeRepository ->get ('default ' );
96
100
$ fixtureSecondStore = $ this ->storeRepository ->get ('fixture_second_store ' );
97
101
98
- $ defaultIndexName = $ this ->indexPrefix . $ defaultStore ->getCode () . ' _products ' ;
99
- $ fixtureIndexName = $ this ->indexPrefix . $ fixtureSecondStore ->getCode () . ' _products ' ;
102
+ $ defaultIndexName = $ this ->indexNameFetcher -> getProductIndexName ( $ defaultStore ->getId ()) ;
103
+ $ fixtureIndexName = $ this ->indexNameFetcher -> getProductIndexName ( $ fixtureSecondStore ->getId ()) ;
100
104
101
105
// Update store config for fixture only
102
106
$ this ->mockSortUpdate ('price ' , 'desc ' , ['virtualReplica ' => 1 ], $ fixtureSecondStore );
@@ -119,8 +123,8 @@ public function testReplicaCommands()
119
123
$ syncCmd = $ this ->objectManager ->get (ReplicaSyncCommand::class);
120
124
$ this ->mockProperty ($ syncCmd , 'output ' , OutputInterface::class);
121
125
$ syncCmd ->syncReplicas ();
122
- $ this ->algoliaHelper ->waitLastTask ($ defaultStore ->getId ());
123
- $ this ->algoliaHelper ->waitLastTask ($ fixtureSecondStore ->getId ());
126
+ $ this ->algoliaConnector ->waitLastTask ($ defaultStore ->getId ());
127
+ $ this ->algoliaConnector ->waitLastTask ($ fixtureSecondStore ->getId ());
124
128
125
129
$ rebuildCmd = $ this ->objectManager ->get (ReplicaRebuildCommand::class);
126
130
$ this ->invokeMethod (
@@ -131,12 +135,18 @@ public function testReplicaCommands()
131
135
$ this ->createMock (OutputInterface::class)
132
136
]
133
137
);
134
- $ this ->algoliaHelper ->waitLastTask ($ defaultStore ->getId ());
135
- $ this ->algoliaHelper ->waitLastTask ($ fixtureSecondStore ->getId ());
138
+ $ this ->algoliaConnector ->waitLastTask ($ defaultStore ->getId ());
139
+ $ this ->algoliaConnector ->waitLastTask ($ fixtureSecondStore ->getId ());
136
140
// Executing commands - End
137
141
138
142
$ currentDefaultSettings = $ this ->algoliaHelper ->getSettings ($ defaultIndexName , $ defaultStore ->getId ());
143
+ $ currentDefaultSettings = $ this ->algoliaConnector ->getSettings (
144
+ $ this ->indexOptionsBuilder ->buildEntityIndexOptions ($ defaultStore ->getId ())
145
+ );
139
146
$ currentFixtureSettings = $ this ->algoliaHelper ->getSettings ($ fixtureIndexName , $ fixtureSecondStore ->getId ());
147
+ $ currentFixtureSettings = $ this ->algoliaConnector ->getSettings (
148
+ $ this ->indexOptionsBuilder ->buildEntityIndexOptions ($ fixtureSecondStore ->getId ())
149
+ );
140
150
141
151
$ this ->assertArrayHasKey ('replicas ' , $ currentDefaultSettings );
142
152
$ this ->assertArrayHasKey ('replicas ' , $ currentFixtureSettings );
@@ -176,7 +186,9 @@ protected function checkReplicaConfigByStore(StoreInterface $store, $sortAttr, $
176
186
{
177
187
$ indexName = $ this ->indexPrefix . $ store ->getCode () . '_products ' ;
178
188
179
- $ settings = $ this ->algoliaHelper ->getSettings ($ indexName , $ store ->getId ());
189
+ $ settings = $ this ->algoliaConnector ->getSettings (
190
+ $ this ->indexOptionsBuilder ->buildWithEnforcedIndex ($ indexName , $ store ->getId ())
191
+ );
180
192
181
193
$ this ->assertArrayHasKey ('replicas ' , $ settings );
182
194
@@ -216,7 +228,7 @@ protected function addSortingByStore(StoreInterface $store, $attr, $dir, $isVir
216
228
217
229
$ this ->assertSortingAttribute ($ attr , $ dir );
218
230
$ this ->indicesConfigurator ->saveConfigurationToAlgolia ($ store ->getId ());
219
- $ this ->algoliaHelper ->waitLastTask ($ store ->getId ());
231
+ $ this ->algoliaConnector ->waitLastTask ($ store ->getId ());
220
232
}
221
233
222
234
protected function resetAllSortings ()
0 commit comments