Skip to content

Commit 3afcb6c

Browse files
committed
MAGETWO-63020: [2.1 backport] SCD does not work when multiple languages are specified.
1 parent 75a7b9b commit 3afcb6c

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

dev/tests/integration/testsuite/Magento/Theme/Model/Theme/Domain/VirtualTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\View\Design\ThemeInterface;
99

10+
/**
11+
* Virtual theme test
12+
*/
1013
class VirtualTest extends \PHPUnit_Framework_TestCase
1114
{
1215
/**
@@ -19,20 +22,23 @@ class VirtualTest extends \PHPUnit_Framework_TestCase
1922
'theme_title' => 'Test physical theme',
2023
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
2124
'type' => ThemeInterface::TYPE_PHYSICAL,
25+
'code' => 'physical',
2226
],
2327
'virtual' => [
2428
'parent_id' => null,
2529
'theme_path' => '',
2630
'theme_title' => 'Test virtual theme',
2731
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
2832
'type' => ThemeInterface::TYPE_VIRTUAL,
33+
'code' => 'virtual',
2934
],
3035
'staging' => [
3136
'parent_id' => null,
3237
'theme_path' => '',
3338
'theme_title' => 'Test staging theme',
3439
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
3540
'type' => ThemeInterface::TYPE_STAGING,
41+
'code' => 'staging',
3642
],
3743
];
3844

@@ -54,21 +60,21 @@ public function testGetPhysicalTheme()
5460
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
5561
//1. set up fixture
5662
/** @var $physicalTheme \Magento\Framework\View\Design\ThemeInterface */
57-
$physicalTheme = $objectManager->create('Magento\Framework\View\Design\ThemeInterface');
63+
$physicalTheme = $objectManager->create(\Magento\Framework\View\Design\ThemeInterface::class);
5864
$physicalTheme->setData($this->_themes['physical']);
5965
$physicalTheme->save();
6066

6167
$this->_themes['virtual']['parent_id'] = $physicalTheme->getId();
6268

6369
/** @var $virtualTheme \Magento\Framework\View\Design\ThemeInterface */
64-
$virtualTheme = $objectManager->create('Magento\Framework\View\Design\ThemeInterface');
70+
$virtualTheme = $objectManager->create(\Magento\Framework\View\Design\ThemeInterface::class);
6571
$virtualTheme->setData($this->_themes['virtual']);
6672
$virtualTheme->save();
6773

6874
$this->_themes['staging']['parent_id'] = $virtualTheme->getId();
6975

7076
/** @var $stagingTheme \Magento\Framework\View\Design\ThemeInterface */
71-
$stagingTheme = $objectManager->create('Magento\Framework\View\Design\ThemeInterface');
77+
$stagingTheme = $objectManager->create(\Magento\Framework\View\Design\ThemeInterface::class);
7278
$stagingTheme->setData($this->_themes['staging']);
7379
$stagingTheme->save();
7480

@@ -77,7 +83,7 @@ public function testGetPhysicalTheme()
7783

7884
//2. run test
7985
/** @var $virtualTheme \Magento\Framework\View\Design\ThemeInterface */
80-
$virtualTheme = $objectManager->create('Magento\Framework\View\Design\ThemeInterface');
86+
$virtualTheme = $objectManager->create(\Magento\Framework\View\Design\ThemeInterface::class);
8187
$virtualTheme->load($this->_virtualThemeId);
8288

8389
$this->assertEquals(

lib/internal/Magento/Framework/View/Design/Theme/FlyweightFactory.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ public function __construct(ThemeProviderInterface $themeProvider)
4444
/**
4545
* Creates or returns a shared model of theme
4646
*
47-
* @param string $themeKey
48-
* @param string $area
49-
* @return \Magento\Framework\View\Design\ThemeInterface|null
50-
* @throws \InvalidArgumentException
51-
* @throws \LogicException
47+
* Search for theme in File System by specific path or load theme from DB
48+
* by specific path (e.g. adminhtml/Magento/backend) or by identifier (theme primary key) and return it
49+
* Can be used to deploy static or in other setup commands, even if Magento is not installed yet.
50+
*
51+
* @param string $themeKey Should looks like Magento/backend or should be theme primary key
52+
* @param string $area Can be adminhtml, frontend, etc...
53+
* @return \Magento\Framework\View\Design\ThemeInterface
54+
* @throws \InvalidArgumentException when incorrect themeKey was specified
55+
* @throws \LogicException when theme with appropriate themeKey was not found
5256
*/
5357
public function create($themeKey, $area = \Magento\Framework\View\DesignInterface::DEFAULT_AREA)
5458
{
@@ -61,7 +65,7 @@ public function create($themeKey, $area = \Magento\Framework\View\DesignInterfac
6165
} else {
6266
$themeModel = $this->_loadByPath($themeKey, $area);
6367
}
64-
if (!$themeModel->getId()) {
68+
if (!$themeModel->getCode()) {
6569
throw new \LogicException("Unable to load theme by specified key: '{$themeKey}'");
6670
}
6771
$this->_addTheme($themeModel);

lib/internal/Magento/Framework/View/Test/Unit/Design/Theme/FlyweightFactoryTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use \Magento\Framework\View\Design\Theme\FlyweightFactory;
99

10+
/**
11+
* FlyweightFactory test class
12+
*/
1013
class FlyweightFactoryTest extends \PHPUnit_Framework_TestCase
1114
{
1215
/**
@@ -21,7 +24,7 @@ class FlyweightFactoryTest extends \PHPUnit_Framework_TestCase
2124

2225
protected function setUp()
2326
{
24-
$this->themeProviderMock = $this->getMock('Magento\Framework\View\Design\Theme\ThemeProviderInterface');
27+
$this->themeProviderMock = $this->getMock(\Magento\Framework\View\Design\Theme\ThemeProviderInterface::class);
2528
$this->factory = new FlyweightFactory($this->themeProviderMock);
2629
}
2730

@@ -33,10 +36,11 @@ protected function setUp()
3336
*/
3437
public function testCreateById($path, $expectedId)
3538
{
36-
$theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false);
37-
$theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($expectedId));
39+
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
40+
$theme->expects($this->exactly(2))->method('getId')->will($this->returnValue($expectedId));
3841

3942
$theme->expects($this->once())->method('getFullPath')->will($this->returnValue(null));
43+
$theme->expects($this->once())->method('getCode')->willReturn($expectedId);
4044

4145
$this->themeProviderMock->expects(
4246
$this->once()
@@ -69,10 +73,11 @@ public function testCreateByPath()
6973
{
7074
$path = 'frontend/Magento/luma';
7175
$themeId = 7;
72-
$theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false);
73-
$theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($themeId));
76+
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
77+
$theme->expects($this->exactly(2))->method('getId')->will($this->returnValue($themeId));
7478

7579
$theme->expects($this->once())->method('getFullPath')->will($this->returnValue($path));
80+
$theme->expects($this->once())->method('getCode')->willReturn('Magento/luma');
7681

7782
$this->themeProviderMock->expects(
7883
$this->once()
@@ -94,8 +99,7 @@ public function testCreateByPath()
9499
public function testCreateDummy()
95100
{
96101
$themeId = 0;
97-
$theme = $this->getMock('Magento\Theme\Model\Theme', [], [], '', false);
98-
$theme->expects($this->once())->method('getId')->will($this->returnValue($themeId));
102+
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
99103

100104
$this->themeProviderMock->expects(
101105
$this->once()

0 commit comments

Comments
 (0)