Skip to content

Commit a506519

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into ACPT-1572
2 parents 3e15c1b + 8ec20cb commit a506519

File tree

5 files changed

+118
-16
lines changed

5 files changed

+118
-16
lines changed

app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontShareWishlistWithMoreThanMaximumAllowedEmailsQtyTest.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,19 @@
2222
<before>
2323
<magentoCLI command="config:set wishlist/email/number_limit 1" stepKey="changeEmailsQtyLimit"/>
2424
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
25-
<argument name="tags" value="config"/>
25+
<argument name="tags" value="config full_page"/>
2626
</actionGroup>
2727
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
2828
<createData entity="SimpleProduct" stepKey="createProduct">
2929
<requiredEntity createDataKey="createCategory"/>
3030
</createData>
31-
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="runCronIndexer">
32-
<argument name="indices" value=""/>
33-
</actionGroup>
31+
<comment userInput="BIC workaround" stepKey="runCronIndexer"/>
3432
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
3533
</before>
3634
<after>
3735
<magentoCLI command="config:set wishlist/email/number_limit 10" stepKey="returnDefaultValue"/>
3836
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cacheClean">
39-
<argument name="tags" value="config"/>
37+
<argument name="tags" value="config full_page"/>
4038
</actionGroup>
4139
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
4240
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>

dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ public function install($cleanup)
5050
}
5151
$this->_shell->execute($installCmd, $installArgs);
5252
}
53+
/* Set Indexer mode as "Update on Save" & Reindex all the Indexers */
54+
$this->_shell->execute(
55+
'php -f ' . BP . '/bin/magento indexer:set-mode realtime -vvv'
56+
);
57+
$this->_shell->execute(
58+
'php -f ' . BP . '/bin/magento indexer:reindex -vvv'
59+
);
5360

5461
$this->runPostInstallCommands();
5562
}

dev/tests/integration/testsuite/Magento/Customer/Controller/ForgotPasswordPostTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Magento\Framework\App\Config\ScopeConfigInterface;
1616
use Magento\Framework\App\Http;
1717
use Magento\Framework\App\Request\Http as HttpRequest;
18+
use Magento\Framework\Exception\AlreadyExistsException;
19+
use Magento\Framework\Exception\AuthenticationException;
1820
use Magento\Framework\Exception\NoSuchEntityException;
1921
use Magento\Framework\Intl\DateTimeFactory;
2022
use Magento\Framework\Math\Random;
@@ -528,7 +530,6 @@ private function clearCookieMessagesList(): void
528530
/**
529531
* Test to enable password change frequency limit for customer
530532
*
531-
* @magentoDbIsolation disabled
532533
* @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0
533534
* @magentoConfigFixture current_store customer/captcha/enable 0
534535
* @magentoDataFixture Magento/Customer/_files/customer.php
@@ -556,7 +557,7 @@ public function testEnablePasswordChangeFrequencyLimitForCustomer(): void
556557
// Updating the limit to greater than 0
557558
$this->resourceConfig->saveConfig(
558559
'customer/password/min_time_between_password_reset_requests',
559-
2,
560+
1,
560561
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
561562
0
562563
);
@@ -577,8 +578,8 @@ public function testEnablePasswordChangeFrequencyLimitForCustomer(): void
577578
MessageInterface::TYPE_ERROR
578579
);
579580

580-
// Wait for 2 minutes before resetting password
581-
sleep(120);
581+
// Wait for 1 minute before resetting password
582+
sleep(60);
582583

583584
// Clicking on the forgot password link
584585
$this->getRequest()->setPostValue('email', $email);

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use Magento\Framework\Exception\LocalizedException;
2828
use Magento\Framework\Exception\RuntimeException;
2929
use Magento\Framework\Filesystem;
30+
use Magento\Framework\Indexer\IndexerInterface;
31+
use Magento\Framework\Indexer\IndexerRegistry;
3032
use Magento\Framework\Model\ResourceModel\Db\Context;
3133
use Magento\Framework\Module\ModuleList\Loader as ModuleLoader;
3234
use Magento\Framework\Module\ModuleListInterface;
@@ -46,6 +48,7 @@
4648
use Magento\Framework\Setup\UpgradeDataInterface;
4749
use Magento\Framework\Setup\UpgradeSchemaInterface;
4850
use Magento\Framework\Validation\ValidationException;
51+
use Magento\Indexer\Model\Indexer\Collection;
4952
use Magento\PageCache\Model\Cache\Type as PageCache;
5053
use Magento\RemoteStorage\Driver\DriverException;
5154
use Magento\Setup\Console\Command\InstallCommand;
@@ -337,6 +340,8 @@ public function __construct(
337340
* @throws FileSystemException
338341
* @throws LocalizedException
339342
* @throws RuntimeException
343+
* @SuppressWarnings(PHPMD.NPathComplexity)
344+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
340345
*/
341346
public function install($request)
342347
{
@@ -374,6 +379,9 @@ public function install($request)
374379
$script[] = ['Disabling Maintenance Mode:', 'setMaintenanceMode', [0]];
375380
$script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []];
376381
$script[] = ['Write installation date...', 'writeInstallationDate', []];
382+
if (empty($request['magento-init-params'])) {
383+
$script[] = ['Enabling Update by Schedule Indexer Mode...', 'setIndexerModeSchedule', []];
384+
}
377385
$estimatedModules = $this->createModulesConfig($request, true);
378386
$total = count($script) + 4 * count(array_filter($estimatedModules));
379387
$this->progress = new Installer\Progress($total, 0);
@@ -1838,4 +1846,32 @@ private function revertRemoteStorageConfiguration()
18381846
$configData = [$remoteStorageData->getFileKey() => $remoteStorageData->getData()];
18391847
$this->deploymentConfigWriter->saveConfig($configData, true);
18401848
}
1849+
1850+
/**
1851+
* Set Index mode as 'Update by Schedule'
1852+
*
1853+
* @return void
1854+
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) Called by install() via callback.
1855+
* @throws LocalizedException
1856+
* @throws \Exception
1857+
*/
1858+
private function setIndexerModeSchedule(): void
1859+
{
1860+
/** @var Collection $indexCollection */
1861+
$indexCollection = $this->objectManagerProvider->get()->get(Collection::class);
1862+
$indexerIds = $indexCollection->getAllIds();
1863+
try {
1864+
foreach ($indexerIds as $indexerId) {
1865+
/** @var IndexerInterface $model */
1866+
$model = $this->objectManagerProvider->get()->get(IndexerRegistry::class)
1867+
->get($indexerId);
1868+
$model->setScheduled(true);
1869+
}
1870+
$this->log->log(__('%1 indexer(s) are in "Update by Schedule" mode.', count($indexerIds)));
1871+
} catch (LocalizedException $e) {
1872+
$this->log->log($e->getMessage());
1873+
} catch (\Exception $e) {
1874+
$this->log->log(__("We couldn't change indexer(s)' mode because of an error: ".$e->getMessage()));
1875+
}
1876+
}
18411877
}

setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
use Magento\Framework\Filesystem;
3030
use Magento\Framework\Filesystem\Directory\WriteInterface;
3131
use Magento\Framework\Filesystem\DriverPool;
32+
use Magento\Framework\Indexer\IndexerInterface;
33+
use Magento\Framework\Indexer\IndexerRegistry;
3234
use Magento\Framework\Model\ResourceModel\Db\Context;
3335
use Magento\Framework\Module\ModuleList\Loader;
3436
use Magento\Framework\Module\ModuleListInterface;
@@ -42,6 +44,7 @@
4244
use Magento\Framework\Setup\SampleData\State;
4345
use Magento\Framework\Setup\SchemaListener;
4446
use Magento\Framework\Validation\ValidationException;
47+
use Magento\Indexer\Model\Indexer\Collection;
4548
use Magento\RemoteStorage\Driver\DriverException;
4649
use Magento\RemoteStorage\Setup\ConfigOptionsList as RemoteStorageValidator;
4750
use Magento\Setup\Console\Command\InstallCommand;
@@ -224,6 +227,19 @@ class InstallerTest extends TestCase
224227
*/
225228
private $patchApplierFactoryMock;
226229

230+
/**
231+
* @var Collection|MockObject
232+
*/
233+
private $indexerMock;
234+
/**
235+
* @var IndexerRegistry|MockObject
236+
*/
237+
private $indexerRegistryMock;
238+
/**
239+
* @var IndexerInterface|MockObject
240+
*/
241+
private $indexerInterfaceMock;
242+
227243
/**
228244
* @inheritdoc
229245
*/
@@ -263,6 +279,10 @@ protected function setUp(): void
263279
$this->patchApplierFactoryMock->expects($this->any())->method('create')->willReturn(
264280
$this->patchApplierMock
265281
);
282+
$this->indexerMock = $this->createMock(Collection::class);
283+
$this->indexerRegistryMock = $this->createMock(IndexerRegistry::class);
284+
$this->indexerInterfaceMock = $this->getMockForAbstractClass(IndexerInterface::class);
285+
266286
$this->object = $this->createObject();
267287
}
268288

@@ -429,7 +449,9 @@ public function testInstall(array $request, array $logMessages)
429449
[DeclarationInstaller::class, $this->declarationInstallerMock],
430450
[Registry::class, $registry],
431451
[SearchConfig::class, $searchConfigMock],
432-
[RemoteStorageValidator::class, $remoteStorageValidatorMock]
452+
[RemoteStorageValidator::class, $remoteStorageValidatorMock],
453+
[Collection::class, $this->indexerMock],
454+
[IndexerRegistry::class, $this->indexerRegistryMock]
433455
]
434456
);
435457
$this->adminFactory->expects($this->any())->method('create')->willReturn(
@@ -445,6 +467,15 @@ public function testInstall(array $request, array $logMessages)
445467
$this->filePermissions->expects($this->once())
446468
->method('getMissingWritableDirectoriesForDbUpgrade')
447469
->willReturn([]);
470+
$this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
471+
[
472+
'catalog_category_product',
473+
'catalog_product_category',
474+
]
475+
);
476+
$this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
477+
$this->indexerInterfaceMock
478+
);
448479
call_user_func_array(
449480
[
450481
$this->logger->expects($this->exactly(count($logMessages)))->method('log'),
@@ -507,6 +538,8 @@ public function installDataProvider()
507538
['Disabling Maintenance Mode:'],
508539
['Post installation file permissions check...'],
509540
['Write installation date...'],
541+
['Enabling Update by Schedule Indexer Mode...'],
542+
['2 indexer(s) are in "Update by Schedule" mode.'],
510543
['Sample Data is installed with errors. See log file for details']
511544
],
512545
],
@@ -560,6 +593,8 @@ public function installDataProvider()
560593
['Disabling Maintenance Mode:'],
561594
['Post installation file permissions check...'],
562595
['Write installation date...'],
596+
['Enabling Update by Schedule Indexer Mode...'],
597+
['2 indexer(s) are in "Update by Schedule" mode.'],
563598
['Sample Data is installed with errors. See log file for details']
564599
],
565600
],
@@ -698,9 +733,20 @@ public function testInstallWithOrderIncrementPrefix(array $request, array $logMe
698733
[DeclarationInstaller::class, $this->declarationInstallerMock],
699734
[Registry::class, $registry],
700735
[SearchConfig::class, $searchConfigMock],
701-
[RemoteStorageValidator::class, $remoteStorageValidatorMock]
736+
[RemoteStorageValidator::class, $remoteStorageValidatorMock],
737+
[Collection::class, $this->indexerMock],
738+
[IndexerRegistry::class, $this->indexerRegistryMock]
702739
]
703740
);
741+
$this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
742+
[
743+
'catalog_category_product',
744+
'catalog_product_category',
745+
]
746+
);
747+
$this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
748+
$this->indexerInterfaceMock
749+
);
704750
$this->adminFactory->expects($this->any())->method('create')->willReturn(
705751
$this->createMock(AdminAccount::class)
706752
);
@@ -784,6 +830,8 @@ public function installWithOrderIncrementPrefixDataProvider(): array
784830
['Disabling Maintenance Mode:'],
785831
['Post installation file permissions check...'],
786832
['Write installation date...'],
833+
['Enabling Update by Schedule Indexer Mode...'],
834+
['2 indexer(s) are in "Update by Schedule" mode.'],
787835
['Sample Data is installed with errors. See log file for details']
788836
],
789837
],
@@ -1103,14 +1151,17 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
11031151
$objectManagerReturnMapSequence = [
11041152
0 => [Registry::class, $registry],
11051153
1 => [DeclarationInstaller::class, $this->declarationInstallerMock],
1106-
3 => [SearchConfig::class, $searchConfigMock],
1107-
4 => [
1154+
2 => [SearchConfig::class, $searchConfigMock],
1155+
3 => [
11081156
RemoteStorageValidator::class,
11091157
new ReflectionException('Class ' . RemoteStorageValidator::class . ' does not exist')
11101158
],
1111-
5 => [\Magento\Framework\App\State::class, $appState],
1112-
7 => [Registry::class, $registry],
1113-
11 => [Manager::class, $cacheManager]
1159+
4 => [\Magento\Framework\App\State::class, $appState],
1160+
5 => [Registry::class, $registry],
1161+
6 => [Manager::class, $cacheManager],
1162+
7 => [Collection::class, $this->indexerMock],
1163+
8 => [IndexerRegistry::class, $this->indexerRegistryMock],
1164+
9 => [IndexerRegistry::class, $this->indexerRegistryMock]
11141165
];
11151166
$withArgs = $willReturnArgs = [];
11161167

@@ -1130,6 +1181,15 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
11301181
->withConsecutive(...$withArgs)
11311182
->willReturnOnConsecutiveCalls(...$willReturnArgs);
11321183

1184+
$this->indexerMock->expects($this->once())->method('getAllIds')->willReturn(
1185+
[
1186+
'catalog_category_product',
1187+
'catalog_product_category',
1188+
]
1189+
);
1190+
$this->indexerRegistryMock->expects($this->exactly(2))->method('get')->willReturn(
1191+
$this->indexerInterfaceMock
1192+
);
11331193
$this->adminFactory->expects(static::any())->method('create')->willReturn(
11341194
$this->createMock(AdminAccount::class)
11351195
);

0 commit comments

Comments
 (0)