/** * @param string $parentName * @param string $alias * @param string $name * @param bool $isBlock * @dataProvider getChildBlockDataProvider */ public function testGetChildBlock($parentName, $alias, $name, $isBlock) { $this->structureMock->expects($this->once())->method('getChildId')->with($this->equalTo($parentName), $this->equalTo($alias))->will($this->returnValue($name)); $this->structureMock->expects($this->once())->method('hasElement')->with($this->equalTo($name))->will($this->returnValue($isBlock)); if ($isBlock) { $this->schStructureMock->expects($this->once())->method('hasElement')->with($this->equalTo($name))->will($this->returnValue($isBlock)); $this->structureMock->expects($this->once())->method('getAttribute')->with($this->equalTo($name), $this->equalTo('type'))->will($this->returnValue(\Magento\Framework\View\Layout\Element::TYPE_BLOCK)); $this->prepareGenerateBlock($name); $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $this->model->getChildBlock($parentName, $alias)); } else { $this->assertFalse($this->model->getChildBlock($parentName, $alias)); } }
/** * @magentoAppIsolation enabled */ public function testGetChildBlock() { $this->_layout->addContainer('parent', 'Parent'); $block = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'block', 'parent', 'block_alias'); $this->_layout->addContainer('container', 'Container', [], 'parent', 'container_alias'); $this->assertSame($block, $this->_layout->getChildBlock('parent', 'block_alias')); $this->assertFalse($this->_layout->getChildBlock('parent', 'container_alias')); }
public function testGetChildNonExistBlock() { $this->structureMock->expects($this->once()) ->method('getChildId') ->with('non_exist_parent', 'non_exist_alias') ->willReturn(false); $this->assertFalse($this->model->getChildBlock('non_exist_parent', 'non_exist_alias')); }
/** * {@inheritdoc} */ public function getChildBlock($parentName, $alias) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getChildBlock'); if (!$pluginInfo) { return parent::getChildBlock($parentName, $alias); } else { return $this->___callPlugins('getChildBlock', func_get_args(), $pluginInfo); } }