Skip to content

Commit 2ab76e3

Browse files
authored
MAGE-870 add changes from PR #1528 (#1532)
1 parent 3a15d99 commit 2ab76e3

File tree

9 files changed

+63
-91
lines changed

9 files changed

+63
-91
lines changed

Setup/Patch/Schema/ConfigPatch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConfigPatch implements SchemaPatchInterface
8181

8282
'algoliasearch_synonyms/synonyms_group/enable_synonyms' => '0',
8383

84-
'algoliasearch_advanced/advanced/number_of_element_by_page' => '300',
84+
'algoliasearch_advanced/queue/number_of_element_by_page' => '300',
8585
'algoliasearch_advanced/advanced/remove_words_if_no_result' => 'allOptional',
8686
'algoliasearch_advanced/advanced/partial_update' => '0',
8787
'algoliasearch_advanced/advanced/customer_groups_enable' => '0',
@@ -92,7 +92,7 @@ class ConfigPatch implements SchemaPatchInterface
9292
'algoliasearch_advanced/advanced/prevent_backend_rendering' => '0',
9393
'algoliasearch_advanced/advanced/prevent_backend_rendering_display_mode' => 'all',
9494
'algoliasearch_advanced/advanced/backend_rendering_allowed_user_agents' => "Googlebot\nBingbot",
95-
'algoliasearch_advanced/advanced/archive_clear_limit' => '30',
95+
'algoliasearch_advanced/queue/archive_clear_limit' => '30',
9696
];
9797

9898
/**

Test/Integration/AssertValues/Magento_2_3.php renamed to Test/Integration/AssertValues/Magento23.php

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

33
namespace Algolia\AlgoliaSearch\Test\Integration\AssertValues;
44

5-
class Magento_2_3
5+
class Magento23
66
{
77
public $productsOnStockCount = 186;
88
public $productsOutOfStockCount = 187;

Test/Integration/AssertValues/Magento244.php renamed to Test/Integration/AssertValues/Magento24.php

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

33
namespace Algolia\AlgoliaSearch\Test\Integration\AssertValues;
44

5-
class Magento244
5+
class Magento24
66
{
77
public $productsOnStockCount = 180;
8-
public $productsOutOfStockCount = 183;
8+
public $productsOutOfStockCount = 181;
99
public $lastJobDataSize = 13;
10-
public $expectedCategory = 17;
10+
public $expectedCategory = 16;
1111
public $attributesForFaceting = 5;
1212
public $automaticalSetOfCategoryAttributesForFaceting = 4;
13-
public $expectedPages = 9;
14-
public $expectedExcludePages = 7;
13+
public $expectedPages = 6;
14+
public $expectedExcludePages = 4;
1515
}

Test/Integration/AssertValues/Magento_2_01.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

Test/Integration/AssertValues/Magento_2_2.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

Test/Integration/PagesIndexingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class PagesIndexingTest extends IndexingTestCase
1010
{
11-
public function testOnlyOnStockProducts()
11+
public function testNoExcludedPages()
1212
{
1313
$this->setConfig(
1414
'algoliasearch_autocomplete/autocomplete/excluded_pages',

Test/Integration/QueueTest.php

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class QueueTest extends TestCase
2121
/** @var AdapterInterface */
2222
private $connection;
2323

24+
/** @var Queue */
25+
private $queue;
26+
2427
public function setUp(): void
2528
{
2629
parent::setUp();
@@ -30,13 +33,15 @@ public function setUp(): void
3033
/** @var ResourceConnection $resouce */
3134
$resouce = $this->getObjectManager()->create(ResourceConnection::class);
3235
$this->connection = $resouce->getConnection();
36+
37+
$this->queue = $this->getObjectManager()->create(Queue::class);
3338
}
3439

3540
public function testFill()
3641
{
3742
$this->resetConfigs([
3843
'algoliasearch_queue/queue/number_of_job_to_run',
39-
'algoliasearch_advanced/advanced/number_of_element_by_page',
44+
'algoliasearch_advanced/queue/number_of_element_by_page',
4045
]);
4146

4247
$this->setConfig('algoliasearch_queue/queue/active', '1');
@@ -136,7 +141,7 @@ public function testSettings()
136141

137142
$this->resetConfigs([
138143
'algoliasearch_queue/queue/number_of_job_to_run',
139-
'algoliasearch_advanced/advanced/number_of_element_by_page',
144+
'algoliasearch_advanced/queue/number_of_element_by_page',
140145
'algoliasearch_instant/instant/facets',
141146
'algoliasearch_products/products/product_additional_attributes',
142147
]);
@@ -172,13 +177,14 @@ public function testSettings()
172177
$this->assertFalse(empty($settings['searchableAttributes']), 'SearchableAttributes should be set, but they are not.');
173178
}
174179

180+
/**
181+
* @magentoDbIsolation disabled
182+
*/
175183
public function testMergeSettings()
176184
{
177-
$this->markTestIncomplete(self::INCOMPLETE_REASON);
178-
179185
$this->setConfig('algoliasearch_queue/queue/active', '1');
180186
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 1);
181-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 300);
187+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 300);
182188

183189
$this->connection->query('DELETE FROM algoliasearch_queue');
184190

@@ -213,10 +219,11 @@ public function testMergeSettings()
213219
$this->assertEquals(['sku'], $settings['disableTypoToleranceOnAttributes']);
214220
}
215221

222+
/**
223+
* @magentoDbIsolation disabled
224+
*/
216225
public function testMerging()
217226
{
218-
$this->markTestIncomplete(self::INCOMPLETE_REASON);
219-
220227
$this->connection->query('DELETE FROM algoliasearch_queue');
221228

222229
$data = [
@@ -357,13 +364,10 @@ public function testMerging()
357364

358365
$this->connection->insertMultiple('algoliasearch_queue', $data);
359366

360-
/** @var Queue $queue */
361-
$queue = $this->getObjectManager()->create(Queue::class);
362-
363367
$jobs = $this->jobsCollectionFactory->create()->getItems();
364368
// $jobs = $this->connection->query('SELECT * FROM algoliasearch_queue')->fetchAll();
365369

366-
$mergedJobs = array_values($this->invokeMethod($queue, 'mergeJobs', [$jobs]));
370+
$mergedJobs = array_values($this->invokeMethod($this->queue, 'mergeJobs', [$jobs]));
367371
$this->assertEquals(6, count($mergedJobs));
368372

369373
$expectedCategoryJob = [
@@ -389,6 +393,7 @@ public function testMerging()
389393
],
390394
],
391395
'locked_at' => null,
396+
'debug' => null,
392397
];
393398

394399
/** @var Job $categoryJob */
@@ -417,13 +422,17 @@ public function testMerging()
417422
],
418423
],
419424
'locked_at' => null,
425+
'debug' => null,
420426
];
421427

422428
/** @var Job $productJob */
423429
$productJob = $mergedJobs[3];
424430
$this->assertEquals($expectedProductJob, $productJob->toArray());
425431
}
426432

433+
/**
434+
* @magentoDbIsolation disabled
435+
*/
427436
public function testMergingWithStaticMethods()
428437
{
429438
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
@@ -552,15 +561,12 @@ public function testMergingWithStaticMethods()
552561
],
553562
];
554563

555-
/** @var Queue $queue */
556-
$queue = $this->getObjectManager()->create(Queue::class);
557-
558564
$this->connection->insertMultiple('algoliasearch_queue', $data);
559565

560566
/** @var Job[] $jobs */
561567
$jobs = $this->jobsCollectionFactory->create()->getItems();
562568

563-
$jobs = array_values($this->invokeMethod($queue, 'mergeJobs', [$jobs]));
569+
$jobs = array_values($this->invokeMethod($this->queue, 'mergeJobs', [$jobs]));
564570
$this->assertEquals(12, count($jobs));
565571

566572
$this->assertEquals('rebuildStoreCategoryIndex', $jobs[0]->getMethod());
@@ -577,6 +583,9 @@ public function testMergingWithStaticMethods()
577583
$this->assertEquals('rebuildStoreProductIndex', $jobs[11]->getMethod());
578584
}
579585

586+
/**
587+
* @magentoDbIsolation disabled
588+
*/
580589
public function testGetJobs()
581590
{
582591
$this->markTestIncomplete(self::INCOMPLETE_REASON);
@@ -721,11 +730,8 @@ public function testGetJobs()
721730

722731
$this->connection->insertMultiple('algoliasearch_queue', $data);
723732

724-
/** @var Queue $queue */
725-
$queue = $this->getObjectManager()->create(Queue::class);
726-
727733
$pid = getmypid();
728-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
734+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
729735
$this->assertEquals(6, count($jobs));
730736

731737
$expectedFirstJob = [
@@ -751,6 +757,7 @@ public function testGetJobs()
751757
],
752758
],
753759
'locked_at' => null,
760+
'debug' => null,
754761
];
755762

756763
$expectedLastJob = [
@@ -775,6 +782,7 @@ public function testGetJobs()
775782
],
776783
],
777784
'locked_at' => null,
785+
'debug' => null,
778786
];
779787

780788
/** @var Job $firstJob */
@@ -795,10 +803,11 @@ public function testGetJobs()
795803
}
796804
}
797805

806+
/**
807+
* @magentoDbIsolation disabled
808+
*/
798809
public function testHugeJob()
799810
{
800-
$this->markTestIncomplete(self::INCOMPLETE_REASON);
801-
802811
// Default value - maxBatchSize = 1000
803812
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
804813
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
@@ -811,12 +820,9 @@ public function testHugeJob()
811820
(1, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"1","product_ids":' . $jsonProductIds . '}\', 3, 0, \'\', 5000),
812821
(2, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"2","product_ids":["9","22"]}\', 3, 0, \'\', 2);');
813822

814-
/** @var Queue $queue */
815-
$queue = $this->getObjectManager()->create(Queue::class);
816-
817823
$pid = getmypid();
818824
/** @var Job[] $jobs */
819-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
825+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
820826

821827
$this->assertEquals(1, count($jobs));
822828

@@ -835,13 +841,14 @@ public function testHugeJob()
835841
$this->assertNull($lastJob['pid']);
836842
}
837843

844+
/**
845+
* @magentoDbIsolation disabled
846+
*/
838847
public function testMaxSingleJobSize()
839848
{
840-
$this->markTestIncomplete(self::INCOMPLETE_REASON);
841-
842849
// Default value - maxBatchSize = 1000
843850
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
844-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
851+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
845852

846853
$productIds = range(1, 99);
847854
$jsonProductIds = json_encode($productIds);
@@ -851,13 +858,10 @@ public function testMaxSingleJobSize()
851858
(1, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"1","product_ids":' . $jsonProductIds . '}\', 3, 0, \'\', 99),
852859
(2, NULL, \'class\', \'rebuildStoreProductIndex\', \'{"store_id":"2","product_ids":["9","22"]}\', 3, 0, \'\', 2);');
853860

854-
/** @var Queue $queue */
855-
$queue = $this->getObjectManager()->create(Queue::class);
856-
857861
$pid = getmypid();
858862

859863
/** @var Job[] $jobs */
860-
$jobs = $this->invokeMethod($queue, 'getJobs', ['maxJobs' => 10]);
864+
$jobs = $this->invokeMethod($this->queue, 'getJobs', ['maxJobs' => 10]);
861865

862866
$this->assertEquals(2, count($jobs));
863867

@@ -881,19 +885,20 @@ public function testMaxSingleJobSize()
881885
$this->assertEquals($pid, $lastJob['pid']);
882886
}
883887

888+
/**
889+
* @magentoDbIsolation disabled
890+
*/
884891
public function testMaxSingleJobsSizeOnProductReindex()
885892
{
886-
$this->markTestIncomplete(self::INCOMPLETE_REASON);
887-
888893
$this->resetConfigs([
889894
'algoliasearch_queue/queue/number_of_job_to_run',
890-
'algoliasearch_advanced/advanced/number_of_element_by_page',
895+
'algoliasearch_advanced/queue/number_of_element_by_page',
891896
]);
892897

893898
$this->setConfig('algoliasearch_queue/queue/active', '1');
894899

895900
$this->setConfig('algoliasearch_queue/queue/number_of_job_to_run', 10);
896-
$this->setConfig('algoliasearch_advanced/advanced/number_of_element_by_page', 100);
901+
$this->setConfig('algoliasearch_advanced/queue/number_of_element_by_page', 100);
897902

898903
$this->connection->query('TRUNCATE TABLE algoliasearch_queue');
899904

Test/Integration/TestCase.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
use Algolia\AlgoliaSearch\Helper\AlgoliaHelper;
77
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
88
use Algolia\AlgoliaSearch\Setup\Patch\Schema\ConfigPatch;
9-
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento244;
10-
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento_2_01;
11-
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento_2_2;
12-
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento_2_3;
9+
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento23;
10+
use Algolia\AlgoliaSearch\Test\Integration\AssertValues\Magento24;
1311
use Magento\Framework\App\Config\ScopeConfigInterface;
1412
use Magento\Framework\App\ProductMetadataInterface;
1513
use Magento\Store\Model\ScopeInterface;
@@ -21,10 +19,6 @@ class_alias('PHPUnit\Framework\TestCase', '\TC');
2119
class_alias('\PHPUnit_Framework_TestCase', '\TC');
2220
}
2321

24-
if (class_exists('\Algolia\AlgoliaSearch\Test\Integration\AssertValues_2_01')) {
25-
class_alias('\Algolia\AlgoliaSearch\Test\Integration\AssertValues_2_01', 'AssertValues');
26-
}
27-
2822
abstract class TestCase extends \TC
2923
{
3024
/** @var bool */
@@ -39,7 +33,7 @@ abstract class TestCase extends \TC
3933
/** @var ConfigHelper */
4034
protected $configHelper;
4135

42-
/** @var Magento_2_01|Magento_2_2 */
36+
/** @var Magento23|Magento24 */
4337
protected $assertValues;
4438

4539
public function setUp(): void
@@ -103,14 +97,10 @@ private function bootstrap()
10397
return;
10498
}
10599

106-
if (version_compare($this->getMagentoVersion(), '2.2.0', '<')) {
107-
$this->assertValues = new Magento_2_01();
108-
} elseif (version_compare($this->getMagentoVersion(), '2.3.0', '<')) {
109-
$this->assertValues = new Magento_2_2();
110-
} elseif (version_compare($this->getMagentoVersion(), '2.4.3', '<=')) {
111-
$this->assertValues = new Magento_2_3();
100+
if (version_compare($this->getMagentoVersion(), '2.4.0', '<')) {
101+
$this->assertValues = new Magento23();
112102
} else {
113-
$this->assertValues = new Magento244();
103+
$this->assertValues = new Magento24();
114104
}
115105

116106
$this->configHelper = $this->getObjectManager()->create(ConfigHelper::class);

0 commit comments

Comments
 (0)