Skip to content

Commit 9300561

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-63022' into BUGS
2 parents 6be54c0 + 6b6a9ab commit 9300561

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@ class VirtualTest extends \PHPUnit_Framework_TestCase
1919
'theme_title' => 'Test physical theme',
2020
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
2121
'type' => ThemeInterface::TYPE_PHYSICAL,
22+
'code' => 'physical',
2223
],
2324
'virtual' => [
2425
'parent_id' => null,
2526
'theme_path' => '',
2627
'theme_title' => 'Test virtual theme',
2728
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
2829
'type' => ThemeInterface::TYPE_VIRTUAL,
30+
'code' => 'virtual',
2931
],
3032
'staging' => [
3133
'parent_id' => null,
3234
'theme_path' => '',
3335
'theme_title' => 'Test staging theme',
3436
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
3537
'type' => ThemeInterface::TYPE_STAGING,
38+
'code' => 'staging',
3639
],
3740
];
3841

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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ protected function setUp()
3434
public function testCreateById($path, $expectedId)
3535
{
3636
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
37-
$theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($expectedId));
37+
$theme->expects($this->exactly(2))->method('getId')->will($this->returnValue($expectedId));
3838

3939
$theme->expects($this->once())->method('getFullPath')->will($this->returnValue(null));
40-
40+
$theme->expects($this->once())->method('getCode')->willReturn($expectedId);
4141
$this->themeProviderMock->expects(
4242
$this->once()
4343
)->method(
@@ -70,10 +70,10 @@ public function testCreateByPath()
7070
$path = 'frontend/Magento/luma';
7171
$themeId = 7;
7272
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
73-
$theme->expects($this->exactly(3))->method('getId')->will($this->returnValue($themeId));
73+
$theme->expects($this->exactly(2))->method('getId')->will($this->returnValue($themeId));
7474

7575
$theme->expects($this->once())->method('getFullPath')->will($this->returnValue($path));
76-
76+
$theme->expects($this->once())->method('getCode')->willReturn('Magento/luma');
7777
$this->themeProviderMock->expects(
7878
$this->once()
7979
)->method(
@@ -95,7 +95,6 @@ public function testCreateDummy()
9595
{
9696
$themeId = 0;
9797
$theme = $this->getMock(\Magento\Theme\Model\Theme::class, [], [], '', false);
98-
$theme->expects($this->once())->method('getId')->will($this->returnValue($themeId));
9998

10099
$this->themeProviderMock->expects(
101100
$this->once()

0 commit comments

Comments
 (0)