Skip to content

Commit b99ac91

Browse files
committed
Fixed unit tests (I think)
1 parent 2d59cb8 commit b99ac91

File tree

1 file changed

+149
-22
lines changed

1 file changed

+149
-22
lines changed

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

Lines changed: 149 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,11 @@ private function createObject($connectionFactory = false, $objectManagerProvider
318318
/**
319319
* @param array $request
320320
* @param array $logMessages
321+
* @param array $logMetaMessages
321322
* @dataProvider installDataProvider
322323
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
323324
*/
324-
public function testInstall(array $request, array $logMessages)
325+
public function testInstall(array $request, array $logMessages, array $logMetaMessages)
325326
{
326327
$this->moduleList->method('getOne')
327328
->willReturnMap(
@@ -452,6 +453,13 @@ public function testInstall(array $request, array $logMessages)
452453
],
453454
$logMessages
454455
);
456+
call_user_func_array(
457+
[
458+
$this->logger->expects($this->exactly(count($logMetaMessages)))->method('logMeta'),
459+
'withConsecutive'
460+
],
461+
$logMetaMessages
462+
);
455463
$this->logger->expects($this->exactly(3))
456464
->method('logSuccess')
457465
->withConsecutive(
@@ -502,6 +510,37 @@ public function installDataProvider()
502510
['Write installation date...'],
503511
['Sample Data is installed with errors. See log file for details']
504512
],
513+
'logMetaMessages' => [
514+
['Starting Magento installation:'],
515+
['[Progress: 1 / 22]'],
516+
['[Progress: 2 / 22]'],
517+
['[Progress: 3 / 22]'],
518+
['[Progress: 4 / 22]'],
519+
['Schema creation/updates:'],
520+
['[Progress: 5 / 22]'],
521+
['[Progress: 6 / 22]'],
522+
['Schema post-updates:'],
523+
['[Progress: 7 / 22]'],
524+
['[Progress: 8 / 22]'],
525+
['[Progress: 9 / 22]'],
526+
['[Progress: 10 / 22]'],
527+
['[Progress: 11 / 22]'],
528+
['[Progress: 12 / 22]'],
529+
['[Progress: 13 / 22]'],
530+
['Data install/update:'],
531+
['Disabling caches:'],
532+
['[Progress: 14 / 22]'],
533+
['[Progress: 15 / 22]'],
534+
['Data post-updates:'],
535+
['[Progress: 16 / 22]'],
536+
['[Progress: 17 / 22]'],
537+
['Enabling caches:'],
538+
['[Progress: 18 / 22]'],
539+
['[Progress: 19 / 22]'],
540+
['[Progress: 20 / 22]'],
541+
['[Progress: 21 / 22]'],
542+
['[Progress: 22 / 22]'],
543+
],
505544
],
506545
[
507546
'request' => [
@@ -547,6 +586,38 @@ public function installDataProvider()
547586
['Write installation date...'],
548587
['Sample Data is installed with errors. See log file for details']
549588
],
589+
'logMetaMessages' => [
590+
['Starting Magento installation:'],
591+
['[Progress: 1 / 23]'],
592+
['[Progress: 2 / 23]'],
593+
['[Progress: 3 / 23]'],
594+
['[Progress: 4 / 23]'],
595+
['Schema creation/updates:'],
596+
['[Progress: 5 / 23]'],
597+
['[Progress: 6 / 23]'],
598+
['Schema post-updates:'],
599+
['[Progress: 7 / 23]'],
600+
['[Progress: 8 / 23]'],
601+
['[Progress: 9 / 23]'],
602+
['[Progress: 10 / 23]'],
603+
['[Progress: 11 / 23]'],
604+
['[Progress: 12 / 23]'],
605+
['[Progress: 13 / 23]'],
606+
['Data install/update:'],
607+
['Disabling caches:'],
608+
['[Progress: 14 / 23]'],
609+
['[Progress: 15 / 23]'],
610+
['Data post-updates:'],
611+
['[Progress: 16 / 23]'],
612+
['[Progress: 17 / 23]'],
613+
['Enabling caches:'],
614+
['[Progress: 18 / 23]'],
615+
['[Progress: 19 / 23]'],
616+
['[Progress: 20 / 23]'],
617+
['[Progress: 21 / 23]'],
618+
['[Progress: 22 / 23]'],
619+
['[Progress: 23 / 23]'],
620+
],
550621
],
551622
];
552623
}
@@ -556,13 +627,14 @@ public function installDataProvider()
556627
*
557628
* @param array $request
558629
* @param array $logMessages
630+
* @param array $logMetaMessages
559631
* @throws RuntimeException
560632
* @throws FileSystemException
561633
* @throws LocalizedException
562634
* @dataProvider installWithOrderIncrementPrefixDataProvider
563635
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
564636
*/
565-
public function testInstallWithOrderIncrementPrefix(array $request, array $logMessages)
637+
public function testInstallWithOrderIncrementPrefix(array $request, array $logMessages, array $logMetaMessages)
566638
{
567639
$this->moduleList->method('getOne')
568640
->willReturnMap(
@@ -706,9 +778,17 @@ public function testInstallWithOrderIncrementPrefix(array $request, array $logMe
706778
],
707779
$logMessages
708780
);
709-
$this->logger->expects($this->exactly(2))
781+
call_user_func_array(
782+
[
783+
$this->logger->expects($this->exactly(count($logMetaMessages)))->method('logMeta'),
784+
'withConsecutive'
785+
],
786+
$logMetaMessages
787+
);
788+
$this->logger->expects($this->exactly(3))
710789
->method('logSuccess')
711790
->withConsecutive(
791+
['Cache cleared successfully'],
712792
['Magento installation complete.'],
713793
['Magento Admin URI: /']
714794
);
@@ -733,16 +813,13 @@ public function installWithOrderIncrementPrefixDataProvider(): array
733813
InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX => 'ORD'
734814
],
735815
'logMessages' => [
736-
['Starting Magento installation:'],
737816
['File permissions check...'],
738817
['Required extensions check...'],
739818
['Enabling Maintenance Mode...'],
740819
['Installing deployment configuration...'],
741820
['Installing database schema:'],
742-
['Schema creation/updates:'],
743821
['Module \'Foo_One\':'],
744822
['Module \'Bar_Two\':'],
745-
['Schema post-updates:'],
746823
['Module \'Foo_One\':'],
747824
['Module \'Bar_Two\':'],
748825
['Installing search configuration...'],
@@ -753,24 +830,51 @@ public function installWithOrderIncrementPrefixDataProvider(): array
753830
['foo: 1'],
754831
['bar: 1'],
755832
['Installing data...'],
756-
['Data install/update:'],
757-
['Disabling caches:'],
758833
['Current status:'],
759834
['Module \'Foo_One\':'],
760835
['Module \'Bar_Two\':'],
761-
['Data post-updates:'],
762836
['Module \'Foo_One\':'],
763837
['Module \'Bar_Two\':'],
764-
['Enabling caches:'],
765838
['Current status:'],
766839
['Creating sales order increment prefix...'], // << added
767840
['Caches clearing:'],
768-
['Cache cleared successfully'],
769841
['Disabling Maintenance Mode:'],
770842
['Post installation file permissions check...'],
771843
['Write installation date...'],
772844
['Sample Data is installed with errors. See log file for details']
773845
],
846+
'logMetaMessages' => [
847+
['Starting Magento installation:'],
848+
['[Progress: 1 / 23]'],
849+
['[Progress: 2 / 23]'],
850+
['[Progress: 3 / 23]'],
851+
['[Progress: 4 / 23]'],
852+
['Schema creation/updates:'],
853+
['[Progress: 5 / 23]'],
854+
['[Progress: 6 / 23]'],
855+
['Schema post-updates:'],
856+
['[Progress: 7 / 23]'],
857+
['[Progress: 8 / 23]'],
858+
['[Progress: 9 / 23]'],
859+
['[Progress: 10 / 23]'],
860+
['[Progress: 11 / 23]'],
861+
['[Progress: 12 / 23]'],
862+
['[Progress: 13 / 23]'],
863+
['Data install/update:'],
864+
['Disabling caches:'],
865+
['[Progress: 14 / 23]'],
866+
['[Progress: 15 / 23]'],
867+
['Data post-updates:'],
868+
['[Progress: 16 / 23]'],
869+
['[Progress: 17 / 23]'],
870+
['Enabling caches:'],
871+
['[Progress: 18 / 23]'],
872+
['[Progress: 19 / 23]'],
873+
['[Progress: 20 / 23]'],
874+
['[Progress: 21 / 23]'],
875+
['[Progress: 22 / 23]'],
876+
['[Progress: 23 / 23]'],
877+
],
774878
],
775879
];
776880
}
@@ -798,7 +902,6 @@ public function testInstallWithInvalidRemoteStorageConfiguration(bool $isDeploym
798902
['Installing database schema:'],
799903
['Module \'Foo_One\':'],
800904
['Module \'Bar_Two\':'],
801-
['Schema post-updates:'],
802905
['Module \'Foo_One\':'],
803906
['Module \'Bar_Two\':'],
804907
['Installing search configuration...'],
@@ -807,7 +910,18 @@ public function testInstallWithInvalidRemoteStorageConfiguration(bool $isDeploym
807910

808911
$logMetaMessages = [
809912
['Starting Magento installation:'],
913+
['[Progress: 1 / 22]'],
914+
['[Progress: 2 / 22]'],
915+
['[Progress: 3 / 22]'],
916+
['[Progress: 4 / 22]'],
810917
['Schema creation/updates:'],
918+
['[Progress: 5 / 22]'],
919+
['[Progress: 6 / 22]'],
920+
['Schema post-updates:'],
921+
['[Progress: 7 / 22]'],
922+
['[Progress: 8 / 22]'],
923+
['[Progress: 9 / 22]'],
924+
['[Progress: 10 / 22]'],
811925
];
812926

813927
$this->config->expects(static::atLeastOnce())
@@ -988,6 +1102,7 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
9881102

9891103
// every log message call is expected
9901104
$logMessages = $this->installDataProvider()[0]['logMessages'];
1105+
$logMetaMessages = $this->installDataProvider()[0]['logMetaMessages'];
9911106

9921107
$this->config->expects(static::atLeastOnce())
9931108
->method('get')
@@ -1145,9 +1260,17 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
11451260
],
11461261
$logMessages
11471262
);
1148-
$this->logger->expects(static::exactly(2))
1263+
call_user_func_array(
1264+
[
1265+
$this->logger->expects(static::exactly(count($logMetaMessages)))->method('logMeta'),
1266+
'withConsecutive'
1267+
],
1268+
$logMetaMessages
1269+
);
1270+
$this->logger->expects(static::exactly(3))
11491271
->method('logSuccess')
11501272
->withConsecutive(
1273+
['Cache cleared successfully'],
11511274
['Magento installation complete.'],
11521275
['Magento Admin URI: /']
11531276
);
@@ -1179,7 +1302,11 @@ public function testInstallWithInvalidRemoteStorageConfigurationWithEarlyExcepti
11791302

11801303
$logMetaMessages = [
11811304
['Starting Magento installation:'],
1182-
['Schema creation/updates:']
1305+
['[Progress: 1 / 22]'],
1306+
['[Progress: 2 / 22]'],
1307+
['[Progress: 3 / 22]'],
1308+
['[Progress: 4 / 22]'],
1309+
['Schema creation/updates:'],
11831310
];
11841311

11851312
$this->config->expects(static::atLeastOnce())
@@ -1468,17 +1595,20 @@ public function testUpdateModulesSequence()
14681595
$this->logger
14691596
->method('log')
14701597
->withConsecutive(
1471-
['Cache types config flushed successfully'],
1472-
['Cache cleared successfully'],
14731598
['The directory \'/generation\' doesn\'t exist - skipping cleanup'],
14741599
);
1475-
14761600
$this->logger
14771601
->method('logMeta')
14781602
->withConsecutive(
14791603
['File system cleanup:'],
14801604
['Updating modules:']
14811605
);
1606+
$this->logger
1607+
->method('logSuccess')
1608+
->withConsecutive(
1609+
['Cache types config flushed successfully'],
1610+
['Cache cleared successfully'],
1611+
);
14821612

14831613
$installer->updateModulesSequence(false);
14841614
}
@@ -1489,12 +1619,11 @@ public function testUpdateModulesSequenceKeepGenerated()
14891619

14901620
$installer = $this->prepareForUpdateModulesTests();
14911621
$this->logger
1492-
->method('log')
1622+
->method('logSuccess')
14931623
->withConsecutive(
14941624
['Cache types config flushed successfully'],
14951625
['Cache cleared successfully'],
14961626
);
1497-
14981627
$this->logger
14991628
->method('logMeta')
15001629
->withConsecutive(
@@ -1546,7 +1675,6 @@ public function testUninstall(): void
15461675
->method('get')
15471676
->with(Manager::class)
15481677
->willReturn($cacheManager);
1549-
$this->logger->expects($this->once())->method('logSuccess')->with('Magento uninstallation complete.');
15501678
$this->cleanupFiles->expects($this->once())->method('clearAllFiles')->willReturn(
15511679
[
15521680
"The directory '/var' doesn't exist - skipping cleanup",
@@ -1563,18 +1691,17 @@ public function testUninstall(): void
15631691
["The file '/config/ConfigOne.php' doesn't exist - skipping cleanup"],
15641692
["The file '/config/ConfigTwo.php' doesn't exist - skipping cleanup"]
15651693
);
1566-
15671694
$this->logger
15681695
->method('logMeta')
15691696
->withConsecutive(
15701697
['Starting Magento uninstallation:'],
15711698
['File system cleanup:'],
15721699
);
1573-
15741700
$this->logger
15751701
->method('logSuccess')
15761702
->withConsecutive(
15771703
['Cache cleared successfully'],
1704+
['Magento uninstallation complete.'],
15781705
);
15791706

15801707
$this->object->uninstall();

0 commit comments

Comments
 (0)