@@ -114,14 +114,18 @@ protected function setUp()
114
114
public function testDeploy ($ options , $ expectedContentVersion )
115
115
{
116
116
$ package = $ this ->getMock (Package::class, [], [], '' , false );
117
- $ package ->expects ($ this ->exactly (1 ))->method ('isVirtual ' )->willReturn (false );
118
- $ package ->expects ($ this ->exactly (3 ))->method ('getArea ' )->willReturn ('area ' );
119
- $ package ->expects ($ this ->exactly (3 ))->method ('getTheme ' )->willReturn ('theme ' );
120
- $ package ->expects ($ this ->exactly (2 ))->method ('getLocale ' )->willReturn ('locale ' );
121
-
122
- $ packages = [
123
- 'package ' => $ package
124
- ];
117
+ if ($ options ['refresh-content-version-only ' ]) {
118
+ $ package ->expects ($ this ->never ())->method ('isVirtual ' );
119
+ $ package ->expects ($ this ->never ())->method ('getArea ' );
120
+ $ package ->expects ($ this ->never ())->method ('getTheme ' );
121
+ $ package ->expects ($ this ->never ())->method ('getLocale ' );
122
+ } else {
123
+ $ package ->expects ($ this ->exactly (1 ))->method ('isVirtual ' )->willReturn (false );
124
+ $ package ->expects ($ this ->exactly (3 ))->method ('getArea ' )->willReturn ('area ' );
125
+ $ package ->expects ($ this ->exactly (3 ))->method ('getTheme ' )->willReturn ('theme ' );
126
+ $ package ->expects ($ this ->exactly (2 ))->method ('getLocale ' )->willReturn ('locale ' );
127
+ }
128
+ $ packages = ['package ' => $ package ];
125
129
126
130
if ($ expectedContentVersion ) {
127
131
$ this ->versionStorage ->expects ($ this ->once ())->method ('save ' )->with ($ expectedContentVersion );
@@ -132,20 +136,27 @@ public function testDeploy($options, $expectedContentVersion)
132
136
$ queue = $ this ->getMockBuilder (Queue::class)
133
137
->disableOriginalConstructor ()
134
138
->getMockForAbstractClass ();
135
- $ this ->queueFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ queue );
139
+ if ($ options ['refresh-content-version-only ' ]) {
140
+ $ this ->queueFactory ->expects ($ this ->never ())->method ('create ' );
141
+ } else {
142
+ $ this ->queueFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ queue );
143
+ }
136
144
137
145
$ strategy = $ this ->getMockBuilder (CompactDeploy::class)
138
146
->setMethods (['deploy ' ])
139
147
->disableOriginalConstructor ()
140
148
->getMockForAbstractClass ();
141
- $ strategy ->expects ($ this ->once ())->method ('deploy ' )
142
- ->with ($ options )
143
- ->willReturn ($ packages );
144
- $ this ->deployStrategyFactory ->expects ($ this ->once ())
145
- ->method ('create ' )
146
- ->with ('compact ' , ['queue ' => $ queue ])
147
- ->willReturn ($ strategy );
148
-
149
+ if ($ options ['refresh-content-version-only ' ]) {
150
+ $ strategy ->expects ($ this ->never ())->method ('deploy ' );
151
+ } else {
152
+ $ strategy ->expects ($ this ->once ())->method ('deploy ' )
153
+ ->with ($ options )
154
+ ->willReturn ($ packages );
155
+ $ this ->deployStrategyFactory ->expects ($ this ->once ())
156
+ ->method ('create ' )
157
+ ->with ('compact ' , ['queue ' => $ queue ])
158
+ ->willReturn ($ strategy );
159
+ }
149
160
$ deployPackageService = $ this ->getMockBuilder (DeployPackage::class)
150
161
->disableOriginalConstructor ()
151
162
->getMockForAbstractClass ();
@@ -166,34 +177,32 @@ public function testDeploy($options, $expectedContentVersion)
166
177
->disableOriginalConstructor ()
167
178
->getMockForAbstractClass ();
168
179
169
- $ this ->objectManager ->expects ($ this ->exactly (4 ))
170
- ->method ('create ' )
171
- ->withConsecutive (
172
- [DeployPackage::class, ['logger ' => $ this ->logger ]],
173
- [DeployRequireJsConfig::class, ['logger ' => $ this ->logger ]],
174
- [DeployTranslationsDictionary::class, ['logger ' => $ this ->logger ]],
175
- [Bundle::class, ['logger ' => $ this ->logger ]]
176
- )
177
- ->willReturnOnConsecutiveCalls (
178
- $ deployPackageService ,
179
- $ deployRjsConfig ,
180
- $ deployI18n ,
181
- $ deployBundle
182
- );
183
-
184
- $ this ->objectManager ->expects ($ this ->exactly (1 ))
185
- ->method ('get ' )
186
- ->withConsecutive (
187
- [MinifyTemplates::class]
188
- )
189
- ->willReturnOnConsecutiveCalls (
190
- $ minifyTemplates
191
- );
192
-
193
- $ this ->assertEquals (
194
- null ,
195
- $ this ->service ->deploy ($ options )
196
- );
180
+ if ($ options ['refresh-content-version-only ' ]) {
181
+ $ this ->objectManager ->expects ($ this ->never ())->method ('create ' );
182
+ $ this ->objectManager ->expects ($ this ->never ())->method ('get ' );
183
+ } else {
184
+ $ this ->objectManager ->expects ($ this ->exactly (4 ))
185
+ ->method ('create ' )
186
+ ->withConsecutive (
187
+ [DeployPackage::class, ['logger ' => $ this ->logger ]],
188
+ [DeployRequireJsConfig::class, ['logger ' => $ this ->logger ]],
189
+ [DeployTranslationsDictionary::class, ['logger ' => $ this ->logger ]],
190
+ [Bundle::class, ['logger ' => $ this ->logger ]]
191
+ )
192
+ ->willReturnOnConsecutiveCalls (
193
+ $ deployPackageService ,
194
+ $ deployRjsConfig ,
195
+ $ deployI18n ,
196
+ $ deployBundle
197
+ );
198
+
199
+ $ this ->objectManager ->expects ($ this ->exactly (1 ))
200
+ ->method ('get ' )
201
+ ->withConsecutive ([MinifyTemplates::class])
202
+ ->willReturnOnConsecutiveCalls ($ minifyTemplates );
203
+ }
204
+
205
+ $ this ->assertEquals (null , $ this ->service ->deploy ($ options ));
197
206
}
198
207
199
208
public function deployDataProvider ()
@@ -203,7 +212,8 @@ public function deployDataProvider()
203
212
[
204
213
'strategy ' => 'compact ' ,
205
214
'no-javascript ' => false ,
206
- 'no-html-minify ' => false
215
+ 'no-html-minify ' => false ,
216
+ 'refresh-content-version-only ' => false ,
207
217
],
208
218
null // content version value should not be asserted in this case
209
219
],
@@ -212,9 +222,17 @@ public function deployDataProvider()
212
222
'strategy ' => 'compact ' ,
213
223
'no-javascript ' => false ,
214
224
'no-html-minify ' => false ,
225
+ 'refresh-content-version-only ' => false ,
215
226
'content-version ' => '123456 ' ,
216
227
],
217
228
'123456 '
229
+ ],
230
+ [
231
+ [
232
+ 'refresh-content-version-only ' => true ,
233
+ 'content-version ' => '654321 ' ,
234
+ ],
235
+ '654321 '
218
236
]
219
237
];
220
238
}
0 commit comments