@@ -114,11 +114,17 @@ 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
-
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
+ }
122
128
$ packages = [
123
129
'package ' => $ package
124
130
];
@@ -132,20 +138,28 @@ public function testDeploy($options, $expectedContentVersion)
132
138
$ queue = $ this ->getMockBuilder (Queue::class)
133
139
->disableOriginalConstructor ()
134
140
->getMockForAbstractClass ();
135
- $ this ->queueFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ queue );
141
+ if ($ options ['refresh-content-version-only ' ]) {
142
+ $ this ->queueFactory ->expects ($ this ->never ())->method ('create ' );
143
+ } else {
144
+ $ this ->queueFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ queue );
145
+ }
136
146
137
147
$ strategy = $ this ->getMockBuilder (CompactDeploy::class)
138
148
->setMethods (['deploy ' ])
139
149
->disableOriginalConstructor ()
140
150
->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
-
151
+ if ($ options ['refresh-content-version-only ' ]) {
152
+ $ strategy ->expects ($ this ->never ())->method ('deploy ' );
153
+ $ this ->deployStrategyFactory ->expects ($ this ->never ())->method ('create ' );
154
+ } else {
155
+ $ strategy ->expects ($ this ->once ())->method ('deploy ' )
156
+ ->with ($ options )
157
+ ->willReturn ($ packages );
158
+ $ this ->deployStrategyFactory ->expects ($ this ->once ())
159
+ ->method ('create ' )
160
+ ->with ('compact ' , ['queue ' => $ queue ])
161
+ ->willReturn ($ strategy );
162
+ }
149
163
$ deployPackageService = $ this ->getMockBuilder (DeployPackage::class)
150
164
->disableOriginalConstructor ()
151
165
->getMockForAbstractClass ();
@@ -166,29 +180,34 @@ public function testDeploy($options, $expectedContentVersion)
166
180
->disableOriginalConstructor ()
167
181
->getMockForAbstractClass ();
168
182
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
- );
183
+ if ($ options ['refresh-content-version-only ' ]) {
184
+ $ this ->objectManager ->expects ($ this ->never ())->method ('create ' );
185
+ $ this ->objectManager ->expects ($ this ->never ())->method ('get ' );
186
+ } else {
187
+ $ this ->objectManager ->expects ($ this ->exactly (4 ))
188
+ ->method ('create ' )
189
+ ->withConsecutive (
190
+ [DeployPackage::class, ['logger ' => $ this ->logger ]],
191
+ [DeployRequireJsConfig::class, ['logger ' => $ this ->logger ]],
192
+ [DeployTranslationsDictionary::class, ['logger ' => $ this ->logger ]],
193
+ [Bundle::class, ['logger ' => $ this ->logger ]]
194
+ )
195
+ ->willReturnOnConsecutiveCalls (
196
+ $ deployPackageService ,
197
+ $ deployRjsConfig ,
198
+ $ deployI18n ,
199
+ $ deployBundle
200
+ );
201
+
202
+ $ this ->objectManager ->expects ($ this ->exactly (1 ))
203
+ ->method ('get ' )
204
+ ->withConsecutive (
205
+ [MinifyTemplates::class]
206
+ )
207
+ ->willReturnOnConsecutiveCalls (
208
+ $ minifyTemplates
209
+ );
210
+ }
192
211
193
212
$ this ->assertEquals (
194
213
null ,
@@ -203,7 +222,8 @@ public function deployDataProvider()
203
222
[
204
223
'strategy ' => 'compact ' ,
205
224
'no-javascript ' => false ,
206
- 'no-html-minify ' => false
225
+ 'no-html-minify ' => false ,
226
+ 'refresh-content-version-only ' => false ,
207
227
],
208
228
null // content version value should not be asserted in this case
209
229
],
@@ -212,9 +232,17 @@ public function deployDataProvider()
212
232
'strategy ' => 'compact ' ,
213
233
'no-javascript ' => false ,
214
234
'no-html-minify ' => false ,
235
+ 'refresh-content-version-only ' => false ,
215
236
'content-version ' => '123456 ' ,
216
237
],
217
238
'123456 '
239
+ ],
240
+ [
241
+ [
242
+ 'refresh-content-version-only ' => true ,
243
+ 'content-version ' => '654321 ' ,
244
+ ],
245
+ '654321 '
218
246
]
219
247
];
220
248
}
0 commit comments