Skip to content

Commit 52e5233

Browse files
committed
Install command unit tests updated
1 parent 5e70487 commit 52e5233

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Setup\ConfigOptionsList as BackendConfigOptionsList;
1111
use Magento\Deploy\Console\Command\App\ConfigImportCommand;
1212
use Magento\Framework\Config\ConfigOptionsListConstants as SetupConfigOptionsList;
13+
use Magento\Framework\Console\Cli;
1314
use Magento\Framework\Setup\Option\TextConfigOption;
1415
use Magento\Setup\Console\Command\AdminUserCreateCommand;
1516
use Magento\Setup\Console\Command\InstallCommand;
@@ -24,6 +25,7 @@
2425
use Magento\Setup\Model\SearchConfigOptionsList;
2526
use Symfony\Component\Console\Application;
2627
use Symfony\Component\Console\Helper\HelperSet;
28+
use Symfony\Component\Console\Helper\QuestionHelper;
2729
use Symfony\Component\Console\Input\InputDefinition;
2830
use Symfony\Component\Console\Tester\CommandTester;
2931

@@ -77,6 +79,11 @@ class InstallCommandTest extends TestCase
7779
*/
7880
private $adminUserMock;
7981

82+
/**
83+
* @var QuestionHelper
84+
*/
85+
private $questionHelperMock;
86+
8087
protected function setUp(): void
8188
{
8289
$this->input = [
@@ -102,7 +109,7 @@ protected function setUp(): void
102109

103110
$userConfig = $this->createMock(InstallStoreConfigurationCommand::class);
104111
$userConfig
105-
->expects($this->once())
112+
->expects($this->atLeastOnce())
106113
->method('getOptionsList')
107114
->willReturn($this->getOptionsListUserConfig());
108115
$userConfig
@@ -112,7 +119,7 @@ protected function setUp(): void
112119

113120
$this->adminUserMock = $this->createMock(AdminUserCreateCommand::class);
114121
$this->adminUserMock
115-
->expects($this->once())
122+
->expects($this->atLeastOnce())
116123
->method('getOptionsList')
117124
->willReturn($this->getOptionsListAdminUser());
118125

@@ -146,6 +153,10 @@ protected function setUp(): void
146153
->with(ConfigImportCommand::COMMAND_NAME)
147154
->willReturn($this->configImportMock);
148155

156+
$this->questionHelperMock = $this->getMockBuilder(QuestionHelper::class)
157+
->disableOriginalConstructor()
158+
->getMock();
159+
149160
$this->command = new InstallCommand(
150161
$this->installerFactory,
151162
$configModel,
@@ -181,6 +192,27 @@ public function testExecute()
181192
$commandTester->execute($this->input);
182193
}
183194

195+
public function testInteractiveExecute(): void
196+
{
197+
$this->installerFactory
198+
->expects($this->once())
199+
->method('create')
200+
->willReturn($this->installer);
201+
$this->installer
202+
->expects($this->once())
203+
->method('install');
204+
$this->questionHelperMock->method('ask');
205+
$this->helperSetMock
206+
->method('get')
207+
->with('question')
208+
->willReturn($this->questionHelperMock);
209+
$this->command->setHelperSet($this->helperSetMock);
210+
211+
$commandTester = new CommandTester($this->command);
212+
$commandTester->execute(['--' . InstallCommand::INPUT_KEY_INTERACTIVE_SETUP => true]);
213+
$this->assertEquals(Cli::RETURN_SUCCESS, $commandTester->getStatusCode());
214+
}
215+
184216
/**
185217
* Get list of options for deployment configuration
186218
*

0 commit comments

Comments
 (0)