@@ -250,6 +250,33 @@ public function setupPassChildThemeCheck()
250
250
$ this ->collection ->expects ($ this ->any ())->method ('getIterator ' )->willReturn (new \ArrayIterator ([]));
251
251
}
252
252
253
+ public function setupPassThemeInUseCheck ()
254
+ {
255
+ $ this ->themeValidator ->expects ($ this ->once ())->method ('validateIsThemeInUse ' )->willReturn ([]);
256
+ }
257
+
258
+ public function setupPassDependencyCheck ()
259
+ {
260
+ $ this ->dependencyChecker ->expects ($ this ->once ())->method ('checkDependencies ' )->willReturn ([]);
261
+ }
262
+
263
+ public function testExecuteFailedThemeInUseCheck ()
264
+ {
265
+ $ this ->setUpPassValidation ();
266
+ $ this ->setupPassChildThemeCheck ();
267
+ $ this ->setupPassDependencyCheck ();
268
+ $ this ->themeValidator
269
+ ->expects ($ this ->once ())
270
+ ->method ('validateIsThemeInUse ' )
271
+ ->willReturn (['frontend/Magento/a is in use in default config ' ]);
272
+ $ this ->tester ->execute (['theme ' => ['frontend/Magento/a ' ]]);
273
+ $ this ->assertEquals (
274
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL
275
+ . 'frontend/Magento/a is in use in default config ' . PHP_EOL ,
276
+ $ this ->tester ->getDisplay ()
277
+ );
278
+ }
279
+
253
280
/**
254
281
* @dataProvider executeFailedChildThemeCheckDataProvider
255
282
* @param bool $hasVirtual
@@ -261,6 +288,8 @@ public function setupPassChildThemeCheck()
261
288
public function testExecuteFailedChildThemeCheck ($ hasVirtual , $ hasPhysical , array $ input , $ expected )
262
289
{
263
290
$ this ->setUpPassValidation ();
291
+ $ this ->setupPassThemeInUseCheck ();
292
+ $ this ->setupPassDependencyCheck ();
264
293
$ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
265
294
$ theme ->expects ($ this ->any ())->method ('hasChildThemes ' )->willReturn ($ hasVirtual );
266
295
$ parentThemeA = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
@@ -282,10 +311,7 @@ public function testExecuteFailedChildThemeCheck($hasVirtual, $hasPhysical, arra
282
311
->method ('getIterator ' )
283
312
->willReturn (new \ArrayIterator ([$ childThemeC , $ childThemeD ]));
284
313
$ this ->tester ->execute ($ input );
285
- $ this ->assertContains (
286
- $ expected ,
287
- $ this ->tester ->getDisplay ()
288
- );
314
+ $ this ->assertContains ($ expected , $ this ->tester ->getDisplay ());
289
315
}
290
316
291
317
/**
@@ -298,74 +324,75 @@ public function executeFailedChildThemeCheckDataProvider()
298
324
true ,
299
325
false ,
300
326
['theme ' => ['frontend/Magento/a ' ]],
301
- 'Unable to uninstall. frontend/Magento/a is a parent of virtual theme '
327
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL
328
+ . 'frontend/Magento/a is a parent of virtual theme. Parent themes cannot be uninstalled. '
302
329
],
303
330
[
304
331
true ,
305
332
false ,
306
333
['theme ' => ['frontend/Magento/a ' , 'frontend/Magento/b ' ]],
307
- 'Unable to uninstall. frontend/Magento/a, frontend/Magento/b are parents of virtual theme '
334
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL .
335
+ 'frontend/Magento/a, frontend/Magento/b are parents of virtual theme. '
336
+ . ' Parent themes cannot be uninstalled. '
308
337
],
309
338
[
310
339
false ,
311
340
true ,
312
341
['theme ' => ['frontend/Magento/a ' ]],
313
- 'Unable to uninstall. frontend/Magento/a is a parent of physical theme '
342
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL .
343
+ 'frontend/Magento/a is a parent of physical theme. Parent themes cannot be uninstalled. '
314
344
],
315
345
[
316
346
false ,
317
347
true ,
318
348
['theme ' => ['frontend/Magento/a ' , 'frontend/Magento/b ' ]],
319
- 'Unable to uninstall. frontend/Magento/a, frontend/Magento/b are parents of physical theme '
349
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL .
350
+ 'frontend/Magento/a, frontend/Magento/b are parents of physical theme. '
351
+ . ' Parent themes cannot be uninstalled. '
320
352
],
321
353
[
322
354
true ,
323
355
true ,
324
356
['theme ' => ['frontend/Magento/a ' ]],
325
- 'Unable to uninstall. frontend/Magento/a is a parent of virtual theme ' . PHP_EOL .
326
- 'Unable to uninstall. frontend/Magento/a is a parent of physical theme '
357
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL .
358
+ 'frontend/Magento/a is a parent of virtual theme. Parent themes cannot be uninstalled. ' . PHP_EOL .
359
+ 'frontend/Magento/a is a parent of physical theme. Parent themes cannot be uninstalled. '
327
360
],
328
361
[
329
362
true ,
330
363
true ,
331
364
['theme ' => ['frontend/Magento/a ' , 'frontend/Magento/b ' ]],
332
- 'Unable to uninstall. frontend/Magento/a, frontend/Magento/b are parents of virtual theme ' . PHP_EOL .
333
- 'Unable to uninstall. frontend/Magento/a, frontend/Magento/b are parents of physical theme '
365
+ 'frontend/Magento/a, frontend/Magento/b are parents of virtual theme. '
366
+ . ' Parent themes cannot be uninstalled. ' . PHP_EOL .
367
+ 'frontend/Magento/a, frontend/Magento/b are parents of physical theme. '
368
+ . ' Parent themes cannot be uninstalled. '
334
369
],
335
370
];
336
371
}
337
372
338
- public function testExecuteFailedThemeInUseCheck ()
339
- {
340
- $ this ->setUpPassValidation ();
341
- $ this ->themeValidator
342
- ->expects ($ this ->once ())
343
- ->method ('validateIsThemeInUse ' )
344
- ->willReturn (['frontend/Magento/a is in use in default config ' ]);
345
- $ this ->tester ->execute (['theme ' => ['frontend/Magento/a ' ]]);
346
- $ this ->assertEquals ('frontend/Magento/a is in use in default config ' . PHP_EOL , $ this ->tester ->getDisplay ());
347
- }
348
-
349
373
public function testExecuteFailedDependencyCheck ()
350
374
{
351
375
$ this ->setUpPassValidation ();
376
+ $ this ->setupPassThemeInUseCheck ();
352
377
$ this ->setupPassChildThemeCheck ();
353
378
$ this ->dependencyChecker ->expects ($ this ->once ())
354
379
->method ('checkDependencies ' )
355
380
->willReturn (['magento/theme-a ' => ['magento/theme-b ' , 'magento/theme-c ' ]]);
356
381
$ this ->tester ->execute (['theme ' => ['frontend/Magento/a ' ]]);
357
382
$ this ->assertContains (
358
- 'Cannot uninstall frontend/Magento/a because the following package(s) ' .
359
- 'depend on it: ' . PHP_EOL . "\tmagento/theme-b " . PHP_EOL . "\tmagento/theme-c " ,
383
+ 'Unable to uninstall. Please resolve the following issues: ' . PHP_EOL .
384
+ 'frontend/Magento/a has the following dependent package(s): '
385
+ . PHP_EOL . "\tmagento/theme-b " . PHP_EOL . "\tmagento/theme-c " ,
360
386
$ this ->tester ->getDisplay ()
361
387
);
362
388
}
363
389
364
390
public function setUpExecute ()
365
391
{
366
392
$ this ->setUpPassValidation ();
393
+ $ this ->setupPassThemeInUseCheck ();
367
394
$ this ->setupPassChildThemeCheck ();
368
- $ this ->dependencyChecker -> expects ( $ this -> once ())-> method ( ' checkDependencies ' )-> willReturn ([] );
395
+ $ this ->setupPassDependencyCheck ( );
369
396
$ this ->remove ->expects ($ this ->once ())->method ('remove ' );
370
397
$ this ->cache ->expects ($ this ->once ())->method ('clean ' );
371
398
$ theme = $ this ->getMock ('Magento\Theme\Model\Theme ' , [], [], '' , false );
0 commit comments