9
9
use Symfony \Component \Console \Tester \CommandTester ;
10
10
use Magento \Framework \Validator \Locale ;
11
11
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
12
- use Magento \Framework \App \State ;
13
12
14
13
require 'FunctionExistMock.php ' ;
15
14
@@ -45,11 +44,6 @@ class DeployStaticContentCommandTest extends \PHPUnit_Framework_TestCase
45
44
*/
46
45
private $ validator ;
47
46
48
- /**
49
- * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
50
- */
51
- private $ appState ;
52
-
53
47
protected function setUp ()
54
48
{
55
49
$ this ->objectManager = $ this ->getMockForAbstractClass (\Magento \Framework \ObjectManagerInterface::class);
@@ -62,20 +56,17 @@ protected function setUp()
62
56
);
63
57
$ this ->deployer = $ this ->getMock (\Magento \Deploy \Model \Deployer::class, [], [], '' , false );
64
58
$ this ->filesUtil = $ this ->getMock (\Magento \Framework \App \Utility \Files::class, [], [], '' , false );
65
- $ this ->appState = $ this ->getMock (\Magento \Framework \App \State::class, [], [], '' , false );
66
59
67
60
$ this ->validator = $ this ->getMock (\Magento \Framework \Validator \Locale::class, [], [], '' , false );
68
61
$ this ->command = (new ObjectManager ($ this ))->getObject (DeployStaticContentCommand::class, [
69
62
'objectManagerFactory ' => $ this ->objectManagerFactory ,
70
63
'validator ' => $ this ->validator ,
71
64
'objectManager ' => $ this ->objectManager ,
72
- 'appState ' => $ this ->appState ,
73
65
]);
74
66
}
75
67
76
68
public function testExecute ()
77
69
{
78
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
79
70
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
80
71
$ this ->deployer ->expects ($ this ->once ())->method ('deploy ' );
81
72
$ this ->objectManager ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ this ->filesUtil );
@@ -87,7 +78,6 @@ public function testExecute()
87
78
88
79
public function testExecuteValidateLanguages ()
89
80
{
90
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
91
81
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
92
82
$ this ->deployer ->expects ($ this ->once ())->method ('deploy ' );
93
83
$ this ->objectManager ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ this ->filesUtil );
@@ -107,7 +97,6 @@ public function testExecuteValidateLanguages()
107
97
*/
108
98
public function testExecuteIncludedExcludedLanguages ()
109
99
{
110
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
111
100
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
112
101
$ this ->objectManager ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ this ->filesUtil );
113
102
$ this ->validator ->expects (self ::exactly (2 ))->method ('isValid ' )->willReturnMap ([
@@ -125,7 +114,6 @@ public function testExecuteIncludedExcludedLanguages()
125
114
*/
126
115
public function testExecuteIncludedExcludedAreas ()
127
116
{
128
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
129
117
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
130
118
$ this ->objectManager ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ this ->filesUtil );
131
119
@@ -139,7 +127,6 @@ public function testExecuteIncludedExcludedAreas()
139
127
*/
140
128
public function testExecuteIncludedExcludedThemes ()
141
129
{
142
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
143
130
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
144
131
$ this ->objectManager ->expects ($ this ->at (0 ))->method ('create ' )->willReturn ($ this ->filesUtil );
145
132
@@ -153,7 +140,6 @@ public function testExecuteIncludedExcludedThemes()
153
140
*/
154
141
public function testExecuteInvalidLanguageArgument ()
155
142
{
156
- $ this ->appState ->expects ($ this ->once ())->method ('getMode ' )->willReturn (State::MODE_PRODUCTION );
157
143
$ this ->filesUtil ->expects (self ::any ())->method ('getStaticPreProcessingFiles ' )->willReturn ([]);
158
144
$ this ->objectManager ->expects ($ this ->at (0 ))
159
145
->method ('create ' )
@@ -162,30 +148,4 @@ public function testExecuteInvalidLanguageArgument()
162
148
$ commandTester = new CommandTester ($ this ->command );
163
149
$ commandTester ->execute ($ wrongParam );
164
150
}
165
-
166
- /**
167
- * @param string $mode
168
- * @return void
169
- * @expectedException \Magento\Framework\Exception\LocalizedException
170
- * @dataProvider executionInNonProductionModeDataProvider
171
- */
172
- public function testExecuteInNonProductionMode ($ mode )
173
- {
174
- $ this ->appState ->expects ($ this ->any ())->method ('getMode ' )->willReturn ($ mode );
175
- $ this ->objectManager ->expects ($ this ->never ())->method ('create ' );
176
-
177
- $ tester = new CommandTester ($ this ->command );
178
- $ tester ->execute ([]);
179
- }
180
-
181
- /**
182
- * @return array
183
- */
184
- public function executionInNonProductionModeDataProvider ()
185
- {
186
- return [
187
- [State::MODE_DEFAULT ],
188
- [State::MODE_DEVELOPER ],
189
- ];
190
- }
191
151
}
0 commit comments