66namespace Magento \Setup \Test \Unit \Console \Command ;
77
88use Magento \Framework \App \DeploymentConfig ;
9+ use Magento \Framework \App \State as AppState ;
910use Magento \Framework \Console \Cli ;
1011use Magento \Setup \Console \Command \UpgradeCommand ;
1112use Magento \Setup \Model \Installer ;
@@ -29,11 +30,15 @@ class UpgradeCommandTest extends \PHPUnit\Framework\TestCase
2930 */
3031 private $ installerMock ;
3132
33+ /**
34+ * @var AppState|\PHPUnit_Framework_MockObject_MockObject
35+ */
36+ private $ appStateMock ;
37+
3238 /**
3339 * @var UpgradeCommand
3440 */
3541 private $ upgradeCommand ;
36-
3742 /**
3843 * @var CommandTester
3944 */
@@ -56,16 +61,24 @@ protected function setUp()
5661 $ this ->installerFactoryMock ->expects ($ this ->once ())
5762 ->method ('create ' )
5863 ->willReturn ($ this ->installerMock );
64+ $ this ->appStateMock = $ this ->getMockBuilder (AppState::class)
65+ ->disableOriginalConstructor ()
66+ ->getMock ();
5967
60- $ this ->upgradeCommand = new UpgradeCommand ($ this ->installerFactoryMock , $ this ->deploymentConfigMock );
68+ $ this ->upgradeCommand = new UpgradeCommand (
69+ $ this ->installerFactoryMock ,
70+ $ this ->deploymentConfigMock ,
71+ $ this ->appStateMock
72+ );
6173 $ this ->commandTester = new CommandTester ($ this ->upgradeCommand );
6274 }
6375
6476 /**
6577 * @dataProvider executeDataProvider
6678 */
67- public function testExecute ($ options , $ expectedString = '' )
79+ public function testExecute ($ options , $ deployMode , $ expectedString = '' )
6880 {
81+ $ this ->appStateMock ->method ('getMode ' )->willReturn ($ deployMode );
6982 $ this ->installerMock ->expects ($ this ->at (0 ))
7083 ->method ('updateModulesSequence ' );
7184 $ this ->installerMock ->expects ($ this ->at (1 ))
@@ -85,11 +98,23 @@ public function executeDataProvider()
8598 return [
8699 [
87100 'options ' => [],
101+ 'deployMode ' => \Magento \Framework \App \State::MODE_PRODUCTION ,
88102 'expectedString ' => 'Please re-run Magento compile command. Use the command "setup:di:compile" '
89103 . PHP_EOL
90104 ],
91105 [
92106 'options ' => ['--keep-generated ' => true ],
107+ 'deployMode ' => \Magento \Framework \App \State::MODE_PRODUCTION ,
108+ 'expectedString ' => ''
109+ ],
110+ [
111+ 'options ' => [],
112+ 'deployMode ' => \Magento \Framework \App \State::MODE_DEVELOPER ,
113+ 'expectedString ' => ''
114+ ],
115+ [
116+ 'options ' => [],
117+ 'deployMode ' => \Magento \Framework \App \State::MODE_DEFAULT ,
93118 'expectedString ' => ''
94119 ],
95120 ];
0 commit comments