Skip to content

Commit 0aeac1b

Browse files
author
Oleksandr Karpenko
committed
MAGETWO-43188: Unable to rename theme by editing theme.xml file
1 parent 300465c commit 0aeac1b

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

app/code/Magento/Theme/Model/Theme/Plugin/Registration.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ protected function updateThemeData()
8989
$themesData = $this->themeCollection->loadData();
9090
/** @var \Magento\Theme\Model\Theme $themeData */
9191
foreach ($themesData as $themeData) {
92+
if ($themeData->getParentTheme()) {
93+
$parentTheme = $this->themeLoader->getThemeByFullPath(
94+
$themeData->getParentTheme()->getFullPath()
95+
);
96+
$themeData->setParentId($parentTheme->getId());
97+
}
98+
9299
/** @var \Magento\Theme\Model\Theme $theme */
93100
$theme = $this->themeLoader->getThemeByFullPath(
94101
$themeData->getArea()

app/code/Magento/Theme/Test/Unit/Model/Theme/Plugin/RegistrationTest.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,42 @@ public function setUp()
5555

5656
public function testBeforeDispatch()
5757
{
58-
$theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false);
58+
$theme = $this->getMock(
59+
'Magento\Theme\Model\Theme',
60+
[
61+
'setParentId',
62+
'getArea',
63+
'getThemePath',
64+
'getParentTheme',
65+
'getId',
66+
'getFullPath',
67+
'toArray',
68+
'addData',
69+
'save',
70+
],
71+
[],
72+
'',
73+
false
74+
);
5975
$this->appState->expects($this->once())->method('getMode')->willReturn('default');
6076
$this->themeRegistration->expects($this->once())->method('register');
6177
$this->themeCollection->expects($this->once())->method('loadData')->willReturn([$theme]);
6278
$theme->expects($this->once())->method('getArea')->willReturn('frontend');
6379
$theme->expects($this->once())->method('getThemePath')->willReturn('Magento/luma');
64-
$this->themeLoader->expects($this->once())
80+
$theme->expects($this->exactly(2))->method('getParentTheme')->willReturnSelf();
81+
$theme->expects($this->once())->method('getId')->willReturn(1);
82+
$theme->expects($this->once())->method('getFullPath')->willReturn('frontend/Magento/blank');
83+
$theme->expects($this->once())->method('setParentId')->with(1);
84+
$this->themeLoader->expects($this->exactly(2))
6585
->method('getThemeByFullPath')
66-
->with('frontend/Magento/luma')
67-
->willReturn($theme);
86+
->withConsecutive(
87+
['frontend/Magento/blank'],
88+
['frontend/Magento/luma']
89+
)
90+
->will($this->onConsecutiveCalls(
91+
$theme,
92+
$theme
93+
));
6894
$theme->expects($this->once())
6995
->method('toArray')
7096
->willReturn([

0 commit comments

Comments
 (0)