/** * @magentoAppIsolation enabled */ public function testGetParentBlock() { // Without layout $this->assertFalse($this->_block->getParentBlock()); // Need to create blocks through layout $parentBlock = $this->_createBlockWithLayout('block1', 'block1', 'Magento\\Framework\\View\\Element\\Text'); $childBlock = $this->_createBlockWithLayout('block2', 'block2'); $this->assertEmpty($childBlock->getParentBlock()); $parentBlock->setChild('block2', $childBlock); $this->assertSame($parentBlock, $childBlock->getParentBlock()); }