$opt_etree->hideTestCases = SHOW_TESTCASES; $opt_etree->tc_action_enabled = false; $opt_etree->showTestCaseExecStatus = false; $opt_etree->nodeHelpText = array(); $opt_etree->nodeHelpText['testproject'] = lang_get('gen_test_plan_design_report'); $opt_etree->nodeHelpText['testsuite'] = $opt_etree->nodeHelpText['testproject']; $opt_etree->actionJS['testproject'] = 'TPLAN_PTP'; $opt_etree->actionJS['testsuite'] = 'TPLAN_PTS'; break; default: $opt_etree->hideTestCases = HIDE_TESTCASES; break; } $filters = null; $treeContents = null; list($treeContents, $testcases_to_show) = testPlanTree($db, $rightPaneAction, $args->tproject_id, $args->tproject_name, $args->tplan_id, $testplan_name, $filters, $opt_etree); $gui->ajaxTree = new stdClass(); $gui->ajaxTree->cookiePrefix = "{$args->doc_type}_tplan_id_{$args->tplan_id}_"; $gui->ajaxTree->loadFromChildren = true; $gui->ajaxTree->root_node = $treeContents->rootnode; $gui->ajaxTree->children = trim($treeContents->menustring); if ($gui->ajaxTree->children == '') { $gui->ajaxTree->children = '{}'; // generate valid JSON $gui->ajaxTree->root_node->href = ''; } break; default: tLog("Argument _REQUEST['type'] has invalid value", 'ERROR'); exit; break;
/** * Build the tree menu for generation of JavaScript test case tree. * Depending on mode and user's selections in user interface, * either a completely filtered tree will be build and returned, * or only the minimal necessary data to "lazy load" * the objects in the tree by later Ajax calls. * No return value - all variables will be stored in gui object * which is passed by reference. * * @author Andreas Simon * @param object $gui Reference to GUI object (data will be written to it) */ public function build_tree_menu(&$gui) { $tree_menu = null; $filters = $this->get_active_filters(); $loader = ''; $children = "[]"; $cookie_prefix = ''; // by default, disable drag and drop, then later enable if needed $drag_and_drop = new stdClass(); $drag_and_drop->enabled = false; $drag_and_drop->BackEndUrl = ''; $drag_and_drop->useBeforeMoveNode = FALSE; if (!$this->testproject_mgr) { $this->testproject_mgr = new testproject($this->db); } $tc_prefix = $this->testproject_mgr->getTestCasePrefix($this->args->testproject_id); switch ($this->mode) { case 'plan_mode': // No lazy loading here. $opt_etree = $this->treeOpt[$this->mode]; $filters->show_testsuite_contents = 1; switch ($this->args->feature) { case 'test_urgency': $filters->hide_testcases = 1; // ?? $opt_etree->allow_empty_build = 1; $opt_etree->hideTestCases = 1; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; break; case 'tc_exec_assignment': $filters->hide_testcases = 0; $opt_etree->hideTestCases = 0; $opt_etree->allow_empty_build = 0; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; // TICKET 4905: Test Case Tester Assignment - filters dont work properly // for 'Assigned to' Field // This way we are GOING TO IGNORE SETTING BUILD $opt_etree->buildIDKeyMap = 'filter_result_build'; break; case 'planUpdateTC': $filters->hide_testcases = 0; $opt_etree->hideTestCases = 0; $opt_etree->allow_empty_build = 1; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; break; } list($tree_menu, $testcases_to_show) = testPlanTree($this->db, $gui->menuUrl, $this->args->testproject_id, $this->args->testproject_name, $this->args->testplan_id, $this->args->testplan_name, $filters, $opt_etree); $this->set_testcases_to_show($testcases_to_show); $root_node = $tree_menu->rootnode; $children = $tree_menu->menustring ? $tree_menu->menustring : "[]"; // improved cookiePrefix - all trees in plan mode show test cases // assigned to a specified test plan -> store state for each feature and each project // // usage of wrong values in $this->args->xyz for cookiePrefix // instead of correct values in $filters->setting_xyz $cookie_prefix = $this->args->feature . "_tplan_id_" . $filters->setting_testplan . "_"; break; case 'edit_mode': if ($gui->tree_drag_and_drop_enabled[$this->args->feature]) { $drag_and_drop->enabled = true; $drag_and_drop->BackEndUrl = $this->args->basehref . 'lib/ajax/dragdroptprojectnodes.php'; $drag_and_drop->useBeforeMoveNode = true; } // improved cookiePrefix - // all trees in edit mode show test cases of whole test project // -> store state for each feature and each project $cookie_prefix = $this->args->feature . "_tproject_id_" . $this->args->testproject_id . "_"; if ($this->do_filtering) { // TICKET 4353: added active/inactive filter $ignore_inactive_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; $ignore_active_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; if (isset($filters['filter_active_inactive'])) { if ($filters['filter_active_inactive'] == IGNORE_INACTIVE_TESTCASES) { $ignore_inactive_testcases = IGNORE_INACTIVE_TESTCASES; } if ($filters['filter_active_inactive'] == IGNORE_ACTIVE_TESTCASES) { $ignore_active_testcases = IGNORE_ACTIVE_TESTCASES; } } $options = array('forPrinting' => NOT_FOR_PRINTING, 'hideTestCases' => SHOW_TESTCASES, 'tc_action_enabled' => DO_ON_TESTCASE_CLICK, 'exclude_branches' => null, 'ignore_inactive_testcases' => $ignore_inactive_testcases, 'ignore_active_testcases' => $ignore_active_testcases); $forrest = generateTestSpecTree($this->db, $this->args->testproject_id, $this->args->testproject_name, $gui->menuUrl, $filters, $options); $this->set_testcases_to_show($forrest['leaves']); $tree_menu = $forrest['menu']; $root_node = $tree_menu->rootnode; $children = $tree_menu->menustring ? $tree_menu->menustring : "[]"; } else { $loader = $this->args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$this->args->testproject_id}&" . "tcprefix=" . urlencode($tc_prefix . $this->configuration->tc_cfg->glue_character); $tcase_qty = $this->testproject_mgr->count_testcases($this->args->testproject_id); $root_node = new stdClass(); $root_node->href = "javascript:EP({$this->args->testproject_id})"; $root_node->id = $this->args->testproject_id; $root_node->name = $this->args->testproject_name . " ({$tcase_qty})"; $root_node->wrapOpen = $root_node->wrapClose = ''; $root_node->testlink_node_type = 'testproject'; } break; case 'plan_add_mode': // improved cookiePrefix - // tree in plan_add_mode is only used for add/removed test cases features // and shows all test cases defined within test project, // but as test cases are added to a specified test plan -> store state for each test plan // // usage of wrong values in $this->args->xyz for cookiePrefix instead of correct // values in $filters->setting_xyz $cookie_prefix = "add_remove_tc_tplan_id_{$filters['setting_testplan']}_"; if ($this->do_filtering) { // TICKET 4496: added active/inactive filter // Will be refactored in future versions // $ignore_inactive_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; // $ignore_active_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; // if ($filters['filter_active_inactive'] == IGNORE_INACTIVE_TESTCASES) // { // $ignore_inactive_testcases = IGNORE_INACTIVE_TESTCASES; // } // if ($filters['filter_active_inactive'] == IGNORE_ACTIVE_TESTCASES) // { // $ignore_active_testcases = IGNORE_ACTIVE_TESTCASES; // } // need to be refactored $ignore_inactive_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; $ignore_active_testcases = DO_NOT_FILTER_INACTIVE_TESTCASES; $options = array('forPrinting' => NOT_FOR_PRINTING, 'hideTestCases' => HIDE_TESTCASES, 'tc_action_enabled' => ACTION_TESTCASE_DISABLE, 'viewType' => 'testSpecTreeForTestPlan', 'ignore_inactive_testcases' => $ignore_inactive_testcases, 'ignore_active_testcases' => $ignore_active_testcases); $options['nodeHelpText']['testproject'] = lang_get('right_pane_test_plan_tree'); $options['nodeHelpText']['testsuite'] = lang_get('display_tsuite_contents'); // belongs to treeMenu.inc.php $forrest = generateTestSpecTree($this->db, $this->args->testproject_id, $this->args->testproject_name, $gui->menuUrl, $filters, $options); $tree_menu = $forrest['menu']; $root_node = $tree_menu->rootnode; $children = $tree_menu->menustring ? $tree_menu->menustring : "[]"; } else { $loader = $this->args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$this->args->testproject_id}&show_tcases=0" . "&" . http_build_query(array('tsuiteHelp' => lang_get('display_tsuite_contents'))); $root_node = new stdClass(); $root_node->href = "javascript:EP({$this->args->testproject_id})"; $root_node->id = $this->args->testproject_id; $root_node->name = $this->args->testproject_name; $root_node->wrapOpen = '<span title="' . lang_get('right_pane_test_plan_tree') . '">'; $root_node->wrapClose = '</span>'; $root_node->testlink_node_type = 'testproject'; } break; case 'execution_mode': default: // No lazy loading here. // Filtering is always done in execution mode, no matter if user enters data or not, // since the user should usually never see the whole tree here. $filters->hide_testcases = false; $filters->show_testsuite_contents = $this->configuration->exec_cfg->show_testsuite_contents; $exec_cfg =& $this->configuration->exec_cfg; $opt_etree = new stdClass(); $opt_etree->useCounters = $exec_cfg->enable_tree_testcase_counters; $opt_etree->useColours = new stdClass(); $opt_etree->useColours->testcases = $exec_cfg->enable_tree_testcases_colouring; $opt_etree->useColours->counters = $exec_cfg->enable_tree_counters_colouring; $opt_etree->testcases_colouring_by_selected_build = $exec_cfg->testcases_colouring_by_selected_build; if ($this->mode == 'execution_mode') { $opt_etree->actionJS['testproject'] = 'EXDS'; } list($tree_menu, $testcases_to_show) = execTree($this->db, $gui->menuUrl, array('tproject_id' => $this->args->testproject_id, 'tproject_name' => $this->args->testproject_name, 'tplan_id' => $this->args->testplan_id, 'tplan_name' => $this->args->testplan_name), $filters, $opt_etree); $this->set_testcases_to_show($testcases_to_show); $root_node = $tree_menu->rootnode; $children = $tree_menu->menustring ? $tree_menu->menustring : "[]"; // // improved cookiePrefix - // tree on test execution shows test cases depending on test plan, platform and build. // Because test plan is implicitily given with build -> store state for each (platform-build) // combination // // Usage of wrong values in $this->args->xyz for cookiePrefix // instead of correct values in $filters->setting_xyz // $cookie_prefix = 'test_exec_build_id_' . $filters->setting_build . '_'; if (isset($filters->setting_platform)) { $cookie_prefix .= 'platform_id_' . $filters->setting_platform . '_'; } break; } $gui->tree = $tree_menu; $gui->ajaxTree = new stdClass(); $gui->ajaxTree->loader = $loader; $gui->ajaxTree->root_node = $root_node; $gui->ajaxTree->children = $children; $gui->ajaxTree->cookiePrefix = $cookie_prefix; $gui->ajaxTree->dragDrop = $drag_and_drop; }
function buildTreePlanMode($menuUrl) { // No lazy loading here. $opt_etree = $this->treeOpt[$this->mode]; $filtersObj = new stdClass(); $filtersObj->show_testsuite_contents = 1; switch ($this->args->feature) { case 'test_urgency': $filtersObj->hide_testcases = 1; // @TODO Document Why $opt_etree->allow_empty_build = 1; $opt_etree->hideTestCases = 1; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; break; case 'tc_exec_assignment': $filtersObj->hide_testcases = 0; $opt_etree->hideTestCases = 0; $opt_etree->allow_empty_build = 0; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; // Test Case Tester Assignment - // filters dont work properly for 'Assigned to' Field // This way we are GOING TO IGNORE SETTING BUILD $opt_etree->buildIDKeyMap = 'filter_result_build'; break; case 'planUpdateTC': $filtersObj->hide_testcases = 0; $opt_etree->hideTestCases = 0; $opt_etree->allow_empty_build = 1; $opt_etree->getTreeMethod = 'getLinkedForTesterAssignmentTree'; break; } $ajaxTree = $this->ajaxTreeTemplate(); list($ajaxTree->tree_menu, $testcases_to_show) = testPlanTree($this->db, $menuUrl, $this->args->testproject_id, $this->args->testproject_name, $this->args->testplan_id, $this->args->testplan_name, $filtersObj, $opt_etree); $ajaxTree->root_node = $ajaxTree->tree_menu->rootnode; $ajaxTree->children = $ajaxTree->tree_menu->menustring ? $ajaxTree->tree_menu->menustring : "[]"; $ajaxTree->cookiePrefix = $this->args->feature . "_tplan_id_" . $filtersObj->setting_testplan . "_"; $ajaxTree->filters = $filtersObj; $this->set_testcases_to_show($testcases_to_show); unset($testcases_to_show); return $ajaxTree; }