Skip to content

Commit 6bb77c2

Browse files
committed
MAGE-1374 Repair unit tests for 3.17 post 3.16 port
1 parent d4562da commit 6bb77c2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Test/Unit/Helper/ConfigHelperTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Test\Unit\Helper;
44

5+
use Algolia\AlgoliaSearch\Helper\Configuration\QueueHelper;
56
use Algolia\AlgoliaSearch\Service\Serializer;
67
use Algolia\AlgoliaSearch\Helper\Configuration\AutocompleteHelper;
78
use Algolia\AlgoliaSearch\Helper\Configuration\InstantSearchHelper;
@@ -38,6 +39,7 @@ class ConfigHelperTest extends TestCase
3839
protected ?CookieHelper $cookieHelper;
3940
protected ?AutocompleteHelper $autocompleteHelper;
4041
protected ?InstantSearchHelper $instantSearchHelper;
42+
protected ?QueueHelper $queueHelper;
4143

4244
protected function setUp(): void
4345
{
@@ -56,6 +58,7 @@ protected function setUp(): void
5658
$this->cookieHelper = $this->createMock(CookieHelper::class);
5759
$this->autocompleteHelper = $this->createMock(AutocompleteHelper::class);
5860
$this->instantSearchHelper = $this->createMock(InstantSearchHelper::class);
61+
$this->queueHelper = $this->createMock(QueueHelper::class);
5962

6063
$this->configHelper = new ConfigHelperTestable(
6164
$this->configInterface,
@@ -72,7 +75,8 @@ protected function setUp(): void
7275
$this->groupExcludedWebsiteRepository,
7376
$this->cookieHelper,
7477
$this->autocompleteHelper,
75-
$this->instantSearchHelper
78+
$this->instantSearchHelper,
79+
$this->queueHelper
7680
);
7781
}
7882

Test/Unit/Service/Product/BatchQueueProcessorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Algolia\AlgoliaSearch\Exception\DiagnosticsException;
66
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
7+
use Algolia\AlgoliaSearch\Helper\Configuration\QueueHelper;
78
use Algolia\AlgoliaSearch\Helper\Data;
89
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
910
use Algolia\AlgoliaSearch\Logger\DiagnosticsLogger;
@@ -23,6 +24,7 @@ class BatchQueueProcessorTest extends TestCase
2324
protected ?Data $dataHelper;
2425
protected ?ConfigHelper $configHelper;
2526
protected ?ProductHelper $productHelper;
27+
protected ?QueueHelper $queueHelper;
2628
protected ?Queue $queue;
2729
protected ?DiagnosticsLogger $diag;
2830
protected ?AlgoliaCredentialsManager $algoliaCredentialsManager;
@@ -40,11 +42,13 @@ protected function setUp(): void
4042
$this->algoliaCredentialsManager = $this->createMock(AlgoliaCredentialsManager::class);
4143
$this->indexBuilder = $this->createMock(IndexBuilder::class);
4244
$this->indexCollectionSizeCache = $this->createMock(IndexCollectionSize::class);
45+
$this->queueHelper = $this->createMock(QueueHelper::class);
4346

4447
$this->processor = new BatchQueueProcessor(
4548
$this->dataHelper,
4649
$this->configHelper,
4750
$this->productHelper,
51+
$this->queueHelper,
4852
$this->queue,
4953
$this->diag,
5054
$this->algoliaCredentialsManager,
@@ -136,6 +140,7 @@ public function testProcessBatchHandlesFullIndexing()
136140
$this->configHelper->method('isQueueActive')->willReturn(false);
137141
$this->indexCollectionSizeCache->expects($this->once())->method('get')->willReturn(10);
138142
$this->productHelper->method('getProductCollectionQuery')->willReturn($this->getMockCollection());
143+
$this->queueHelper->method('useTmpIndex')->willReturn(false);
139144

140145
$invocations = $this->exactly(2);
141146
$this->queue->expects($invocations)
@@ -176,6 +181,7 @@ public function testProcessBatchFullIndexingWithNoCache()
176181
$this->configHelper->method('isQueueActive')->willReturn(false);
177182
$this->indexCollectionSizeCache->expects($this->once())->method('get')->willReturn(IndexCollectionSize::NOT_FOUND);
178183
$this->productHelper->method('getProductCollectionQuery')->willReturn($this->getMockCollection(10, 1));
184+
$this->queueHelper->method('useTmpIndex')->willReturn(false);
179185

180186
$this->queue->expects($this->exactly(2))
181187
->method('addToQueue');
@@ -194,6 +200,7 @@ public function testProcessBatchHandlesFullIndexingPaged()
194200
$this->configHelper->method('isQueueActive')->willReturn(false);
195201
$this->indexCollectionSizeCache->expects($this->once())->method('get')->willReturn(50);
196202
$this->productHelper->method('getProductCollectionQuery')->willReturn($this->getMockCollection());
203+
$this->queueHelper->method('useTmpIndex')->willReturn(false);
197204

198205
$invocations = $this->exactly(6);
199206
$this->queue->expects($invocations)
@@ -240,6 +247,8 @@ public function testProcessBatchMovesTempIndexIfQueueActive()
240247
$this->productHelper->method('getTempIndexName')->willReturn('tmp_index');
241248
$this->productHelper->method('getIndexName')->willReturn('main_index');
242249

250+
$this->queueHelper->method('useTmpIndex')->willReturn(true);
251+
243252
$invocations = $this->exactly(3);
244253
$this->queue->expects($invocations)
245254
->method('addToQueue')

0 commit comments

Comments
 (0)