Skip to content

Commit c2403a2

Browse files
committed
MAGE-1226: updated product tests
1 parent 7977ef3 commit c2403a2

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

Test/Integration/Indexing/Product/MultiStoreProductsTest.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Test\Integration\Indexing\Product;
44

5-
use Algolia\AlgoliaSearch\Model\Indexer\Product;
5+
use Algolia\AlgoliaSearch\Service\Product\BatchQueueProcessor as ProductBatchQueueProcessor;
66
use Algolia\AlgoliaSearch\Test\Integration\Indexing\MultiStoreTestCase;
77
use Magento\Catalog\Api\Data\ProductInterface;
88
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -19,8 +19,8 @@
1919
*/
2020
class MultiStoreProductsTest extends MultiStoreTestCase
2121
{
22-
/** @var Product */
23-
protected $productsIndexer;
22+
/** @var ProductBatchQueueProcessor */
23+
protected $productBatchQueueProcessor;
2424

2525
/** @var ProductRepositoryInterface */
2626
protected $productRepository;
@@ -53,7 +53,7 @@ protected function setUp():void
5353
{
5454
parent::setUp();
5555

56-
$this->productsIndexer = $this->objectManager->get(Product::class);
56+
$this->productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
5757
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
5858
$this->productCollectionFactory = $this->objectManager->get(CollectionFactory::class);
5959
$this->websiteRepository = $this->objectManager->get(WebsiteRepositoryInterface::class);
@@ -62,8 +62,7 @@ protected function setUp():void
6262
$this->productPriceIndexer = $this->indexerRegistry->get('catalog_product_price');
6363
$this->productPriceIndexer->reindexAll();
6464

65-
$this->productsIndexer->executeFull();
66-
$this->algoliaHelper->waitLastTask();
65+
$this->reindexToAllStores($this->productBatchQueueProcessor);
6766
}
6867

6968
public function testMultiStoreProductIndices()
@@ -102,11 +101,7 @@ public function testMultiStoreProductIndices()
102101
$this->assertEquals(self::VOYAGE_YOGA_BAG_NAME, $voyageYogaBag->getName());
103102
$this->assertEquals(self::VOYAGE_YOGA_BAG_NAME_ALT, $voyageYogaBagAlt->getName());
104103

105-
$this->productsIndexer->execute([self::VOYAGE_YOGA_BAG_ID]);
106-
107-
$this->algoliaHelper->waitLastTask($defaultStore->getId());
108-
$this->algoliaHelper->waitLastTask($fixtureSecondStore->getId());
109-
$this->algoliaHelper->waitLastTask($fixtureThirdStore->getId());
104+
$this->reindexToAllStores($this->productBatchQueueProcessor, [self::VOYAGE_YOGA_BAG_ID]);
110105

111106
$this->assertAlgoliaRecordValues(
112107
$this->indexPrefix . 'default_products',
@@ -131,11 +126,7 @@ public function testMultiStoreProductIndices()
131126
$this->productRepository->save($voyageYogaBag);
132127
$this->productPriceIndexer->reindexRow(self::VOYAGE_YOGA_BAG_ID);
133128

134-
$this->productsIndexer->execute([self::VOYAGE_YOGA_BAG_ID]);
135-
136-
$this->algoliaHelper->waitLastTask($defaultStore->getId());
137-
$this->algoliaHelper->waitLastTask($fixtureSecondStore->getId());
138-
$this->algoliaHelper->waitLastTask($fixtureThirdStore->getId());
129+
$this->reindexToAllStores($this->productBatchQueueProcessor, [self::VOYAGE_YOGA_BAG_ID]);
139130

140131
// default store should have the same number of products
141132
$this->assertNbOfRecordsPerStore(

Test/Integration/Indexing/Product/PricingTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function indexProducts(int|array $productIds): void
5454
if (!is_array($productIds)) {
5555
$productIds = [$productIds];
5656
}
57-
$this->productIndexer->execute($productIds);
57+
$this->productBatchQueueProcessor->processBatch(1, $productIds);
5858
$this->algoliaHelper->waitLastTask();
5959
}
6060

@@ -141,7 +141,7 @@ function ($key, $value) {
141141

142142
public function testSpecialPrice(): void
143143
{
144-
$this->productIndexer->execute([self::SPECIAL_PRICE_TEST_PRODUCT_ID]);
144+
$this->productBatchQueueProcessor->processBatch(1, [self::SPECIAL_PRICE_TEST_PRODUCT_ID]);
145145
$this->algoliaHelper->waitLastTask();
146146

147147
$res = $this->algoliaHelper->getObjects(
@@ -175,7 +175,7 @@ public function testSpecialPrice(): void
175175
]);
176176
$product->save();
177177

178-
$this->productIndexer->execute([self::SPECIAL_PRICE_TEST_PRODUCT_ID]);
178+
$this->productBatchQueueProcessor->processBatch(1, [self::SPECIAL_PRICE_TEST_PRODUCT_ID]);
179179
$this->algoliaHelper->waitLastTask();
180180

181181
$res = $this->algoliaHelper->getObjects(

Test/Integration/Indexing/Product/ProductsIndexingTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class ProductsIndexingTest extends ProductsIndexingTestCase
1919
/*** @var IndexerRegistry */
2020
protected $indexerRegistry;
2121

22-
protected $productPriceIndexer;
23-
2422
protected $testProductId;
2523

2624
const OUT_OF_STOCK_PRODUCT_SKU = '24-MB01';
@@ -31,7 +29,7 @@ public function testOnlyOnStockProducts()
3129

3230
$this->updateStockItem(self::OUT_OF_STOCK_PRODUCT_SKU, false);
3331

34-
$this->processTest($this->productIndexer, 'products', $this->assertValues->productsOnStockCount);
32+
$this->processTest($this->productBatchQueueProcessor, 'products', $this->assertValues->productsOnStockCount);
3533
}
3634

3735
public function testIncludingOutOfStock()
@@ -40,7 +38,7 @@ public function testIncludingOutOfStock()
4038

4139
$this->updateStockItem(self::OUT_OF_STOCK_PRODUCT_SKU, false);
4240

43-
$this->processTest($this->productIndexer, 'products', $this->assertValues->productsOutOfStockCount);
41+
$this->processTest($this->productBatchQueueProcessor, 'products', $this->assertValues->productsOutOfStockCount);
4442
}
4543

4644
public function testDefaultIndexableAttributes()
@@ -52,7 +50,7 @@ public function testDefaultIndexableAttributes()
5250
$this->setConfig(ConfigHelper::SORTING_INDICES, $empty);
5351
$this->setConfig(ConfigHelper::PRODUCT_CUSTOM_RANKING, $empty);
5452

55-
$this->productIndexer->executeRow($this->getValidTestProduct());
53+
$this->productBatchQueueProcessor->processBatch(1, [$this->getValidTestProduct()]);
5654
$this->algoliaHelper->waitLastTask();
5755

5856
$results = $this->algoliaHelper->getObjects($this->indexPrefix . 'default_products', [$this->getValidTestProduct()]);

Test/Integration/Indexing/Product/ProductsIndexingTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Test\Integration\Indexing\Product;
44

5-
use Algolia\AlgoliaSearch\Model\Indexer\Product as ProductIndexer;
5+
use Algolia\AlgoliaSearch\Service\Product\BatchQueueProcessor as ProductBatchQueueProcessor;
66
use Algolia\AlgoliaSearch\Test\Integration\Indexing\IndexingTestCase;
77
use Magento\CatalogInventory\Model\StockRegistry;
88
use Magento\Framework\Exception\NoSuchEntityException;
@@ -12,13 +12,13 @@ class ProductsIndexingTestCase extends IndexingTestCase
1212
{
1313

1414
protected ?StockRegistry $stockRegistry = null;
15-
protected ?ProductIndexer $productIndexer = null;
15+
protected ?ProductBatchQueueProcessor $productBatchQueueProcessor = null;
1616

1717
protected function setUp(): void
1818
{
1919
parent::setUp();
2020

21-
$this->productIndexer = $this->objectManager->get(ProductIndexer::class);
21+
$this->productBatchQueueProcessor = $this->objectManager->get(ProductBatchQueueProcessor::class);
2222
$this->stockRegistry = $this->objectManager->get(StockRegistry::class);
2323

2424
$this->objectManager

0 commit comments

Comments
 (0)