本文整理汇总了PHP中Magento\Framework\View\LayoutInterface::addToParentGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP LayoutInterface::addToParentGroup方法的具体用法?PHP LayoutInterface::addToParentGroup怎么用?PHP LayoutInterface::addToParentGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\LayoutInterface
的用法示例。
在下文中一共展示了LayoutInterface::addToParentGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToHtmlPropagatesUrl
public function testToHtmlPropagatesUrl()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
$this->_block->setShouldPrepareInfoTabs(true);
$childOne = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child1', 'block');
$this->_layout->addToParentGroup('child1', 'info_tabs');
$childTwo = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child2', 'block');
$this->_layout->addToParentGroup('child2', 'info_tabs');
$this->assertEmpty($childOne->getViewUrl());
$this->assertEmpty($childTwo->getViewUrl());
$this->_block->toHtml();
$this->assertNotEmpty($childOne->getViewUrl());
$this->assertNotEmpty($childTwo->getViewUrl());
}
示例2: testAddToParentGroup
/**
* @magentoAppIsolation enabled
* @covers \Magento\Framework\View\Element\AbstractBlock::getGroupChildNames
* @covers \Magento\Framework\View\Layout::addToParentGroup
*/
public function testAddToParentGroup()
{
$parent = $this->_createBlockWithLayout('parent', 'parent');
$block1 = $this->_createBlockWithLayout('block1', 'block1');
$block2 = $this->_createBlockWithLayout('block2', 'block2');
$parent->setChild('block1', $block1)->setChild('block2', $block2);
$this->_layout->addToParentGroup('block1', 'group');
$this->_layout->addToParentGroup('block2', 'group');
$group = $parent->getGroupChildNames('group');
$this->assertContains('block1', $group);
$this->assertContains('block2', $group);
$this->assertSame($group[0], 'block1');
$this->assertSame($group[1], 'block2');
}