Example #1
0
 /**
  * Format widget pseudo-code for inserting into wysiwyg editor
  *
  * @return void
  */
 public function execute()
 {
     $type = $this->getRequest()->getPost('widget_type');
     $params = $this->getRequest()->getPost('parameters', array());
     $asIs = $this->getRequest()->getPost('as_is');
     $html = $this->_widget->getWidgetDeclaration($type, $params, $asIs);
     $this->getResponse()->setBody($html);
 }
Example #2
0
 public function testGetWidgetDeclaration()
 {
     $mathRandomMock = $this->getMock('\\Magento\\Framework\\Math\\Random', ['getRandomString'], [], '', false);
     $mathRandomMock->expects($this->any())->method('getRandomString')->willReturn('asdf');
     $reflection = new \ReflectionClass(get_class($this->widget));
     $reflectionProperty = $reflection->getProperty('mathRandom');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->widget, $mathRandomMock);
     $conditions = [['type' => 'Magento\\CatalogWidget\\Model\\Rule\\Condition\\Combine', 'aggregator' => 'all', 'value' => '1', 'new_child' => '']];
     $params = ['title' => 'my widget', 'show_pager' => '1', 'products_per_page' => '5', 'products_count' => '10', 'template' => 'product/widget/content/grid.phtml', 'conditions' => $conditions];
     $this->conditionsHelper->expects($this->once())->method('encode')->with($conditions)->willReturn('encoded-conditions-string');
     $result = $this->widget->getWidgetDeclaration('Magento\\CatalogWidget\\Block\\Product\\ProductsList', $params);
     $this->assertContains('{{widget type="Magento\\CatalogWidget\\Block\\Product\\ProductsList"', $result);
     $this->assertContains('conditions_encoded="encoded-conditions-string"', $result);
     $this->assertContains('page_var_name="pasdf"}}', $result);
 }
Example #3
0
 public function testGetWidgetDeclarationTypeWithBackslashes()
 {
     $this->assertContains('Magento\\\\Widget\\\\Backslashed\\\\ClassName', $this->_model->getWidgetDeclaration('Magento\\Widget\\Backslashed\\ClassName'));
 }