|
3 | 3 | namespace Algolia\AlgoliaSearch\Test\Integration\Indexing\Queue;
|
4 | 4 |
|
5 | 5 | use Algolia\AlgoliaSearch\Helper\ConfigHelper;
|
6 |
| -use Algolia\AlgoliaSearch\Model\Indexer\Product; |
7 | 6 | use Algolia\AlgoliaSearch\Model\Indexer\QueueRunner;
|
8 | 7 | use Algolia\AlgoliaSearch\Model\IndicesConfigurator;
|
9 | 8 | use Algolia\AlgoliaSearch\Model\Job;
|
10 | 9 | use Algolia\AlgoliaSearch\Model\Queue;
|
11 | 10 | use Algolia\AlgoliaSearch\Model\ResourceModel\Job\CollectionFactory as JobsCollectionFactory;
|
| 11 | +use Algolia\AlgoliaSearch\Service\Product\BatchQueueProcessor as ProductBatchQueueProcessor; |
12 | 12 | use Algolia\AlgoliaSearch\Test\Integration\TestCase;
|
13 | 13 | use Magento\Framework\App\ResourceConnection;
|
14 | 14 | use Magento\Framework\DB\Adapter\AdapterInterface;
|
|
19 | 19 | */
|
20 | 20 | class QueueTest extends TestCase
|
21 | 21 | {
|
22 |
| - private const INCOMPLETE_REASON = "Must revisit transaction handling across connections."; |
23 |
| - |
24 | 22 | /** @var JobsCollectionFactory */
|
25 | 23 | private $jobsCollectionFactory;
|
26 | 24 |
|
@@ -53,9 +51,8 @@ public function testFill()
|
53 | 51 | $this->setConfig(ConfigHelper::IS_ACTIVE, '1');
|
54 | 52 | $this->connection->query('TRUNCATE TABLE algoliasearch_queue');
|
55 | 53 |
|
56 |
| - /** @var Product $indexer */ |
57 |
| - $indexer = $this->objectManager->get(Product::class); |
58 |
| - $indexer->executeFull(); |
| 54 | + $productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class); |
| 55 | + $productBatchQueueProcessor->processBatch(1); |
59 | 56 |
|
60 | 57 | $rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
|
61 | 58 | $this->assertEquals(3, count($rows));
|
@@ -90,9 +87,8 @@ public function testExecute()
|
90 | 87 | $this->setConfig(ConfigHelper::IS_ACTIVE, '1');
|
91 | 88 | $this->connection->query('TRUNCATE TABLE algoliasearch_queue');
|
92 | 89 |
|
93 |
| - /** @var Product $indexer */ |
94 |
| - $indexer = $this->objectManager->get(Product::class); |
95 |
| - $indexer->executeFull(); |
| 90 | + $productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class); |
| 91 | + $productBatchQueueProcessor->processBatch(1); |
96 | 92 |
|
97 | 93 | /** @var Queue $queue */
|
98 | 94 | $queue = $this->objectManager->get(Queue::class);
|
@@ -154,11 +150,10 @@ public function testSettings()
|
154 | 150 | $this->connection->query('DELETE FROM algoliasearch_queue');
|
155 | 151 |
|
156 | 152 | // Reindex products multiple times
|
157 |
| - /** @var Product $indexer */ |
158 |
| - $indexer = $this->objectManager->get(Product::class); |
159 |
| - $indexer->executeFull(); |
160 |
| - $indexer->executeFull(); |
161 |
| - $indexer->executeFull(); |
| 153 | + $productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class); |
| 154 | + $productBatchQueueProcessor->processBatch(1); |
| 155 | + $productBatchQueueProcessor->processBatch(1); |
| 156 | + $productBatchQueueProcessor->processBatch(1); |
162 | 157 |
|
163 | 158 | $rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
|
164 | 159 | $this->assertEquals(9, count($rows));
|
@@ -188,9 +183,8 @@ public function testMergeSettings()
|
188 | 183 |
|
189 | 184 | $this->connection->query('DELETE FROM algoliasearch_queue');
|
190 | 185 |
|
191 |
| - /** @var Product $productIndexer */ |
192 |
| - $productIndexer = $this->objectManager->get(Product::class); |
193 |
| - $productIndexer->executeFull(); |
| 186 | + $productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class); |
| 187 | + $productBatchQueueProcessor->processBatch(1); |
194 | 188 |
|
195 | 189 | $rows = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
|
196 | 190 | $this->assertCount(3, $rows);
|
@@ -884,9 +878,8 @@ public function testMaxSingleJobsSizeOnProductReindex()
|
884 | 878 |
|
885 | 879 | $this->connection->query('TRUNCATE TABLE algoliasearch_queue');
|
886 | 880 |
|
887 |
| - /** @var Product $indexer */ |
888 |
| - $indexer = $this->objectManager->get(Product::class); |
889 |
| - $indexer->execute(range(1, 512)); |
| 881 | + $productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class); |
| 882 | + $productBatchQueueProcessor->processBatch(1, range(1, 512)); |
890 | 883 |
|
891 | 884 | $dbJobs = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
|
892 | 885 | $this->assertSame(6, count($dbJobs));
|
|
0 commit comments