4
4
5
5
use Algolia \AlgoliaSearch \Exception \DiagnosticsException ;
6
6
use Algolia \AlgoliaSearch \Helper \ConfigHelper ;
7
+ use Algolia \AlgoliaSearch \Helper \Configuration \QueueHelper ;
7
8
use Algolia \AlgoliaSearch \Helper \Data ;
8
9
use Algolia \AlgoliaSearch \Helper \Entity \ProductHelper ;
9
10
use Algolia \AlgoliaSearch \Logger \DiagnosticsLogger ;
@@ -23,6 +24,7 @@ class BatchQueueProcessorTest extends TestCase
23
24
protected ?Data $ dataHelper ;
24
25
protected ?ConfigHelper $ configHelper ;
25
26
protected ?ProductHelper $ productHelper ;
27
+ protected ?QueueHelper $ queueHelper ;
26
28
protected ?Queue $ queue ;
27
29
protected ?DiagnosticsLogger $ diag ;
28
30
protected ?AlgoliaCredentialsManager $ algoliaCredentialsManager ;
@@ -40,11 +42,13 @@ protected function setUp(): void
40
42
$ this ->algoliaCredentialsManager = $ this ->createMock (AlgoliaCredentialsManager::class);
41
43
$ this ->indexBuilder = $ this ->createMock (IndexBuilder::class);
42
44
$ this ->indexCollectionSizeCache = $ this ->createMock (IndexCollectionSize::class);
45
+ $ this ->queueHelper = $ this ->createMock (QueueHelper::class);
43
46
44
47
$ this ->processor = new BatchQueueProcessor (
45
48
$ this ->dataHelper ,
46
49
$ this ->configHelper ,
47
50
$ this ->productHelper ,
51
+ $ this ->queueHelper ,
48
52
$ this ->queue ,
49
53
$ this ->diag ,
50
54
$ this ->algoliaCredentialsManager ,
@@ -136,6 +140,7 @@ public function testProcessBatchHandlesFullIndexing()
136
140
$ this ->configHelper ->method ('isQueueActive ' )->willReturn (false );
137
141
$ this ->indexCollectionSizeCache ->expects ($ this ->once ())->method ('get ' )->willReturn (10 );
138
142
$ this ->productHelper ->method ('getProductCollectionQuery ' )->willReturn ($ this ->getMockCollection ());
143
+ $ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (false );
139
144
140
145
$ invocations = $ this ->exactly (2 );
141
146
$ this ->queue ->expects ($ invocations )
@@ -176,6 +181,7 @@ public function testProcessBatchFullIndexingWithNoCache()
176
181
$ this ->configHelper ->method ('isQueueActive ' )->willReturn (false );
177
182
$ this ->indexCollectionSizeCache ->expects ($ this ->once ())->method ('get ' )->willReturn (IndexCollectionSize::NOT_FOUND );
178
183
$ this ->productHelper ->method ('getProductCollectionQuery ' )->willReturn ($ this ->getMockCollection (10 , 1 ));
184
+ $ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (false );
179
185
180
186
$ this ->queue ->expects ($ this ->exactly (2 ))
181
187
->method ('addToQueue ' );
@@ -194,6 +200,7 @@ public function testProcessBatchHandlesFullIndexingPaged()
194
200
$ this ->configHelper ->method ('isQueueActive ' )->willReturn (false );
195
201
$ this ->indexCollectionSizeCache ->expects ($ this ->once ())->method ('get ' )->willReturn (50 );
196
202
$ this ->productHelper ->method ('getProductCollectionQuery ' )->willReturn ($ this ->getMockCollection ());
203
+ $ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (false );
197
204
198
205
$ invocations = $ this ->exactly (6 );
199
206
$ this ->queue ->expects ($ invocations )
@@ -240,6 +247,8 @@ public function testProcessBatchMovesTempIndexIfQueueActive()
240
247
$ this ->productHelper ->method ('getTempIndexName ' )->willReturn ('tmp_index ' );
241
248
$ this ->productHelper ->method ('getIndexName ' )->willReturn ('main_index ' );
242
249
250
+ $ this ->queueHelper ->method ('useTmpIndex ' )->willReturn (true );
251
+
243
252
$ invocations = $ this ->exactly (3 );
244
253
$ this ->queue ->expects ($ invocations )
245
254
->method ('addToQueue ' )
0 commit comments