10
10
use Magento \Backend \Setup \ConfigOptionsList as BackendConfigOptionsList ;
11
11
use Magento \Deploy \Console \Command \App \ConfigImportCommand ;
12
12
use Magento \Framework \Config \ConfigOptionsListConstants as SetupConfigOptionsList ;
13
+ use Magento \Framework \Console \Cli ;
13
14
use Magento \Framework \Setup \Option \TextConfigOption ;
14
15
use Magento \Setup \Console \Command \AdminUserCreateCommand ;
15
16
use Magento \Setup \Console \Command \InstallCommand ;
24
25
use Magento \Setup \Model \SearchConfigOptionsList ;
25
26
use Symfony \Component \Console \Application ;
26
27
use Symfony \Component \Console \Helper \HelperSet ;
28
+ use Symfony \Component \Console \Helper \QuestionHelper ;
27
29
use Symfony \Component \Console \Input \InputDefinition ;
28
30
use Symfony \Component \Console \Tester \CommandTester ;
29
31
@@ -77,6 +79,11 @@ class InstallCommandTest extends TestCase
77
79
*/
78
80
private $ adminUserMock ;
79
81
82
+ /**
83
+ * @var QuestionHelper
84
+ */
85
+ private $ questionHelperMock ;
86
+
80
87
protected function setUp (): void
81
88
{
82
89
$ this ->input = [
@@ -102,7 +109,7 @@ protected function setUp(): void
102
109
103
110
$ userConfig = $ this ->createMock (InstallStoreConfigurationCommand::class);
104
111
$ userConfig
105
- ->expects ($ this ->once ())
112
+ ->expects ($ this ->atLeastOnce ())
106
113
->method ('getOptionsList ' )
107
114
->willReturn ($ this ->getOptionsListUserConfig ());
108
115
$ userConfig
@@ -112,7 +119,7 @@ protected function setUp(): void
112
119
113
120
$ this ->adminUserMock = $ this ->createMock (AdminUserCreateCommand::class);
114
121
$ this ->adminUserMock
115
- ->expects ($ this ->once ())
122
+ ->expects ($ this ->atLeastOnce ())
116
123
->method ('getOptionsList ' )
117
124
->willReturn ($ this ->getOptionsListAdminUser ());
118
125
@@ -146,6 +153,10 @@ protected function setUp(): void
146
153
->with (ConfigImportCommand::COMMAND_NAME )
147
154
->willReturn ($ this ->configImportMock );
148
155
156
+ $ this ->questionHelperMock = $ this ->getMockBuilder (QuestionHelper::class)
157
+ ->disableOriginalConstructor ()
158
+ ->getMock ();
159
+
149
160
$ this ->command = new InstallCommand (
150
161
$ this ->installerFactory ,
151
162
$ configModel ,
@@ -181,6 +192,27 @@ public function testExecute()
181
192
$ commandTester ->execute ($ this ->input );
182
193
}
183
194
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
+
184
216
/**
185
217
* Get list of options for deployment configuration
186
218
*
0 commit comments