Skip to content

Commit 3a55007

Browse files
committed
#27500 PHPUnit9 for Setup module
1 parent b8690a3 commit 3a55007

File tree

258 files changed

+1437
-1004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+1437
-1004
lines changed

setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Setup\Console\Command\AdminUserCreateCommand;
@@ -39,7 +41,7 @@ class AdminUserCreateCommandTest extends TestCase
3941
*/
4042
private $command;
4143

42-
public function setUp(): void
44+
protected function setUp(): void
4345
{
4446
$this->installerFactoryMock = $this->createMock(InstallerFactory::class);
4547
$this->command = new AdminUserCreateCommand($this->installerFactoryMock, new UserValidationRules());
@@ -81,23 +83,23 @@ public function testInteraction()
8183

8284
$this->questionHelperMock->expects($this->at(0))
8385
->method('ask')
84-
->will($this->returnValue('admin'));
86+
->willReturn('admin');
8587

8688
$this->questionHelperMock->expects($this->at(1))
8789
->method('ask')
88-
->will($this->returnValue('Password123'));
90+
->willReturn('Password123');
8991

9092
$this->questionHelperMock->expects($this->at(2))
9193
->method('ask')
92-
->will($this->returnValue('[email protected]'));
94+
->willReturn('[email protected]');
9395

9496
$this->questionHelperMock->expects($this->at(3))
9597
->method('ask')
96-
->will($this->returnValue('John'));
98+
->willReturn('John');
9799

98100
$this->questionHelperMock->expects($this->at(4))
99101
->method('ask')
100-
->will($this->returnValue('Doe'));
102+
->willReturn('Doe');
101103

102104
// We override the standard helper with our mock
103105
$this->command->getHelperSet()->set($this->questionHelperMock, 'question');

setup/src/Magento/Setup/Test/Unit/Console/Command/BackupCommandTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Framework\App\Console\MaintenanceModeEnabler;
@@ -46,7 +48,7 @@ class BackupCommandTest extends TestCase
4648
*/
4749
private $deploymentConfig;
4850

49-
public function setUp(): void
51+
protected function setUp(): void
5052
{
5153
$maintenanceMode = $this->createMock(MaintenanceMode::class);
5254
$objectManagerProvider = $this->createMock(ObjectManagerProvider::class);
@@ -74,12 +76,12 @@ public function setUp(): void
7476

7577
$this->objectManager->expects($this->any())
7678
->method('get')
77-
->will(
78-
$this->returnValueMap([
79+
->willReturnMap(
80+
[
7981
[BackupRollbackFactory::class, $this->backupRollbackFactory],
8082
[State::class, $appState],
8183
[ConfigLoaderInterface::class, $configLoader],
82-
])
84+
]
8385
);
8486
$command = new BackupCommand(
8587
$objectManagerProvider,
@@ -94,7 +96,7 @@ public function testExecuteCodeBackup()
9496
{
9597
$this->deploymentConfig->expects($this->once())
9698
->method('isAvailable')
97-
->will($this->returnValue(true));
99+
->willReturn(true);
98100
$this->backupRollback->expects($this->once())
99101
->method('codeBackup')
100102
->willReturn($this->backupRollback);
@@ -105,7 +107,7 @@ public function testExecuteMediaBackup()
105107
{
106108
$this->deploymentConfig->expects($this->once())
107109
->method('isAvailable')
108-
->will($this->returnValue(true));
110+
->willReturn(true);
109111
$this->backupRollback->expects($this->once())
110112
->method('codeBackup')
111113
->willReturn($this->backupRollback);
@@ -116,7 +118,7 @@ public function testExecuteDBBackup()
116118
{
117119
$this->deploymentConfig->expects($this->once())
118120
->method('isAvailable')
119-
->will($this->returnValue(true));
121+
->willReturn(true);
120122
$this->backupRollback->expects($this->once())
121123
->method('dbBackup')
122124
->willReturn($this->backupRollback);
@@ -127,7 +129,7 @@ public function testExecuteNotInstalled()
127129
{
128130
$this->deploymentConfig->expects($this->once())
129131
->method('isAvailable')
130-
->will($this->returnValue(false));
132+
->willReturn(false);
131133
$this->tester->execute(['--db' => true]);
132134
$this->assertStringMatchesFormat(
133135
'No information is available: the Magento application is not installed.%w',
@@ -139,7 +141,7 @@ public function testExecuteNoOptions()
139141
{
140142
$this->deploymentConfig->expects($this->once())
141143
->method('isAvailable')
142-
->will($this->returnValue(false));
144+
->willReturn(false);
143145
$this->tester->execute([]);
144146
$expected = 'Enabling maintenance mode' . PHP_EOL
145147
. 'Not enough information provided to take backup.' . PHP_EOL

setup/src/Magento/Setup/Test/Unit/Console/Command/ConfigSetCommandTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Setup\Test\Unit\Console\Command;
89

@@ -34,18 +35,18 @@ class ConfigSetCommandTest extends TestCase
3435
*/
3536
private $command;
3637

37-
public function setUp(): void
38+
protected function setUp(): void
3839
{
3940
$option = $this->createMock(TextConfigOption::class);
4041
$option
4142
->expects($this->any())
4243
->method('getName')
43-
->will($this->returnValue('db-host'));
44+
->willReturn('db-host');
4445
$this->configModel = $this->createMock(ConfigModel::class);
4546
$this->configModel
4647
->expects($this->exactly(2))
4748
->method('getAvailableOptions')
48-
->will($this->returnValue([$option]));
49+
->willReturn([$option]);
4950
$moduleList = $this->createMock(ModuleList::class);
5051
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);
5152
$this->command = new ConfigSetCommand($this->configModel, $moduleList, $this->deploymentConfig);
@@ -56,7 +57,7 @@ public function testExecuteNoInteractive()
5657
$this->deploymentConfig
5758
->expects($this->once())
5859
->method('get')
59-
->will($this->returnValue(null));
60+
->willReturn(null);
6061
$this->configModel
6162
->expects($this->once())
6263
->method('process')
@@ -74,7 +75,7 @@ public function testExecuteInteractiveWithYes()
7475
$this->deploymentConfig
7576
->expects($this->once())
7677
->method('get')
77-
->will($this->returnValue('localhost'));
78+
->willReturn('localhost');
7879
$this->configModel
7980
->expects($this->once())
8081
->method('process')
@@ -87,7 +88,7 @@ public function testExecuteInteractiveWithNo()
8788
$this->deploymentConfig
8889
->expects($this->once())
8990
->method('get')
90-
->will($this->returnValue('localhost'));
91+
->willReturn('localhost');
9192
$this->configModel
9293
->expects($this->once())
9394
->method('process')
@@ -107,15 +108,15 @@ private function checkInteraction($interactionType)
107108
$dialog
108109
->expects($this->once())
109110
->method('ask')
110-
->will($this->returnValue($interactionType));
111+
->willReturn($interactionType);
111112

112113
/** @var HelperSet|MockObject $helperSet */
113114
$helperSet = $this->createMock(HelperSet::class);
114115
$helperSet
115116
->expects($this->once())
116117
->method('get')
117118
->with('question')
118-
->will($this->returnValue($dialog));
119+
->willReturn($dialog);
119120
$this->command->setHelperSet($helperSet);
120121

121122
$commandTester = new CommandTester($this->command);

setup/src/Magento/Setup/Test/Unit/Console/Command/CronRunCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Framework\App\DeploymentConfig;
@@ -47,7 +49,7 @@ class CronRunCommandTest extends TestCase
4749
*/
4850
private $status;
4951

50-
public function setUp(): void
52+
protected function setUp(): void
5153
{
5254
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);
5355
$this->queue = $this->createMock(Queue::class);

setup/src/Magento/Setup/Test/Unit/Console/Command/DbDataUpgradeCommandTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Setup\Test\Unit\Console\Command;
89

@@ -34,9 +35,9 @@ protected function setup(): void
3435

3536
public function testExecute()
3637
{
37-
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
38+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
3839
$installer = $this->createMock(Installer::class);
39-
$this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer));
40+
$this->installerFactory->expects($this->once())->method('create')->willReturn($installer);
4041
$installer->expects($this->once())->method('installDataFixtures');
4142

4243
$commandTester = new CommandTester(
@@ -47,7 +48,7 @@ public function testExecute()
4748

4849
public function testExecuteNoConfig()
4950
{
50-
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
51+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
5152
$this->installerFactory->expects($this->never())->method('create');
5253

5354
$commandTester = new CommandTester(

setup/src/Magento/Setup/Test/Unit/Console/Command/DbSchemaUpgradeCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ protected function setUp(): void
4040
*/
4141
public function testExecute($options, $expectedOptions)
4242
{
43-
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
43+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
4444
$installer = $this->createMock(Installer::class);
45-
$this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer));
45+
$this->installerFactory->expects($this->once())->method('create')->willReturn($installer);
4646
$installer
4747
->expects($this->once())
4848
->method('installSchema')
@@ -75,7 +75,7 @@ public function executeDataProvider()
7575

7676
public function testExecuteNoConfig()
7777
{
78-
$this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
78+
$this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
7979
$this->installerFactory->expects($this->never())->method('create');
8080

8181
$commandTester = new CommandTester(

setup/src/Magento/Setup/Test/Unit/Console/Command/DbStatusCommandTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Framework\App\DeploymentConfig;
@@ -59,15 +61,19 @@ protected function setUp(): void
5961
->disableOriginalConstructor()
6062
->getMock();
6163
$this->validators = [
62-
'declarative_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
63-
'up_to_date_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
64-
'up_to_date_data' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
65-
'old_validator' => $this->getMockBuilder(UpToDateValidatorInterface::class)->getMock(),
64+
'declarative_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)
65+
->getMock(),
66+
'up_to_date_schema' => $this->getMockBuilder(UpToDateValidatorInterface::class)
67+
->getMock(),
68+
'up_to_date_data' => $this->getMockBuilder(UpToDateValidatorInterface::class)
69+
->getMock(),
70+
'old_validator' => $this->getMockBuilder(UpToDateValidatorInterface::class)
71+
->getMock(),
6672
];
6773

6874
$objectManagerProvider->expects($this->any())
6975
->method('get')
70-
->will($this->returnValue($objectManager));
76+
->willReturn($objectManager);
7177
$objectManager->expects(self::exactly(4))
7278
->method('get')
7379
->willReturnOnConsecutiveCalls(
@@ -95,7 +101,7 @@ public function testExecute()
95101
->willReturn(true);
96102
$this->deploymentConfig->expects($this->once())
97103
->method('isAvailable')
98-
->will($this->returnValue(true));
104+
->willReturn(true);
99105
$tester = new CommandTester($this->command);
100106
$tester->execute([]);
101107
$this->assertStringMatchesFormat('All modules are up to date.', $tester->getDisplay());
@@ -106,7 +112,7 @@ public function testExecuteNotInstalled()
106112
{
107113
$this->deploymentConfig->expects($this->once())
108114
->method('isAvailable')
109-
->will($this->returnValue(false));
115+
->willReturn(false);
110116
$tester = new CommandTester($this->command);
111117
$tester->execute([]);
112118

setup/src/Magento/Setup/Test/Unit/Console/Command/DeployStaticContentCommandTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Deploy\Console\ConsoleLogger;

setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Setup\Test\Unit\Console\Command;
79

810
use Magento\Framework\App\Cache;
@@ -63,7 +65,7 @@ class DiCompileCommandTest extends TestCase
6365
/** @var OutputFormatterInterface|MockObject */
6466
private $outputFormatterMock;
6567

66-
public function setUp(): void
68+
protected function setUp(): void
6769
{
6870
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
6971
$objectManagerProviderMock = $this->createMock(ObjectManagerProvider::class);

setup/src/Magento/Setup/Test/Unit/Console/Command/FunctionExistMock.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Deploy\Console\Command;
89

0 commit comments

Comments
 (0)