/** * @covers Mage_Core_Block_Abstract::getChildHtml * @covers Mage_Core_Block_Abstract::getChildChildHtml */ public function testGetChildHtml() { $blockOne = new Mage_Core_Block_Text(); $blockOne->setText('one')->setNameInLayout(uniqid('block.one.')); $blockTwo = new Mage_Core_Block_Text(); $blockTwo->setText('two')->setNameInLayout(uniqid('block.two.')); $this->_block->insert($blockTwo, '', false, 'block2'); // make block2 1st $this->_block->insert($blockOne, '', false, 'block1'); // make block1 1st $this->assertEquals('one', $this->_block->getChildHtml('block1')); $this->assertEquals('two', $this->_block->getChildHtml('block2')); // unsorted children will render in the order they were added $this->assertEquals('twoone', $this->_block->getChildHtml()); // hack: rendering sorted children requires layout $layout = new Mage_Core_Model_Layout(); $this->_block->setLayout($layout); $blockOne->setLayout($layout); $layout->setBlock($blockOne->getNameInLayout(), $blockOne); $blockTwo->setLayout($layout); $layout->setBlock($blockTwo->getNameInLayout(), $blockTwo); // sorted will render in the designated order $this->assertEquals('onetwo', $this->_block->getChildHtml('', true, true)); // getChildChildHtml $blockTwo->setChild('block11', $blockOne); $this->assertEquals('one', $this->_block->getChildChildHtml('block2')); $this->assertEquals('', $this->_block->getChildChildHtml('')); $this->assertEquals('', $this->_block->getChildChildHtml('block3')); }
public function testGetChildChildHtml() { // Without layout $this->assertEmpty($this->_block->getChildChildHtml('alias')); // With layout $parent1 = $this->_createBlockWithLayout('parent1', 'parent1'); $parent2 = $this->_createBlockWithLayout('parent2', 'parent2'); $block1 = $this->_createBlockWithLayout('block1', 'block1', 'Mage_Core_Block_Text'); $block2 = $this->_createBlockWithLayout('block2', 'block2', 'Mage_Core_Block_Text'); $block3 = $this->_createBlockWithLayout('block3', 'block3', 'Mage_Core_Block_Text'); $block4 = $this->_createBlockWithLayout('block4', 'block4', 'Mage_Core_Block_Text'); $block1->setText('one'); $block2->setText('two'); $block3->setText('three'); $block4->setText('four'); $parent1->insert($parent2); $parent2->insert($block1, '-', false, 'block1'); $parent2->insert($block2, '-', false, 'block2'); $parent2->insert($block3, '-', true, 'block3'); $parent1->insert($block4); $this->assertEquals('twoonethree', $parent1->getChildChildHtml('parent2')); }