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)); }
/** * @magentoAppIsolation enabled */ public function testGetChildBlocks() { $this->_layout->addContainer('parent', 'Parent'); $block1 = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'block1', 'parent'); $this->_layout->addContainer('container', 'Container', [], 'parent'); $block2 = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Template', 'block2', 'parent'); $this->assertSame(['block1' => $block1, 'block2' => $block2], $this->_layout->getChildBlocks('parent')); }
/** * {@inheritdoc} */ public function getChildBlocks($parentName) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getChildBlocks'); if (!$pluginInfo) { return parent::getChildBlocks($parentName); } else { return $this->___callPlugins('getChildBlocks', func_get_args(), $pluginInfo); } }