protected function setUp() { $this->_layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => 'adminhtml')); $this->_layout->getUpdate()->load('layout_test_grid_handle'); $this->_layout->generateXml(); $this->_layout->generateElements(); $this->_block = $this->_layout->getBlock('admin.test.grid.massaction'); }
/** * @covers Mage_Core_Model_Layout::getAllBlocks * @covers Mage_Core_Model_Layout::generateBlocks * @covers Mage_Core_Model_Layout::getBlock */ public function testGenerateXmlAndElements() { $this->_layout->generateXml(); /* Generate fixture file_put_contents(dirname(__FILE__) . '/_files/_layout_update.xml', $this->_model->getNode()->asNiceXml()); */ $this->assertXmlStringEqualsXmlFile(__DIR__ . '/_files/_layout_update.xml', $this->_layout->getXmlString()); $this->assertEquals(array(), $this->_layout->getAllBlocks()); $expectedBlocks = array('root', 'head', 'head.calendar', 'notifications', 'notification_baseurl', 'cache_notifications', 'notification_survey', 'notification_security', 'messages', 'ANONYMOUS_0', 'index_notifications', 'index_notifications_copy'); $this->_layout->generateElements(); $actualBlocks = $this->_layout->getAllBlocks(); $this->assertEquals($expectedBlocks, array_keys($actualBlocks)); /** @var $block Mage_Adminhtml_Block_Page_Head */ $block = $this->_layout->getBlock('head'); $this->assertEquals('Magento Admin', $block->getTitle()); $block = $this->_layout->getBlock('head.calendar'); $this->assertSame($this->_layout->getBlock('head'), $block->getParentBlock()); /** @var $block Mage_Core_Block_Template */ $block = $this->_layout->getBlock('root'); $this->assertEquals('popup.phtml', $block->getTemplate()); $this->assertFalse($this->_layout->getBlock('test.nonexisting.block')); }
/** * Create structure of elements from the loaded XML configuration */ public function generateElements() { if ($this->_sanitationEnabled) { $this->sanitizeLayout($this->getNode()); } parent::generateElements(); }