Skip to content

Commit 48591e8

Browse files
CE-33707: Fixed InstallerTest
1 parent 62a5062 commit 48591e8

File tree

1 file changed

+99
-76
lines changed

1 file changed

+99
-76
lines changed

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

Lines changed: 99 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class InstallerTest extends TestCase
7373
ConfigOptionsListConstants::INPUT_KEY_DB_NAME => 'magento',
7474
ConfigOptionsListConstants::INPUT_KEY_DB_USER => 'magento',
7575
ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY => 'encryption_key',
76-
ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'backend',
76+
ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'backend'
7777
];
7878

7979
/**
@@ -200,7 +200,7 @@ class InstallerTest extends TestCase
200200
ConfigOptionsListConstants::KEY_HOST => '127.0.0.1',
201201
ConfigOptionsListConstants::KEY_NAME => 'magento',
202202
ConfigOptionsListConstants::KEY_USER => 'magento',
203-
ConfigOptionsListConstants::KEY_PASSWORD => '',
203+
ConfigOptionsListConstants::KEY_PASSWORD => ''
204204
]
205205
];
206206

@@ -219,6 +219,9 @@ class InstallerTest extends TestCase
219219
*/
220220
private $patchApplierFactoryMock;
221221

222+
/**
223+
* @inheritdoc
224+
*/
222225
protected function setUp(): void
223226
{
224227
$this->filePermissions = $this->createMock(FilePermissions::class);
@@ -368,37 +371,41 @@ public function testInstall(array $request, array $logMessages)
368371
$this->dataSetupFactory->expects($this->atLeastOnce())->method('create')->willReturn($dataSetup);
369372
$this->objectManager->expects($this->any())
370373
->method('create')
371-
->willReturnMap([
372-
[Manager::class, [], $cacheManager],
373-
[\Magento\Framework\App\State::class, [], $appState],
374-
[
375-
PatchApplierFactory::class,
376-
['objectManager' => $this->objectManager],
377-
$this->patchApplierFactoryMock
378-
],
379-
]);
374+
->willReturnMap(
375+
[
376+
[Manager::class, [], $cacheManager],
377+
[\Magento\Framework\App\State::class, [], $appState],
378+
[
379+
PatchApplierFactory::class,
380+
['objectManager' => $this->objectManager],
381+
$this->patchApplierFactoryMock
382+
],
383+
]
384+
);
380385
$this->patchApplierMock->expects($this->exactly(2))->method('applySchemaPatch')->willReturnMap(
381386
[
382387
['Bar_Two'],
383-
['Foo_One'],
388+
['Foo_One']
384389
]
385390
);
386391
$this->patchApplierMock->expects($this->exactly(2))->method('applyDataPatch')->willReturnMap(
387392
[
388393
['Bar_Two'],
389-
['Foo_One'],
394+
['Foo_One']
390395
]
391396
);
392397
$this->objectManager->expects($this->any())
393398
->method('get')
394-
->willReturnMap([
395-
[\Magento\Framework\App\State::class, $appState],
396-
[Manager::class, $cacheManager],
397-
[DeclarationInstaller::class, $this->declarationInstallerMock],
398-
[Registry::class, $registry],
399-
[SearchConfig::class, $searchConfigMock],
400-
[RemoteStorageValidator::class, $remoteStorageValidatorMock],
401-
]);
399+
->willReturnMap(
400+
[
401+
[\Magento\Framework\App\State::class, $appState],
402+
[Manager::class, $cacheManager],
403+
[DeclarationInstaller::class, $this->declarationInstallerMock],
404+
[Registry::class, $registry],
405+
[SearchConfig::class, $searchConfigMock],
406+
[RemoteStorageValidator::class, $remoteStorageValidatorMock]
407+
]
408+
);
402409
$this->adminFactory->expects($this->any())->method('create')->willReturn(
403410
$this->createMock(AdminAccount::class)
404411
);
@@ -488,7 +495,7 @@ public function installDataProvider()
488495
AdminAccount::KEY_PASSWORD => '123',
489496
AdminAccount::KEY_EMAIL => 'admin@example.com',
490497
AdminAccount::KEY_FIRST_NAME => 'John',
491-
AdminAccount::KEY_LAST_NAME => 'Doe',
498+
AdminAccount::KEY_LAST_NAME => 'Doe'
492499
],
493500
'logMessages' => [
494501
['Starting Magento installation:'],
@@ -654,31 +661,35 @@ public function testInstallWithInvalidRemoteStorageConfiguration(bool $isDeploym
654661

655662
$this->objectManager->expects(static::any())
656663
->method('create')
657-
->willReturnMap([
658-
[Manager::class, [], $cacheManager],
659-
[\Magento\Framework\App\State::class, [], $appState],
660-
[
661-
PatchApplierFactory::class,
662-
['objectManager' => $this->objectManager],
663-
$this->patchApplierFactoryMock
664-
]
665-
]);
664+
->willReturnMap(
665+
[
666+
[Manager::class, [], $cacheManager],
667+
[\Magento\Framework\App\State::class, [], $appState],
668+
[
669+
PatchApplierFactory::class,
670+
['objectManager' => $this->objectManager],
671+
$this->patchApplierFactoryMock
672+
]
673+
]
674+
);
666675
$this->patchApplierMock->expects(static::exactly(2))->method('applySchemaPatch')->willReturnMap(
667676
[
668677
['Bar_Two'],
669-
['Foo_One'],
678+
['Foo_One']
670679
]
671680
);
672681
$this->objectManager->expects(static::any())
673682
->method('get')
674-
->willReturnMap([
675-
[\Magento\Framework\App\State::class, $appState],
676-
[Manager::class, $cacheManager],
677-
[DeclarationInstaller::class, $this->declarationInstallerMock],
678-
[Registry::class, $registry],
679-
[SearchConfig::class, $searchConfigMock],
680-
[RemoteStorageValidator::class, $remoteStorageValidatorMock]
681-
]);
683+
->willReturnMap(
684+
[
685+
[\Magento\Framework\App\State::class, $appState],
686+
[Manager::class, $cacheManager],
687+
[DeclarationInstaller::class, $this->declarationInstallerMock],
688+
[Registry::class, $registry],
689+
[SearchConfig::class, $searchConfigMock],
690+
[RemoteStorageValidator::class, $remoteStorageValidatorMock]
691+
]
692+
);
682693

683694
$this->sampleDataState->expects(static::never())->method('hasError');
684695

@@ -808,25 +819,27 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
808819
$this->dataSetupFactory->expects(static::atLeastOnce())->method('create')->willReturn($dataSetup);
809820
$this->objectManager->expects(static::any())
810821
->method('create')
811-
->willReturnMap([
812-
[Manager::class, [], $cacheManager],
813-
[\Magento\Framework\App\State::class, [], $appState],
814-
[
815-
PatchApplierFactory::class,
816-
['objectManager' => $this->objectManager],
817-
$this->patchApplierFactoryMock
818-
],
819-
]);
822+
->willReturnMap(
823+
[
824+
[Manager::class, [], $cacheManager],
825+
[\Magento\Framework\App\State::class, [], $appState],
826+
[
827+
PatchApplierFactory::class,
828+
['objectManager' => $this->objectManager],
829+
$this->patchApplierFactoryMock
830+
]
831+
]
832+
);
820833
$this->patchApplierMock->expects(static::exactly(2))->method('applySchemaPatch')->willReturnMap(
821834
[
822835
['Bar_Two'],
823-
['Foo_One'],
836+
['Foo_One']
824837
]
825838
);
826839
$this->patchApplierMock->expects(static::exactly(2))->method('applyDataPatch')->willReturnMap(
827840
[
828841
['Bar_Two'],
829-
['Foo_One'],
842+
['Foo_One']
830843
]
831844
);
832845

@@ -836,11 +849,11 @@ public function testInstallWithUnresolvableRemoteStorageValidator()
836849
3 => [SearchConfig::class, $searchConfigMock],
837850
4 => [
838851
RemoteStorageValidator::class,
839-
new ReflectionException('Class ' . RemoteStorageValidator::class . ' does not exist'),
852+
new ReflectionException('Class ' . RemoteStorageValidator::class . ' does not exist')
840853
],
841854
5 => [\Magento\Framework\App\State::class, $appState],
842855
7 => [Registry::class, $registry],
843-
11 => [Manager::class, $cacheManager],
856+
11 => [Manager::class, $cacheManager]
844857
];
845858
$withArgs = $willReturnArgs = [];
846859

@@ -989,10 +1002,12 @@ public function testInstallWithInvalidRemoteStorageConfigurationWithEarlyExcepti
9891002

9901003
$this->objectManager->expects(static::any())
9911004
->method('get')
992-
->willReturnMap([
993-
[DeclarationInstaller::class, $this->declarationInstallerMock],
994-
[Registry::class, $registry]
995-
]);
1005+
->willReturnMap(
1006+
[
1007+
[DeclarationInstaller::class, $this->declarationInstallerMock],
1008+
[Registry::class, $registry]
1009+
]
1010+
);
9961011

9971012
$this->sampleDataState->expects(static::never())->method('hasError');
9981013

@@ -1051,14 +1066,16 @@ public function testInstallDataFixtures(bool $keepCache, array $expectedToEnable
10511066

10521067
$this->objectManager->expects($this->atLeastOnce())
10531068
->method('create')
1054-
->willReturnMap([
1055-
[Manager::class, [], $cacheManagerMock],
1056-
[
1057-
PatchApplierFactory::class,
1058-
['objectManager' => $this->objectManager],
1059-
$this->patchApplierFactoryMock
1060-
],
1061-
]);
1069+
->willReturnMap(
1070+
[
1071+
[Manager::class, [], $cacheManagerMock],
1072+
[
1073+
PatchApplierFactory::class,
1074+
['objectManager' => $this->objectManager],
1075+
$this->patchApplierFactoryMock
1076+
],
1077+
]
1078+
);
10621079

10631080
$registryMock = $this->createMock(Registry::class);
10641081
$this->objectManager->expects($this->atLeastOnce())
@@ -1219,10 +1236,12 @@ public function testUninstall(): void
12191236
->method('get')
12201237
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS)
12211238
->willReturn([]);
1222-
$this->configReader->expects($this->once())->method('getFiles')->willReturn([
1223-
'ConfigOne.php',
1224-
'ConfigTwo.php'
1225-
]);
1239+
$this->configReader->expects($this->once())->method('getFiles')->willReturn(
1240+
[
1241+
'ConfigOne.php',
1242+
'ConfigTwo.php'
1243+
]
1244+
);
12261245
$configDir = $this->getMockForAbstractClass(
12271246
WriteInterface::class
12281247
);
@@ -1238,9 +1257,11 @@ public function testUninstall(): void
12381257
$this->filesystem
12391258
->expects($this->any())
12401259
->method('getDirectoryWrite')
1241-
->willReturnMap([
1242-
[DirectoryList::CONFIG, DriverPool::FILE, $configDir],
1243-
]);
1260+
->willReturnMap(
1261+
[
1262+
[DirectoryList::CONFIG, DriverPool::FILE, $configDir],
1263+
]
1264+
);
12441265
$cacheManager = $this->createMock(Manager::class);
12451266
$cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
12461267
$cacheManager->expects($this->once())->method('clean');
@@ -1307,17 +1328,19 @@ private function prepareForUpdateModulesTests()
13071328
$allModules = [
13081329
'Foo_One' => [],
13091330
'Bar_Two' => [],
1310-
'New_Module' => [],
1331+
'New_Module' => []
13111332
];
13121333

13131334
$cacheManager = $this->createMock(Manager::class);
13141335
$cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
13151336
$cacheManager->expects($this->once())->method('clean');
13161337
$this->objectManager->expects($this->any())
13171338
->method('get')
1318-
->willReturnMap([
1319-
[Manager::class, $cacheManager]
1320-
]);
1339+
->willReturnMap(
1340+
[
1341+
[Manager::class, $cacheManager]
1342+
]
1343+
);
13211344
$this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules);
13221345

13231346
$expectedModules = [

0 commit comments

Comments
 (0)