11 use Symfony\Component\Console\Application;
12 use Symfony\Component\Console\Helper\HelperSet;
13 use Symfony\Component\Console\Input\InputDefinition;
14 use Symfony\Component\Console\Tester\CommandTester;
39 private $installerFactory;
49 private $applicationMock;
54 private $helperSetMock;
59 private $definitionMock;
64 private $configImportMock;
69 private $adminUserMock;
74 '--' . SetupConfigOptionsList::INPUT_KEY_DB_HOST =>
'localhost',
75 '--' . SetupConfigOptionsList::INPUT_KEY_DB_NAME =>
'magento',
76 '--' . SetupConfigOptionsList::INPUT_KEY_DB_USER =>
'root',
77 '--' . BackendConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME =>
'admin',
84 $configModel = $this->createMock(\
Magento\Setup\Model\ConfigModel::class);
86 ->expects($this->exactly(2))
87 ->method(
'getAvailableOptions')
88 ->will($this->returnValue($this->getOptionsListDeployConfig()));
90 ->expects($this->once())
92 ->will($this->returnValue([]));
94 $userConfig = $this->createMock(\
Magento\Setup\Console\Command\InstallStoreConfigurationCommand::class);
96 ->expects($this->once())
97 ->method(
'getOptionsList')
98 ->will($this->returnValue($this->getOptionsListUserConfig()));
100 ->expects($this->once())
102 ->will($this->returnValue([]));
104 $this->adminUserMock = $this->createMock(AdminUserCreateCommand::class);
106 ->expects($this->once())
107 ->method(
'getOptionsList')
108 ->will($this->returnValue($this->getOptionsListAdminUser()));
110 $this->installerFactory = $this->createMock(\
Magento\Setup\Model\InstallerFactory::class);
111 $this->installer = $this->createMock(\
Magento\Setup\Model\Installer::class);
112 $this->applicationMock = $this->getMockBuilder(Application::class)
113 ->disableOriginalConstructor()
115 $this->helperSetMock = $this->getMockBuilder(HelperSet::class)
116 ->disableOriginalConstructor()
118 $this->definitionMock = $this->getMockBuilder(InputDefinition::class)
119 ->disableOriginalConstructor()
121 $this->configImportMock = $this->getMockBuilder(ConfigImportCommand::class)
122 ->disableOriginalConstructor()
125 $this->applicationMock->expects($this->any())
126 ->method(
'getHelperSet')
127 ->willReturn($this->helperSetMock);
128 $this->applicationMock->expects($this->any())
129 ->method(
'getDefinition')
130 ->willReturn($this->definitionMock);
131 $this->definitionMock->expects($this->any())
132 ->method(
'getOptions')
134 $this->applicationMock->expects($this->any())
137 ->willReturn($this->configImportMock);
140 $this->installerFactory,
145 $this->command->setApplication(
146 $this->applicationMock
159 ->expects($this->once())
162 $this->installerFactory->expects($this->once())
164 ->will($this->returnValue($this->installer));
165 $this->installer->expects($this->once())->method(
'install');
166 $this->configImportMock->expects($this->once())
169 $commandTester =
new CommandTester($this->command);
170 $commandTester->execute($this->input);
178 private function getOptionsListDeployConfig()
180 $option1 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
182 ->expects($this->any())
184 ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_HOST));
185 $option2 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
187 ->expects($this->any())
189 ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_NAME));
190 $option3 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
192 ->expects($this->any())
194 ->will($this->returnValue(SetupConfigOptionsList::INPUT_KEY_DB_USER));
195 $option4 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
197 ->expects($this->any())
199 ->will($this->returnValue(BackendConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME));
201 return [$option1, $option2, $option3, $option4];
209 private function getOptionsListUserConfig()
211 $option1 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
213 ->expects($this->any())
216 $option2 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
218 ->expects($this->any())
221 $option3 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
223 ->expects($this->any())
226 $option4 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
228 ->expects($this->any())
232 return [$option1, $option2, $option3, $option4];
240 private function getOptionsListAdminUser()
242 $option1 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
244 ->expects($this->any())
247 $option2 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
249 ->expects($this->any())
252 $option3 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
254 ->expects($this->any())
257 $option4 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
259 ->expects($this->any())
262 $option5 = $this->createMock(\
Magento\Framework\Setup\Option\TextConfigOption::class);
264 ->expects($this->any())
268 return [$option1, $option2, $option3, $option4, $option5];
280 ->expects($this->never())
281 ->method(
'validate');
282 $this->installerFactory->expects($this->once())
284 ->will($this->returnValue($this->installer));
285 $this->installer->expects($this->once())->method(
'install');
288 $commandTester =
new CommandTester($this->command);
289 $commandTester->execute($this->input);
302 ->expects($this->never())
303 ->method(
'validate');
304 $this->installerFactory->expects($this->never())
306 ->will($this->returnValue($this->installer));
307 $this->installer->expects($this->never())->method(
'install');
310 $commandTester =
new CommandTester($this->command);
311 $commandTester->execute($this->input);
320 'without option' => [
'',
''],
321 'normal case' => [
'abcde',
''],
322 '20 chars' => [
'12345678901234567890',
''],
332 [
'123456789012345678901',
'InvalidArgumentException'],
333 [
'abcdefghijk12345678fdgsdfgsdfgsdfsgsdfg90abcdefgdfddgsdfg',
'InvalidArgumentException'],
testValidateWithException($prefixValue)
validateWithExceptionDataProvider()
const INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX
testValidate($prefixValue)