/** * @expectedException OutOfRangeException */ public function testGetResultSkipItemsWithInvalidParent() { $item1 = $this->getMock("Mage_Backend_Model_Menu_Item", array(), array(), '', false); $this->_factoryMock->expects($this->any())->method('createFromArray')->will($this->returnValue($item1)); $this->_model->processCommand(new Mage_Backend_Model_Menu_Builder_Command_Add(array('id' => 'item1', 'parent' => 'not_exists', 'title' => 'Item 1', 'module' => 'Mage_Backend', 'resource' => 'Mage_Backend::item1'))); $this->_model->getResult(); }
/** * Initialize menu object * * @return void */ protected function _initMenu() { if (!$this->_menu) { /* @var $director Mage_Backend_Model_Menu_Director_Dom */ $director = $this->_appConfig->getModelInstance('Mage_Backend_Model_Menu_Director_Dom', array('config' => $this->_getDom(), 'factory' => $this->_appConfig, 'logger' => $this->_logger)); $director->buildMenu($this->_menuBuilder); $this->_menu = $this->_menuBuilder->getResult(); $this->_eventManager->dispatch('backend_menu_load_after', array('menu' => $this->_menu)); } }
public function testGetMenuGenericExceptionIsNotLogged() { $this->_configMenuMock->expects($this->any())->method('getMergedConfig')->will($this->returnValue($this->_domDocumentMock)); $this->_logger->expects($this->never())->method('logException'); $this->_builderMock->expects($this->exactly(1))->method('getResult')->will($this->throwException(new Exception())); try { $this->_model->getMenu(); } catch (Exception $e) { return; } $this->fail("Generic Exception was not throwed"); }
public function setUp() { $this->_appConfigMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false); $this->_appConfigMock->expects($this->any())->method('getModelInstance')->will($this->returnCallback(array($this, 'getModelInstance'))); $this->_cacheInstanceMock = $this->getMock('Mage_Core_Model_Cache', array(), array(), '', false); $this->_directorDomMock = $this->getMock('Mage_Backend_Model_Menu_Director_Dom', array(), array(), '', false); $this->_menuFactoryMock = $this->getMock('Mage_Backend_Model_Menu_Factory', array(), array(), '', false); $this->_configMenuMock = $this->getMock('Mage_Backend_Model_Menu_Config_Menu', array(), array(), '', false); $this->_domDocumentMock = $this->getMock('DOMDocument', array(), array(), '', false); $this->_eventManagerMock = $this->getMock('Mage_Core_Model_Event_Manager'); $this->_logger = $this->getMock('Mage_Backend_Model_Menu_Logger'); $this->_menuMock = $this->getMock('Mage_Backend_Model_Menu', array(), array(), '', false); $this->_menuBuilderMock = $this->getMock('Mage_Backend_Model_Menu_Builder', array(), array(), '', false); $this->_menuFactoryMock->expects($this->any())->method('getMenuInstance')->will($this->returnValue($this->_menuMock)); $this->_model = new Mage_Backend_Model_Menu_Config(array('appConfig' => $this->_appConfigMock, 'cache' => $this->_cacheInstanceMock, 'eventManager' => $this->_eventManagerMock, 'menuFactory' => $this->_menuFactoryMock, 'logger' => $this->_logger)); }
/** * * @param Mage_Backend_Model_Menu_Builder $builder * @throws InvalidArgumentException if invalid builder object * @return Mage_Backend_Model_Menu_DirectorAbstract */ public function buildMenu(Mage_Backend_Model_Menu_Builder $builder) { foreach ($this->getExtractedData() as $data) { $command = $this->_getCommand($data); $builder->processCommand($command); } return $this; }