Exemplo n.º 1
0
 public function testCreateBlockSuccess()
 {
     $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->_blockFactoryMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));
     $this->_model->createBlock('type', 'blockname', array());
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $this->_model->getBlock('blockname'));
 }
Exemplo n.º 2
0
 /**
  * Categories chooser Action (Ajax request)
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $selected = $this->getRequest()->getParam('selected', '');
     $isAnchorOnly = $this->getRequest()->getParam('is_anchor_only', 0);
     /** @var \Magento\Widget\Block\Adminhtml\Widget\Catalog\Category\Chooser $chooser */
     $chooser = $this->layout->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Catalog\\Category\\Chooser')->setUseMassaction(true)->setId($this->mathRandom->getUniqueHash('categories'))->setIsAnchorOnly($isAnchorOnly)->setSelectedCategories(explode(',', $selected));
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     return $resultRaw->setContents($chooser->toHtml());
 }
Exemplo n.º 3
0
    public function testGetChildBlocks()
    {
        $parentName = 'parent';
        $childrenArray = ['block_name' => 'value1'];
        $this->structureMock->expects($this->once())
            ->method('getChildren')
            ->with($this->equalTo($parentName))
            ->will($this->returnValue($childrenArray));

        $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\AbstractBlock')
            ->disableOriginalConstructor()
            ->getMockForAbstractClass();
        $this->structureMock->expects($this->once())
            ->method('createStructuralElement')
            ->with(
                'block_name',
                \Magento\Framework\View\Layout\Element::TYPE_BLOCK,
                'Magento\Framework\View\Element\AbstractBlock'
            )->willReturn('block_name');
        $this->generatorBlockMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));

        $this->assertSame(
            $blockMock,
            $this->model->createBlock('Magento\Framework\View\Element\AbstractBlock', 'block_name', [])
        );
        $this->assertSame(['value1' => $blockMock], $this->model->getChildBlocks($parentName));
    }
Exemplo n.º 4
0
 /**
  * @magentoConfigFixture customer/account_share/scope 1
  */
 public function testToHtmlEmptyWebsiteShareNewCustomer()
 {
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\View\\Accordion');
     $html = $block->toHtml();
     $this->assertContains('Wishlist - 0 item(s)', $html);
     $this->assertContains('Shopping Cart - 0 item(s)', $html);
 }
Exemplo n.º 5
0
 public function testRenameElement()
 {
     $blockName = 'block';
     $expBlockName = 'block_renamed';
     $containerName = 'container';
     $expContainerName = 'container_renamed';
     $block = $this->_layout->createBlock('Magento\\Framework\\View\\Element\\Text', $blockName);
     $this->_layout->addContainer($containerName, 'Container');
     $this->assertEquals($block, $this->_layout->getBlock($blockName));
     $this->_layout->renameElement($blockName, $expBlockName);
     $this->assertEquals($block, $this->_layout->getBlock($expBlockName));
     $this->_layout->hasElement($containerName);
     $this->_layout->renameElement($containerName, $expContainerName);
     $this->_layout->hasElement($expContainerName);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function createBlock($type, $name = '', array $arguments = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'createBlock');
     if (!$pluginInfo) {
         return parent::createBlock($type, $name, $arguments);
     } else {
         return $this->___callPlugins('createBlock', func_get_args(), $pluginInfo);
     }
 }