Skip to content

Commit 7977ef3

Browse files
committed
MAGE-1226: updated page tests
1 parent 9c8f3a3 commit 7977ef3

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

Test/Integration/Indexing/Page/MultiStorePagesTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;
66
use Algolia\AlgoliaSearch\Exceptions\ExceededRetriesException;
77
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
8-
use Algolia\AlgoliaSearch\Model\Indexer\Page;
8+
use Algolia\AlgoliaSearch\Service\Page\BatchQueueProcessor as PageBatchQueueProcessor;
99
use Algolia\AlgoliaSearch\Test\Integration\Indexing\MultiStoreTestCase;
1010
use Magento\Cms\Api\Data\PageInterface;
1111
use Magento\Cms\Api\PageRepositoryInterface;
@@ -21,27 +21,26 @@
2121
*/
2222
class MultiStorePagesTest extends MultiStoreTestCase
2323
{
24-
/** @var Page */
25-
protected $pagesIndexer;
26-
2724
/** @var PageRepositoryInterface */
2825
protected $pageRepository;
2926

3027
/** @var CollectionFactory */
3128
private $pageCollectionFactory;
3229

30+
/** @var PageBatchQueueProcessor */
31+
protected $pageBatchQueueProcessor;
32+
3333
const HOME_PAGE_ID = 2;
3434

3535
public function setUp():void
3636
{
3737
parent::setUp();
3838

39-
$this->pagesIndexer = $this->objectManager->get(Page::class);
4039
$this->pageRepository = $this->objectManager->get(PageRepositoryInterface::class);
4140
$this->pageCollectionFactory = $this->objectManager->get(CollectionFactory::class);
4241

43-
$this->pagesIndexer->executeFull();
44-
$this->algoliaHelper->waitLastTask();
42+
$this->pageBatchQueueProcessor = $this->objectManager->get(PageBatchQueueProcessor::class);
43+
$this->reindexToAllStores($this->pageBatchQueueProcessor);
4544
}
4645

4746
/***
@@ -77,10 +76,7 @@ public function testMultiStorePageIndices()
7776
$homePage->setStores([$defaultStore->getId()]);
7877
$this->pageRepository->save($homePage);
7978

80-
$this->pagesIndexer->execute([self::HOME_PAGE_ID]);
81-
82-
$this->algoliaHelper->waitLastTask($defaultStore->getId());
83-
$this->algoliaHelper->waitLastTask($fixtureSecondStore->getId());
79+
$this->reindexToAllStores($this->pageBatchQueueProcessor, [self::HOME_PAGE_ID]);
8480

8581
$this->assertNbOfRecordsPerStore(
8682
$defaultStore->getCode(),

Test/Integration/Indexing/Page/PagesIndexingTest.php

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

55
use Algolia\AlgoliaSearch\Helper\Entity\PageHelper;
6-
use Algolia\AlgoliaSearch\Model\Indexer\Page;
6+
use Algolia\AlgoliaSearch\Service\Page\BatchQueueProcessor as PageBatchQueueProcessor;
77
use Algolia\AlgoliaSearch\Test\Integration\Indexing\IndexingTestCase;
88
use Magento\Cms\Model\PageFactory;
99

@@ -16,10 +16,8 @@ public function testNoExcludedPages()
1616
$this->getSerializer()->serialize([])
1717
);
1818

19-
/** @var Page $indexer */
20-
$indexer = $this->getObjectManager()->create(Page::class);
21-
22-
$this->processTest($indexer, 'pages', $this->assertValues->expectedPages);
19+
$pageBatchQueueProcessor = $this->objectManager->get(PageBatchQueueProcessor::class);
20+
$this->processTest($pageBatchQueueProcessor, 'pages', $this->assertValues->expectedPages);
2321
}
2422

2523
public function testExcludedPages()
@@ -33,9 +31,8 @@ public function testExcludedPages()
3331
$this->getSerializer()->serialize($excludedPages)
3432
);
3533

36-
/** @var Page $indexer */
37-
$indexer = $this->getObjectManager()->create(Page::class);
38-
$this->processTest($indexer, 'pages', $this->assertValues->expectedExcludePages);
34+
$pageBatchQueueProcessor = $this->objectManager->get(PageBatchQueueProcessor::class);
35+
$this->processTest($pageBatchQueueProcessor, 'pages', $this->assertValues->expectedExcludePages);
3936

4037
$response = $this->algoliaHelper->query($this->indexPrefix . 'default_pages', '', []);
4138
$hits = reset($response['results'])['hits'];
@@ -61,10 +58,8 @@ public function testExcludedPages()
6158

6259
public function testDefaultIndexableAttributes()
6360
{
64-
/** @var Page $indexer */
65-
$indexer = $this->getObjectManager()->create(Page::class);
66-
$indexer->executeFull();
67-
61+
$pageBatchQueueProcessor = $this->objectManager->get(PageBatchQueueProcessor::class);
62+
$pageBatchQueueProcessor->processBatch(1);
6863
$this->algoliaHelper->waitLastTask();
6964

7065
$response = $this->algoliaHelper->query($this->indexPrefix . 'default_pages', '', ['hitsPerPage' => 1]);

0 commit comments

Comments
 (0)