-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #581 from magento-folks/bugfix
[Folks] Bugs
- Loading branch information
Showing
31 changed files
with
642 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/Themes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Widget\Model\ResourceModel\Widget\Instance\Options; | ||
|
||
use Magento\Framework\Data\OptionSourceInterface; | ||
use Magento\Theme\Model\ResourceModel\Theme\CollectionFactory as ThemeCollectionFactory; | ||
|
||
/** | ||
* Option source of the widget theme property. | ||
* | ||
* Can be used as a data provider for UI components that shows possible themes as a list. | ||
*/ | ||
class Themes implements OptionSourceInterface | ||
{ | ||
/** | ||
* @var ThemeCollectionFactory | ||
*/ | ||
private $themeCollectionFactory; | ||
|
||
/** | ||
* @param ThemeCollectionFactory $themeCollectionFactory | ||
*/ | ||
public function __construct(ThemeCollectionFactory $themeCollectionFactory) | ||
{ | ||
$this->themeCollectionFactory = $themeCollectionFactory; | ||
} | ||
|
||
/** | ||
* Return array of options as value-label pairs | ||
* | ||
* @return array Format: array('<theme ID>' => '<theme label>', ...) | ||
*/ | ||
public function toOptionArray() | ||
{ | ||
// Load only visible themes that are used in frontend area | ||
return $this->themeCollectionFactory->create()->loadRegisteredThemes()->toOptionHash(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/code/Magento/Widget/Test/Unit/Model/ResourceModel/Widget/Instance/Options/ThemesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Widget\Test\Unit\Model\ResourceModel\Widget\Instance\Options; | ||
|
||
use Magento\Widget\Model\ResourceModel\Widget\Instance\Options\Themes; | ||
use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection; | ||
use Magento\Theme\Model\ResourceModel\Theme\CollectionFactory as ThemeCollectionFactory; | ||
|
||
/** | ||
* Test class for \Magento\Widget\Model\ResourceModel\Widget\Instance\Options\Themes | ||
*/ | ||
class ThemesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Themes | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $themeCollectionFactoryMock; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $themeCollectionMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->themeCollectionMock = $this->getMock(ThemeCollection::class, [], [], '', false); | ||
$this->themeCollectionFactoryMock = $this->getMock(ThemeCollectionFactory::class, ['create'], [], '', false); | ||
$this->model = new Themes( | ||
$this->themeCollectionFactoryMock | ||
); | ||
} | ||
|
||
public function testToOptionArray() | ||
{ | ||
$expectedResult = [ | ||
1 => 'Theme Label', | ||
]; | ||
$this->themeCollectionFactoryMock->expects($this->once()) | ||
->method('create') | ||
->willReturn($this->themeCollectionMock); | ||
|
||
$this->themeCollectionMock->expects($this->once())->method('loadRegisteredThemes')->willReturnSelf(); | ||
$this->themeCollectionMock->expects($this->once())->method('toOptionHash')->willReturn($expectedResult); | ||
|
||
$this->assertEquals($expectedResult, $this->model->toOptionArray()); | ||
} | ||
} |
Oops, something went wrong.