@@ -26,11 +26,6 @@ class ThemeUninstallCommandTest extends \PHPUnit_Framework_TestCase
26
26
*/
27
27
private $ maintenanceMode ;
28
28
29
- /**
30
- * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
31
- */
32
- private $ objectManager ;
33
-
34
29
/**
35
30
* @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
36
31
*/
@@ -204,8 +199,7 @@ public function testExecuteFailedValidationMixed()
204
199
[
205
200
['test1/composer.json ' , null , null , '{"name": "dummy1"} ' ],
206
201
['test2/composer.json ' , null , null , '{"name": "magento/theme-b"} ' ],
207
- ['test4/composer.json ' , null , null , '{"name": "dummy2"} ' ],
208
- ['test5/composer.json ' , null , null , '{"name": "magento/theme-b"} ' ]
202
+ ['test4/composer.json ' , null , null , '{"name": "dummy2"} ' ]
209
203
]
210
204
));
211
205
$ dirRead ->expects ($ this ->any ())
@@ -215,8 +209,7 @@ public function testExecuteFailedValidationMixed()
215
209
['test1/composer.json ' , true ],
216
210
['test2/composer.json ' , true ],
217
211
['test3/composer.json ' , false ],
218
- ['test4/composer.json ' , true ],
219
- ['test5/composer.json ' , true ]
212
+ ['test4/composer.json ' , true ]
220
213
]
221
214
));
222
215
$ this ->collection ->expects ($ this ->any ())
@@ -226,17 +219,11 @@ public function testExecuteFailedValidationMixed()
226
219
$ this ->collection ->expects ($ this ->at (3 ))->method ('hasTheme ' )->willReturn (true );
227
220
$ this ->collection ->expects ($ this ->at (5 ))->method ('hasTheme ' )->willReturn (false );
228
221
$ this ->collection ->expects ($ this ->at (7 ))->method ('hasTheme ' )->willReturn (true );
229
- $ this ->collection ->expects ($ this ->at (9 ))->method ('hasTheme ' )->willReturn (true );
230
222
$ this ->filesystem ->expects ($ this ->any ())
231
223
->method ('getDirectoryRead ' )
232
224
->with (DirectoryList::THEMES )
233
225
->willReturn ($ dirRead );
234
- $ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
235
- $ theme ->expects ($ this ->at (1 ))->method ('hasChildThemes ' )->willReturn (false );
236
- $ theme ->expects ($ this ->at (2 ))->method ('hasChildThemes ' )->willReturn (false );
237
- $ theme ->expects ($ this ->at (3 ))->method ('hasChildThemes ' )->willReturn (true );
238
- $ this ->themeProvider ->expects ($ this ->any ())->method ('getThemeByFullPath ' )->willReturn ($ theme );
239
- $ this ->tester ->execute (['theme ' => ['test1 ' , 'test2 ' , 'test3 ' , 'test4 ' , 'test5 ' ]]);
226
+ $ this ->tester ->execute (['theme ' => ['test1 ' , 'test2 ' , 'test3 ' , 'test4 ' ]]);
240
227
$ this ->assertContains (
241
228
'test1, test4 are not installed composer packages ' ,
242
229
$ this ->tester ->getDisplay ()
@@ -249,10 +236,6 @@ public function testExecuteFailedValidationMixed()
249
236
'Unknown theme(s): test3 ' . PHP_EOL ,
250
237
$ this ->tester ->getDisplay ()
251
238
);
252
- $ this ->assertContains (
253
- 'test5 is a base of virtual theme ' ,
254
- $ this ->tester ->getDisplay ()
255
- );
256
239
}
257
240
258
241
public function setUpPassValidation ()
@@ -274,14 +257,45 @@ public function setUpPassValidation()
274
257
->method ('getThemeByFullPath ' )
275
258
->willReturn ($ this ->getMockForAbstractClass ('Magento\Framework\View\Design\ThemeInterface ' , [], '' , false ));
276
259
$ this ->collection ->expects ($ this ->any ())->method ('hasTheme ' )->willReturn (true );
260
+ }
261
+
262
+ public function setupPassChildVirtualThemeCheck ()
263
+ {
277
264
$ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
278
265
$ theme ->expects ($ this ->any ())->method ('hasChildThemes ' )->willReturn (false );
279
266
$ this ->themeProvider ->expects ($ this ->any ())->method ('getThemeByFullPath ' )->willReturn ($ theme );
280
267
}
281
268
269
+ public function testExecuteFailedChildVirtualThemeCheck ()
270
+ {
271
+ $ this ->setUpPassValidation ();
272
+ $ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
273
+ $ theme ->expects ($ this ->any ())->method ('hasChildThemes ' )->willReturn (true );
274
+ $ this ->themeProvider ->expects ($ this ->any ())->method ('getThemeByFullPath ' )->willReturn ($ theme );
275
+ $ this ->tester ->execute (['theme ' => ['frontend/Magento/a ' ]]);
276
+ $ this ->assertContains (
277
+ 'Unable to delete. frontend/Magento/a is a base of virtual theme ' ,
278
+ $ this ->tester ->getDisplay ()
279
+ );
280
+ }
281
+
282
+ public function testExecuteFailedMultipleChildVirtualThemeCheck ()
283
+ {
284
+ $ this ->setUpPassValidation ();
285
+ $ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
286
+ $ theme ->expects ($ this ->any ())->method ('hasChildThemes ' )->willReturn (true );
287
+ $ this ->themeProvider ->expects ($ this ->any ())->method ('getThemeByFullPath ' )->willReturn ($ theme );
288
+ $ this ->tester ->execute (['theme ' => ['frontend/Magento/a ' , 'frontend/Magento/b ' ]]);
289
+ $ this ->assertContains (
290
+ 'Unable to delete. frontend/Magento/a, frontend/Magento/b are bases of virtual theme ' ,
291
+ $ this ->tester ->getDisplay ()
292
+ );
293
+ }
294
+
282
295
public function testExecuteFailedDependencyCheck ()
283
296
{
284
297
$ this ->setUpPassValidation ();
298
+ $ this ->setupPassChildVirtualThemeCheck ();
285
299
$ this ->dependencyChecker ->expects ($ this ->once ())
286
300
->method ('checkDependencies ' )
287
301
->willReturn (['magento/theme-a ' => ['magento/theme-b ' , 'magento/theme-c ' ]]);
0 commit comments