/** * @magentoAppIsolation enabled * @covers \Magento\Framework\View\Element\AbstractBlock::getChildNames * @covers \Magento\Framework\View\Element\AbstractBlock::insert */ public function testGetChildNames() { // Without layout $this->assertEquals([], $this->_block->getChildNames()); // With layout $parent = $this->_createBlockWithLayout('parent', 'parent'); $block1 = $this->_createBlockWithLayout('block1'); $block2 = $this->_createBlockWithLayout('block2'); $block3 = $this->_createBlockWithLayout('block3'); $block4 = $this->_createBlockWithLayout('block4'); $parent->insert($block1); // add one block $parent->insert($block2, 'block1', false); // add second to the 1st position $parent->insert($block3, 'block1', false); // add third to the 2nd position $parent->insert($block4, 'block3', true); // add fourth block to the 3rd position $this->assertEquals(['block2', 'block3', 'block4', 'block1'], $parent->getChildNames()); }