29
29
use Magento \Framework \Filesystem ;
30
30
use Magento \Framework \Filesystem \Directory \WriteInterface ;
31
31
use Magento \Framework \Filesystem \DriverPool ;
32
+ use Magento \Framework \Indexer \IndexerInterface ;
33
+ use Magento \Framework \Indexer \IndexerRegistry ;
32
34
use Magento \Framework \Model \ResourceModel \Db \Context ;
33
35
use Magento \Framework \Module \ModuleList \Loader ;
34
36
use Magento \Framework \Module \ModuleListInterface ;
42
44
use Magento \Framework \Setup \SampleData \State ;
43
45
use Magento \Framework \Setup \SchemaListener ;
44
46
use Magento \Framework \Validation \ValidationException ;
47
+ use Magento \Indexer \Model \Indexer \Collection ;
45
48
use Magento \RemoteStorage \Driver \DriverException ;
46
49
use Magento \RemoteStorage \Setup \ConfigOptionsList as RemoteStorageValidator ;
47
50
use Magento \Setup \Console \Command \InstallCommand ;
@@ -224,6 +227,19 @@ class InstallerTest extends TestCase
224
227
*/
225
228
private $ patchApplierFactoryMock ;
226
229
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
+
227
243
/**
228
244
* @inheritdoc
229
245
*/
@@ -263,6 +279,10 @@ protected function setUp(): void
263
279
$ this ->patchApplierFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn (
264
280
$ this ->patchApplierMock
265
281
);
282
+ $ this ->indexerMock = $ this ->createMock (Collection::class);
283
+ $ this ->indexerRegistryMock = $ this ->createMock (IndexerRegistry::class);
284
+ $ this ->indexerInterfaceMock = $ this ->getMockForAbstractClass (IndexerInterface::class);
285
+
266
286
$ this ->object = $ this ->createObject ();
267
287
}
268
288
@@ -429,7 +449,9 @@ public function testInstall(array $request, array $logMessages)
429
449
[DeclarationInstaller::class, $ this ->declarationInstallerMock ],
430
450
[Registry::class, $ registry ],
431
451
[SearchConfig::class, $ searchConfigMock ],
432
- [RemoteStorageValidator::class, $ remoteStorageValidatorMock ]
452
+ [RemoteStorageValidator::class, $ remoteStorageValidatorMock ],
453
+ [Collection::class, $ this ->indexerMock ],
454
+ [IndexerRegistry::class, $ this ->indexerRegistryMock ]
433
455
]
434
456
);
435
457
$ this ->adminFactory ->expects ($ this ->any ())->method ('create ' )->willReturn (
@@ -445,6 +467,15 @@ public function testInstall(array $request, array $logMessages)
445
467
$ this ->filePermissions ->expects ($ this ->once ())
446
468
->method ('getMissingWritableDirectoriesForDbUpgrade ' )
447
469
->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
+ );
448
479
call_user_func_array (
449
480
[
450
481
$ this ->logger ->expects ($ this ->exactly (count ($ logMessages )))->method ('log ' ),
@@ -507,6 +538,8 @@ public function installDataProvider()
507
538
['Disabling Maintenance Mode: ' ],
508
539
['Post installation file permissions check... ' ],
509
540
['Write installation date... ' ],
541
+ ['Enabling Update by Schedule Indexer Mode... ' ],
542
+ ['2 indexer(s) are in "Update by Schedule" mode. ' ],
510
543
['Sample Data is installed with errors. See log file for details ' ]
511
544
],
512
545
],
@@ -560,6 +593,8 @@ public function installDataProvider()
560
593
['Disabling Maintenance Mode: ' ],
561
594
['Post installation file permissions check... ' ],
562
595
['Write installation date... ' ],
596
+ ['Enabling Update by Schedule Indexer Mode... ' ],
597
+ ['2 indexer(s) are in "Update by Schedule" mode. ' ],
563
598
['Sample Data is installed with errors. See log file for details ' ]
564
599
],
565
600
],
@@ -698,9 +733,20 @@ public function testInstallWithOrderIncrementPrefix(array $request, array $logMe
698
733
[DeclarationInstaller::class, $ this ->declarationInstallerMock ],
699
734
[Registry::class, $ registry ],
700
735
[SearchConfig::class, $ searchConfigMock ],
701
- [RemoteStorageValidator::class, $ remoteStorageValidatorMock ]
736
+ [RemoteStorageValidator::class, $ remoteStorageValidatorMock ],
737
+ [Collection::class, $ this ->indexerMock ],
738
+ [IndexerRegistry::class, $ this ->indexerRegistryMock ]
702
739
]
703
740
);
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
+ );
704
750
$ this ->adminFactory ->expects ($ this ->any ())->method ('create ' )->willReturn (
705
751
$ this ->createMock (AdminAccount::class)
706
752
);
@@ -784,6 +830,8 @@ public function installWithOrderIncrementPrefixDataProvider(): array
784
830
['Disabling Maintenance Mode: ' ],
785
831
['Post installation file permissions check... ' ],
786
832
['Write installation date... ' ],
833
+ ['Enabling Update by Schedule Indexer Mode... ' ],
834
+ ['2 indexer(s) are in "Update by Schedule" mode. ' ],
787
835
['Sample Data is installed with errors. See log file for details ' ]
788
836
],
789
837
],
@@ -1103,14 +1151,17 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
1103
1151
$ objectManagerReturnMapSequence = [
1104
1152
0 => [Registry::class, $ registry ],
1105
1153
1 => [DeclarationInstaller::class, $ this ->declarationInstallerMock ],
1106
- 3 => [SearchConfig::class, $ searchConfigMock ],
1107
- 4 => [
1154
+ 2 => [SearchConfig::class, $ searchConfigMock ],
1155
+ 3 => [
1108
1156
RemoteStorageValidator::class,
1109
1157
new ReflectionException ('Class ' . RemoteStorageValidator::class . ' does not exist ' )
1110
1158
],
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 ]
1114
1165
];
1115
1166
$ withArgs = $ willReturnArgs = [];
1116
1167
@@ -1130,6 +1181,15 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
1130
1181
->withConsecutive (...$ withArgs )
1131
1182
->willReturnOnConsecutiveCalls (...$ willReturnArgs );
1132
1183
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
+ );
1133
1193
$ this ->adminFactory ->expects (static ::any ())->method ('create ' )->willReturn (
1134
1194
$ this ->createMock (AdminAccount::class)
1135
1195
);
0 commit comments