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 ;
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