Skip to content

Commit ac8ad60

Browse files
Fred Sungeddielau
authored andcommitted
MAGETWO-38178: Check if Theme in use
- Add missing description block - Test cases updated from CR feedback
1 parent 2d0e1f7 commit ac8ad60

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

app/code/Magento/Theme/Model/ThemeValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct(
5555
}
5656

5757
/**
58+
* Validate the theme if being in use in default, website, or store.
5859
*
5960
* @param string[] $themePaths
6061
* @return array
@@ -81,7 +82,7 @@ public function validateIsThemeInUse($themePaths)
8182
. $this->storeManager->getWebsite($row['scope_id'])->getName();
8283
break;
8384
case ScopeInterface::SCOPE_STORES:
84-
$messages[] = $themesById[$row['value']] . ' is in use in website '
85+
$messages[] = $themesById[$row['value']] . ' is in use in store '
8586
. $this->storeManager->getStore($row['scope_id'])->getName();
8687
break;
8788
}

app/code/Magento/Theme/Test/Unit/Console/Command/ThemeUninstallCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ public function testExecuteFailedThemeInUseCheck()
341341
$this->themeValidator
342342
->expects($this->once())
343343
->method('validateIsThemeInUse')
344-
->willReturn(['frontend/Magento/a']);
344+
->willReturn(['frontend/Magento/a is in use in default config']);
345345
$this->tester->execute(['theme' => ['frontend/Magento/a']]);
346+
$this->assertEquals('frontend/Magento/a is in use in default config' . PHP_EOL, $this->tester->getDisplay());
346347
}
347348

348349
public function testExecuteFailedDependencyCheck()

app/code/Magento/Theme/Test/Unit/Model/ThemeValidatorTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class ThemeValidatorTest extends \PHPUnit_Framework_TestCase
1313
{
1414
/**
15-
* @var \Magento\Theme\Model\ThemeValidator|\PHPUnit_Framework_MockObject_MockObject
15+
* @var \Magento\Theme\Model\ThemeValidator
1616
*/
1717
protected $themeValidator;
1818

@@ -72,10 +72,20 @@ public function testValidateIsThemeInUse()
7272
->expects($this->at(2))
7373
->method('addFieldToFilter')
7474
->willReturn([$defaultEntity, $websitesEntity, $storesEntity]);
75-
$website = $this->getMock('Magento\Store\Model\Website', [], [], '', false);
76-
$store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
75+
$website = $this->getMock('Magento\Store\Model\Website', ['getName'], [], '', false);
76+
$website->expects($this->once())->method('getName')->willReturn('websiteA');
77+
$store = $this->getMock('Magento\Store\Model\Store', ['getName'], [], '', false);
78+
$store->expects($this->once())->method('getName')->willReturn('storeA');
7779
$this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website);
7880
$this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
79-
$this->themeValidator->validateIsThemeInUse(['frontend/Magento/a']);
81+
$result = $this->themeValidator->validateIsThemeInUse(['frontend/Magento/a']);
82+
$this->assertEquals(
83+
[
84+
'frontend/Magento/a is in use in default config',
85+
'frontend/Magento/a is in use in website websiteA',
86+
'frontend/Magento/a is in use in store storeA'
87+
],
88+
$result
89+
);
8090
}
8191
}

0 commit comments

Comments
 (0)