コード例 #1
0
ファイル: WidgetTest.php プロジェクト: tingyeeh/magento2
 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());
 }
コード例 #2
0
 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'));
 }
コード例 #3
0
ファイル: InstanceTest.php プロジェクト: tingyeeh/magento2
 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'));
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 public function testGet()
 {
     $result = $this->_configData->get();
     $expected = (include '_files/expectedGlobalDesignArray.php');
     $this->assertEquals($expected, $result);
 }
コード例 #6
0
ファイル: Data.php プロジェクト: swissup/easytabs
 /**
  * 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);
 }