Skip to content

Commit 960da02

Browse files
committed
MAGE-1131: Added some additional integration tests for legacy indexers
1 parent 8f01cbb commit 960da02

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

Test/Integration/Indexing/Category/CategoriesIndexingTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Algolia\AlgoliaSearch\Test\Integration\Indexing\Category;
44

55
use Algolia\AlgoliaSearch\Console\Command\Indexer\IndexCategoriesCommand;
6+
use Algolia\AlgoliaSearch\Model\Indexer\Category as CategoryIndexer;
67
use Algolia\AlgoliaSearch\Service\Category\BatchQueueProcessor as CategoryBatchQueueProcessor;
78
use Algolia\AlgoliaSearch\Test\Integration\Indexing\IndexingTestCase;
89

@@ -59,4 +60,22 @@ public function testIndexingCategoriesCommand()
5960
$indexCategoriesCmd = $this->objectManager->get(IndexCategoriesCommand::class);
6061
$this->processCommandTest($indexCategoriesCmd,'categories', $this->assertValues->expectedCategory);
6162
}
63+
64+
/**
65+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/categories 0
66+
*/
67+
public function testDisabledOldIndexer()
68+
{
69+
$categoriesIndexer = $this->objectManager->create(CategoryIndexer::class);
70+
$this->processOldIndexerTest($categoriesIndexer, 'categories', 0);
71+
}
72+
73+
/**
74+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/categories 1
75+
*/
76+
public function testEnabledOldIndexer()
77+
{
78+
$categoriesIndexer = $this->objectManager->create(CategoryIndexer::class);
79+
$this->processOldIndexerTest($categoriesIndexer, 'categories', $this->assertValues->expectedCategory);
80+
}
6281
}

Test/Integration/Indexing/IndexingTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Algolia\AlgoliaSearch\Console\Command\Indexer\AbstractIndexerCommand;
77
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
88
use Algolia\AlgoliaSearch\Test\Integration\TestCase;
9+
use Magento\Framework\Indexer\ActionInterface;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112

@@ -31,6 +32,16 @@ protected function processTest(
3132
$this->assertNumberofHits($indexSuffix, $expectedNbHits);
3233
}
3334

35+
protected function processOldIndexerTest(ActionInterface $indexer, $indexSuffix, $expectedNbHits)
36+
{
37+
$this->algoliaHelper->clearIndex($this->indexPrefix . 'default_' . $indexSuffix);
38+
39+
$indexer->executeFull();
40+
$this->algoliaHelper->waitLastTask();
41+
42+
$this->assertNumberofHits($indexSuffix, $expectedNbHits);
43+
}
44+
3445
protected function processCommandTest(
3546
AbstractIndexerCommand $command,
3647
$indexSuffix,

Test/Integration/Indexing/Page/PagesIndexingTest.php

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

55
use Algolia\AlgoliaSearch\Console\Command\Indexer\IndexPagesCommand;
66
use Algolia\AlgoliaSearch\Helper\Entity\PageHelper;
7+
use Algolia\AlgoliaSearch\Model\Indexer\Page as PageIndexer;
78
use Algolia\AlgoliaSearch\Service\Page\BatchQueueProcessor as PageBatchQueueProcessor;
89
use Algolia\AlgoliaSearch\Test\Integration\Indexing\IndexingTestCase;
910
use Magento\Cms\Model\PageFactory;
@@ -159,4 +160,27 @@ public function testIndexingPagesCommand()
159160
$indexPagesCmd = $this->objectManager->get(IndexPagesCommand::class);
160161
$this->processCommandTest($indexPagesCmd, 'pages', $this->assertValues->expectedPages);
161162
}
163+
164+
/**
165+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/pages 0
166+
*/
167+
public function testDisabledOldIndexer()
168+
{
169+
$pagesIndexer = $this->objectManager->create(PageIndexer::class);
170+
$this->processOldIndexerTest($pagesIndexer, 'pages', 0);
171+
}
172+
173+
/**
174+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/pages 1
175+
*/
176+
public function testEnabledOldIndexer()
177+
{
178+
$this->setConfig(
179+
'algoliasearch_autocomplete/autocomplete/excluded_pages',
180+
$this->getSerializer()->serialize([])
181+
);
182+
183+
$pagesIndexer = $this->objectManager->create(PageIndexer::class);
184+
$this->processOldIndexerTest($pagesIndexer, 'pages', $this->assertValues->expectedPages);
185+
}
162186
}

Test/Integration/Indexing/Product/ProductsIndexingTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
77
use Algolia\AlgoliaSearch\Exceptions\ExceededRetriesException;
88
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
9+
use Algolia\AlgoliaSearch\Model\Indexer\Product as ProductIndexer;
910
use Magento\Catalog\Model\Product;
1011
use Magento\Framework\Exception\NoSuchEntityException;
1112
use Magento\Framework\Indexer\IndexerRegistry;
@@ -97,6 +98,28 @@ public function testIndexingProductsCommand()
9798
$this->processCommandTest($indexProductsCmd, 'products', $this->assertValues->productsOnStockCount);
9899
}
99100

101+
/**
102+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/products 0
103+
*/
104+
public function testDisabledOldIndexer()
105+
{
106+
$productsIndexer = $this->objectManager->create(ProductIndexer::class);
107+
$this->processOldIndexerTest($productsIndexer, 'products', 0);
108+
}
109+
110+
/**
111+
* @magentoConfigFixture current_store algoliasearch_indexing_manager/full_indexing/products 1
112+
*/
113+
public function testEnabledOldIndexer()
114+
{
115+
$this->setConfig(ConfigHelper::SHOW_OUT_OF_STOCK, 0);
116+
117+
$this->updateStockItem(self::OUT_OF_STOCK_PRODUCT_SKU, false);
118+
119+
$productsIndexer = $this->objectManager->create(ProductIndexer::class);
120+
$this->processOldIndexerTest($productsIndexer, 'products', $this->assertValues->productsOnStockCount);
121+
}
122+
100123
private function getValidTestProduct()
101124
{
102125
if (!$this->testProductId) {

0 commit comments

Comments
 (0)