public function testGetConfigAsObjectWidgetNoFound() { $this->dataStorageMock->expects($this->once())->method('get')->willReturn([]); $resultObject = $this->widget->getConfigAsObject('Magento\\Cms\\Block\\Widget\\Page\\Link'); $this->assertInstanceOf('Magento\\Framework\\DataObject', $resultObject); $this->assertSame([], $resultObject->getData()); }
public function testGetWidgetByClassType() { $widgetOne = array('@' => array('type' => 'type1')); $widgets = array('widget1' => $widgetOne); $this->_storage->expects($this->any())->method('get')->will($this->returnValue($widgets)); $this->assertEquals($widgetOne, $this->_model->getWidgetByClassType('type1')); $this->assertNull($this->_model->getWidgetByClassType('type2')); }
public function testGetWidgetSupportedTemplatesByContainersUnknownContainer() { $expectedConfigFile = __DIR__ . '/../_files/mappedConfigArray1.php'; $widget = (include $expectedConfigFile); $this->_widgetModelMock->expects($this->once())->method('getWidgetByClassType')->will($this->returnValue($widget)); $this->_viewFileSystemMock->expects($this->once())->method('getFilename')->will($this->returnValue('')); $expectedTemplates = []; $this->assertEquals($expectedTemplates, $this->_model->getWidgetSupportedTemplatesByContainer('unknown')); }
/** * Return filtered list of widgets * * @param array $filters Key-value array of filters for widget node properties * @return array * @api */ public function getWidgets($filters = []) { $widgets = $this->dataStorage->get(); $result = $widgets; // filter widgets by params if (is_array($filters) && count($filters) > 0) { foreach ($widgets as $code => $widget) { try { foreach ($filters as $field => $value) { if (!isset($widget[$field]) || (string) $widget[$field] != $value) { throw new \Exception(); } } } catch (\Exception $e) { unset($result[$code]); continue; } } } return $result; }
public function testGet() { $result = $this->_configData->get(); $expected = (include '_files/expectedGlobalDesignArray.php'); $this->assertEquals($expected, $result); }
/** * Constructor * * @param \Magento\Framework\Config\ReaderInterface $reader * @param \Magento\Framework\Config\ScopeInterface $configScope * @param \Magento\Framework\Config\CacheInterface $cache * @param string $cacheId */ public function __construct(\Magento\Framework\Config\ReaderInterface $reader, \Magento\Framework\Config\ScopeInterface $configScope, \Magento\Framework\Config\CacheInterface $cache, $cacheId) { parent::__construct($reader, $configScope, $cache, $cacheId); }