6
6
namespace Magento \Setup \Test \Unit \Console \Command ;
7
7
8
8
use Magento \Framework \App \DeploymentConfig ;
9
+ use Magento \Framework \App \State as AppState ;
9
10
use Magento \Framework \Console \Cli ;
10
11
use Magento \Setup \Console \Command \UpgradeCommand ;
11
12
use Magento \Setup \Model \Installer ;
@@ -29,11 +30,15 @@ class UpgradeCommandTest extends \PHPUnit\Framework\TestCase
29
30
*/
30
31
private $ installerMock ;
31
32
33
+ /**
34
+ * @var AppState|\PHPUnit_Framework_MockObject_MockObject
35
+ */
36
+ private $ appStateMock ;
37
+
32
38
/**
33
39
* @var UpgradeCommand
34
40
*/
35
41
private $ upgradeCommand ;
36
-
37
42
/**
38
43
* @var CommandTester
39
44
*/
@@ -56,16 +61,24 @@ protected function setUp()
56
61
$ this ->installerFactoryMock ->expects ($ this ->once ())
57
62
->method ('create ' )
58
63
->willReturn ($ this ->installerMock );
64
+ $ this ->appStateMock = $ this ->getMockBuilder (AppState::class)
65
+ ->disableOriginalConstructor ()
66
+ ->getMock ();
59
67
60
- $ this ->upgradeCommand = new UpgradeCommand ($ this ->installerFactoryMock , $ this ->deploymentConfigMock );
68
+ $ this ->upgradeCommand = new UpgradeCommand (
69
+ $ this ->installerFactoryMock ,
70
+ $ this ->deploymentConfigMock ,
71
+ $ this ->appStateMock
72
+ );
61
73
$ this ->commandTester = new CommandTester ($ this ->upgradeCommand );
62
74
}
63
75
64
76
/**
65
77
* @dataProvider executeDataProvider
66
78
*/
67
- public function testExecute ($ options , $ expectedString = '' )
79
+ public function testExecute ($ options , $ deployMode , $ expectedString = '' )
68
80
{
81
+ $ this ->appStateMock ->method ('getMode ' )->willReturn ($ deployMode );
69
82
$ this ->installerMock ->expects ($ this ->at (0 ))
70
83
->method ('updateModulesSequence ' );
71
84
$ this ->installerMock ->expects ($ this ->at (1 ))
@@ -85,11 +98,23 @@ public function executeDataProvider()
85
98
return [
86
99
[
87
100
'options ' => [],
101
+ 'deployMode ' => \Magento \Framework \App \State::MODE_PRODUCTION ,
88
102
'expectedString ' => 'Please re-run Magento compile command. Use the command "setup:di:compile" '
89
103
. PHP_EOL
90
104
],
91
105
[
92
106
'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 ,
93
118
'expectedString ' => ''
94
119
],
95
120
];
0 commit comments