/** * @see SugarView::getMenu() */ public function getMenu($module = null) { global $mod_strings, $current_language; if (empty($module)) { $module = $_REQUEST['import_module']; } $old_mod_strings = $mod_strings; $mod_strings = return_module_language($current_language, $module); $returnMenu = parent::getMenu($module); $mod_strings = $old_mod_strings; return $returnMenu; }
/** * @ticket 43497 */ public function testMenuExistsCanFindModuleMenuAndModuleExtMenu() { // Create module menu if ($fh = @fopen("modules/{$this->_moduleName}/Menu.php", 'w+')) { $string = <<<EOQ <?php \$module_menu[]=Array("index.php?module=Import&action=foo&import_module=Accounts&return_module=Accounts&return_action=index","Foo","Foo", 'Accounts'); ?> EOQ; fputs($fh, $string); fclose($fh); } // Create module ext menu sugar_mkdir("custom/modules/{$this->_moduleName}/Ext/Menus/", null, true); if ($fh = @fopen("custom/modules/{$this->_moduleName}/Ext/Menus/menu.ext.php", 'w+')) { $string = <<<EOQ <?php \$module_menu[]=Array("index.php?module=Import&action=bar&import_module=Accounts&return_module=Accounts&return_action=index","Foo","Foo", 'Accounts'); ?> EOQ; fputs($fh, $string); fclose($fh); } $view = new SugarView(); $module_menu = $view->getMenu($this->_moduleName); $found_custom_menu = false; $found_custom_menu_twice = false; $found_menu = false; $found_menu_twice = false; foreach ($module_menu as $key => $menu_entry) { foreach ($menu_entry as $id => $menu_item) { if (preg_match('/action=foo/', $menu_item)) { if ($found_menu) { $found_menu_twice = true; } $found_menu = true; } if (preg_match('/action=bar/', $menu_item)) { if ($found_custom_menu) { $found_custom_menu_twice = true; } $found_custom_menu = true; } } } $this->assertTrue($found_menu, "Assert that menu was detected"); $this->assertFalse($found_menu_twice, "Assert that menu item wasn't duplicated"); $this->assertTrue($found_custom_menu, "Assert that custom menu was detected"); $this->assertFalse($found_custom_menu_twice, "Assert that custom menu item wasn't duplicated"); }
public function testgetMenu() { //error_reporting(E_ALL); $SugarView = new SugarView(); //execute the method and check if it works and throws an exception if no module is provided //it creates memory Fatal errors which causes PHPunit to crash so we will skip this scenario /* try { //check first with invalid value and test if it throws an exception $menu = $SugarView->getMenu(); //$this->assertTrue(is_array($menu)); } catch (Exception $e) { $this->assertTrue(TRUE); //$this->fail(); } */ //check with valid value and check if it returns an array. $menu = $SugarView->getMenu('Users'); $this->assertTrue(is_array($menu)); }