list($columns, $sortByColumn) = getColumnsDefinition($optColumns); $rows = array(); foreach ($tcase_set as $tcase_platform) { foreach ($tcase_platform as $tcase) { $current_row = array(); $tcase_id = $tcase['testcase_id']; $tcversion_id = $tcase['tcversion_id']; $current_row[] = htmlspecialchars($tcase['login']); $current_row[] = htmlspecialchars($tcase['tcase_full_path']); // create linked icons $exec_history_link = "<a href=\"javascript:openExecHistoryWindow({$tcase_id});\">" . "<img title=\"{$l18n['execution_history']}\" src=\"{$history_img}\" /></a> "; $edit_link = "<a href=\"javascript:openTCEditWindow({$gui->tproject_id},{$tcase_id});\">" . "<img title=\"{$l18n['design']}\" src=\"{$edit_img}\" /></a> "; $current_row[] = "<!-- " . sprintf("%010d", $tcase['tc_external_id']) . " -->" . $exec_history_link . $edit_link . htmlspecialchars($tcase['prefix']) . $gui->glueChar . $tcase['tc_external_id'] . " : " . htmlspecialchars($tcase['name']) . sprintf($l18n['tcversion_indicator'], $tcase['version']); if ($args->priority_enabled) { //BUGID 4418 - clean up priority usage $current_row[] = "<!-- " . $tcase['priority'] . " -->" . $priority[priority_to_level($tcase['priority'])]; } $last_execution = $tcase_mgr->get_last_execution($tcase_id, $tcversion_id, $tplan_id, $tcase['build_id'], $tcase['platform_id']); $status = $last_execution[$tcversion_id]['status']; if (!$status) { $status = $map_status_code['not_run']; } $current_row[] = array("value" => $status, "text" => $map_statuscode_css[$status]['translation'], "cssClass" => $map_statuscode_css[$status]['css_class']); $current_row[] = $tcase['creation_ts']; $current_row[] = $tcase['modification_ts']; // add this row to the others $rows[] = $current_row; } } /* different table id for different reports: * - Assignment Overview if $args->show_all_users is set
/** * Function returns prioritized test case counter (in Test Plan) * * @return array with three priority counters */ public function getPrioritizedTestCaseCounters($tplanID) { $output = array(HIGH => 0, MEDIUM => 0, LOW => 0); /** @TODO - REFACTOR IS OUT OF STANDARD MAGIC NUMBERS */ for ($urgency = 1; $urgency <= 3; $urgency++) { for ($importance = 1; $importance <= 3; $importance++) { // get total count of related TCs $sql = "SELECT COUNT( TPTCV.id ) FROM {$this->tables['testplan_tcversions']} TPTCV " . " JOIN {$this->tables['tcversions']} TCV ON TPTCV.tcversion_id = TCV.id " . " WHERE TPTCV.testplan_id = " . $tplanID . " AND TCV.importance={$importance} AND TPTCV.urgency={$urgency}"; $tmpResult = $this->db->fetchOneValue($sql); // clean up priority usage $priority = priority_to_level($urgency * $importance); $output[$priority] = $output[$priority] + $tmpResult; } } return $output; }
if ($args->urgency != OFF) { $gui->user_feedback['type'] = $tplan_mgr->setSuiteUrgency($args->tplan_id, $args->node_id, $args->urgency); $msg_key = $gui->user_feedback['type'] == OK ? "feedback_urgency_ok" : "feedback_urgency_fail"; $gui->user_feedback['message'] = lang_get($msg_key); } // Set urgency for individual testcases if (isset($args->urgency_tc)) { foreach ($args->urgency_tc as $id => $urgency) { $tplan_mgr->setTestUrgency($args->tplan_id, $id, $urgency); } } // get the current urgency for child test cases $gui->listTestCases = $tplan_mgr->getSuiteUrgency($args->tplan_id, $args->node_id, $args->tproject_id); // get priority for each test case foreach ($gui->listTestCases as $id => $tcase) { $gui->listTestCases[$id]['priority'] = priority_to_level($tcase['priority']); } $smarty = new TLSmarty(); $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $templateCfg->default_template); /* function: init_args(&$dbHandler) args: - returns: object with user input. */ function init_args(&$dbHandler) { $_REQUEST = strings_stripSlashes($_REQUEST); $args = new stdClass(); $args->show_help = isset($_REQUEST['level']) && $_REQUEST['level'] == 'testproject';
/** * Convert a given urgency and importance to a priority level using * threshold values in $tlCfg->priority_levels. * * @param mixed $urgency Urgency of the testcase. * If this is the only parameter given then interpret it as * $urgency*$importance. * @param mixed $importance Importance of the testcase. (Optional) * * @return int HIGH, MEDIUM or LOW */ public function urgencyImportanceToPriorityLevel($urgency, $importance = null) { $urgencyImportance = intval($urgency) * (is_null($importance) ? 1 : intval($importance)); return priority_to_level($urgencyImportance); }
/** * * * @internal revisions: * 20100726 - asimon - BUGID 3628 */ function addLinkedVersionsInfo($testCaseSet, $a_tsuite_idx, &$out, &$linked_items) { $optionalIntegerFields = array('user_id', 'feature_id', 'linked_by'); $result = array('spec_view' => array(), 'num_tc' => 0, 'has_linked_items' => 0); $pivot_id = -1; foreach ($testCaseSet as $the_k => $testCase) { $tc_id = $testCase['testcase_id']; // Needed when having multiple platforms if ($pivot_id != $tc_id) { $pivot_id = $tc_id; $result['num_tc']++; } $parent_idx = $a_tsuite_idx[$tc_id]; // Reference to make code reading more human friendly $outRef =& $out[$parent_idx]['testcases'][$tc_id]; if ($testCase['active'] == 1 && !is_null($out[$parent_idx])) { if (!isset($outRef['execution_order'])) { // Doing this I will set order for test cases that still are not linked. // But Because I loop over all version (linked and not) if I always write, // will overwrite right execution order of linked tcversion. // // N.B.: // As suggested by Martin Havlat order will be set to external_id * 10 $outRef['execution_order'] = $testCase['node_order'] * 10; } $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 1; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; if (!isset($outRef['tcversions_qty'])) { $outRef['tcversions_qty'] = 0; } $outRef['tcversions_qty']++; } if (!is_null($linked_items)) { foreach ($linked_items as $linked_testcase) { if ($linked_testcase[0]['tc_id'] == $testCase['testcase_id'] && $linked_testcase[0]['tcversion_id'] == $testCase['id']) { // This can be written only once no matter platform qty if (!isset($outRef['tcversions'][$testCase['id']])) { $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 0; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; } $exec_order = isset($linked_testcase[0]['execution_order']) ? $linked_testcase[0]['execution_order'] : 0; $outRef['execution_order'] = $exec_order; // 20090625 - Eloff // 20100726 - BUGID 3628 - asimon - missing [0] in condition // caused missing priority in GUI if (isset($linked_testcase[0]['priority'])) { $outRef['priority'] = priority_to_level($linked_testcase[0]['priority']); } $outRef['linked_version_id'] = $testCase['id']; $out[$parent_idx]['write_buttons'] = 'yes'; $out[$parent_idx]['linked_testcase_qty']++; $result['has_linked_items'] = 1; foreach ($linked_testcase as $item) { if (intval($item['executed'])) { $outRef['executed'][$item['platform_id']] = 'yes'; } if (isset($item['linked_ts'])) { $outRef['linked_ts'][$item['platform_id']] = $item['linked_ts']; } foreach ($optionalIntegerFields as $fieldKey) { if (isset($item[$fieldKey])) { $outRef[$fieldKey][$item['platform_id']] = intval($item[$fieldKey]); } } } break; } } } } //foreach($tcase_set if (!is_null($out[0])) { $result['spec_view'] = $out; } return $result; }
/** * Returns priority (urgency * importance) as HIGH, MEDUIM or LOW depending on value * * * @param integer $testplan_id Test Plan ID * @param $filters: optional, map with following keys * @param $options: optional, map with following keys * * @return */ public function getPriority($testplan_id, $filters = null, $options = null) { $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; $rs = null; $my = array('filters' => array('platform_id' => null, 'tcversion_id' => null), 'options' => array('details' => 'tcversion')); $my['filters'] = array_merge($my['filters'], (array) $filters); $my['options'] = array_merge($my['options'], (array) $options); $sqlFilter = ''; if (!is_null($my['filters']['platform_id'])) { $sqlFilter .= " AND TPTCV.platform_id = {$my['filters']['platform_id']} "; } if (!is_null($my['filters']['tcversion_id'])) { $dummy = implode(',', (array) $my['filters']['tcversion_id']); $sqlFilter .= " AND TPTCV.tcversion_id IN ({$dummy}) "; } $sql = "/* {$debugMsg} */ "; $sql .= " SELECT (urgency * importance) AS priority, " . " urgency,importance, " . LOW . " AS priority_level, TPTCV.tcversion_id %CLAUSE%" . " FROM {$this->tables['testplan_tcversions']} TPTCV " . " JOIN {$this->tables['tcversions']} TCV ON TPTCV.tcversion_id = TCV.id " . " WHERE TPTCV.testplan_id = {$testplan_id} {$sqlFilter}"; switch ($my['options']['details']) { case 'tcversion': $sql = str_ireplace("%CLAUSE%", "", $sql); $rs = $this->db->fetchRowsIntoMap($sql, 'tcversion_id'); break; case 'platform': $sql = str_ireplace("%CLAUSE%", ", TPTCV.platform_id", $sql); $rs = $this->db->fetchMapRowsIntoMap($sql, 'tcversion_id', 'platform_id'); break; } if (!is_null($rs)) { $key2loop = array_keys($rs); switch ($my['options']['details']) { case 'tcversion': foreach ($key2loop as $key) { $rs[$key]['priority_level'] = priority_to_level($rs[$key]['priority']); } break; case 'platform': foreach ($key2loop as $key) { $platformSet = array_keys($rs[$key]); foreach ($platformSet as $platform_id) { $rs[$key][$platform_id]['priority_level'] = priority_to_level($rs[$key][$platform_id]['priority']); } } break; } // switch } // !is_null return $rs; }
/** * Returns priority (urgency * importance) as HIGH, MEDUIM or LOW depending on value * @return HIGH, MEDIUM or LOW */ public function getPriority($tplan_id, $tcversion_id) { $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; $sql = "/* {$debugMsg} */ "; $sql .= " SELECT (urgency * importance) AS priority " . " FROM {$this->tables['testplan_tcversions']} TPTCV " . " JOIN {$this->tables['tcversions']} TCV ON TPTCV.tcversion_id = TCV.id " . " WHERE TPTCV.testplan_id = {$tplan_id} AND TPTCV.tcversion_id = {$tcversion_id}"; $prio = $this->db->fetchOneValue($sql); //BUGID 4418 - clean up priority usage return priority_to_level($prio); }
/** * VERY IMPORTANT NOTICE * * You can be a little bit confused regarding What will be returned on 'testcases' =>[]['tcversions'] * You will see JUST ON tcversion with active status = 0, ONLY if the version is LINKED to test plan. * Otherwise you will get ONLY ACTIVE test case versions. * * * @internal revisions: */ function addLinkedVersionsInfo($testCaseVersionSet, $a_tsuite_idx, &$out, &$linked_items, $opt = null) { $my['opt'] = array('useOptionalArrayFields' => false); $my['opt'] = array_merge($my['opt'], (array) $opt); $tcStatus2exclude = config_get('tplanDesign')->hideTestCaseWithStatusIn; $optionalIntegerFields = array('feature_id', 'linked_by'); $optionalArrayFields = array('user_id'); $result = array('spec_view' => array(), 'num_tc' => 0, 'has_linked_items' => 0); $pivot_id = -1; $firstElemIDX = key($out); foreach ($testCaseVersionSet as $the_k => $testCase) { $tc_id = $testCase['testcase_id']; // Needed when having multiple platforms if ($pivot_id != $tc_id) { $pivot_id = $tc_id; $result['num_tc']++; } $parent_idx = $a_tsuite_idx[$tc_id]; // Reference to make code reading more human friendly $outRef =& $out[$parent_idx]['testcases'][$tc_id]; // Is not clear (need explanation) why we process in this part ONLY ACTIVE // also we need to explain !is_null($out[$parent_idx]) // if ($testCase['active'] == 1 && !isset($tcStatus2exclude[$testCase['status']]) && !is_null($out[$parent_idx])) { if (!isset($outRef['execution_order'])) { // Doing this I will set order for test cases that still are not linked. // But Because I loop over all versions (linked and not) if I always write, // will overwrite right execution order of linked tcversion. // // N.B.: // As suggested by Martin Havlat order will be set to external_id * 10 $outRef['execution_order'] = $testCase['node_order'] * 10; } $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 1; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; $outRef['importance'][$testCase['id']] = $testCase['importance']; if (!isset($outRef['tcversions_qty'])) { $outRef['tcversions_qty'] = 0; } $outRef['tcversions_qty']++; } if (!is_null($linked_items)) { foreach ($linked_items as $linked_testcase) { $target = current($linked_testcase); if ($target['tc_id'] == $testCase['testcase_id'] && $target['tcversion_id'] == $testCase['id']) { // This can be written only once no matter platform qty if (!isset($outRef['tcversions'][$testCase['id']])) { $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 0; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; $outRef['importance'][$testCase['id']] = $testCase['importance']; } $outRef['execution_order'] = isset($target['execution_order']) ? $target['execution_order'] : 0; if (isset($target['priority'])) { $outRef['priority'] = priority_to_level($target['priority']); } $outRef['linked_version_id'] = $testCase['id']; $out[$parent_idx]['write_buttons'] = 'yes'; $out[$parent_idx]['linked_testcase_qty']++; $result['has_linked_items'] = 1; foreach ($linked_testcase as $item) { // 20120714 - franciscom - need t check if this info is needed. if (isset($item['executed']) && intval($item['executed']) > 0 || isset($item['exec_id']) && intval($item['exec_id']) > 0) { $outRef['executed'][$item['platform_id']] = 'yes'; } if (isset($item['linked_ts'])) { $outRef['linked_ts'][$item['platform_id']] = $item['linked_ts']; } foreach ($optionalIntegerFields as $fieldKey) { if (isset($item[$fieldKey])) { $outRef[$fieldKey][$item['platform_id']] = intval($item[$fieldKey]); } } // this logic has been created to cope with multiple tester assignment if ($my['opt']['useOptionalArrayFields']) { foreach ($optionalArrayFields as $fieldKey) { // We have issues when no user is assigned because is if (is_array($item[$fieldKey])) { // this seems to be the path we follow when trying to work on test suite $outRef[$fieldKey][$item['platform_id']] = $item[$fieldKey]; } else { // this seems to be the path we follow when trying to work on SINGLE test case $outRef[$fieldKey][$item['platform_id']][] = intval($item[$fieldKey]); } } } } break; } } } } //foreach // Again DAMM 0!! if (!is_null($out[$firstElemIDX])) { $result['spec_view'] = $out; } return $result; }
/** * Convert a given urgency and importance to a priority level using * threshold values in $tlCfg->priority_levels. * * @param mixed $urgency Urgency of the testcase. * If this is the only parameter given then interpret it as * $urgency*$importance. * @param mixed $importance Importance of the testcase. (Optional) * * @return int HIGH, MEDIUM or LOW */ public function urgencyImportanceToPriorityLevel($urgency, $importance = null) { $urgencyImportance = intval($urgency) * (is_null($importance) ? 1 : intval($importance)); //BUGID 4418 - clean up priority usage return priority_to_level($urgencyImportance); }
/** * VERY IMPORTANT NOTICE * * You can be a little bit confused regarding What will be returned on 'testcases' =>[]['tcversions'] * You will see JUST ON tcversion with active status = 0, ONLY if the version is LINKED to test plan. * Otherwise you will get ONLY ACTIVE test case versions. * * * @internal revisions: */ function addLinkedVersionsInfo($testCaseVersionSet, $a_tsuite_idx, &$out, &$linked_items) { $optionalIntegerFields = array('user_id', 'feature_id', 'linked_by'); $result = array('spec_view' => array(), 'num_tc' => 0, 'has_linked_items' => 0); $pivot_id = -1; foreach ($testCaseVersionSet as $the_k => $testCase) { $tc_id = $testCase['testcase_id']; // Needed when having multiple platforms if ($pivot_id != $tc_id) { $pivot_id = $tc_id; $result['num_tc']++; } $parent_idx = $a_tsuite_idx[$tc_id]; // Reference to make code reading more human friendly $outRef =& $out[$parent_idx]['testcases'][$tc_id]; // Is not clear (need explanation) why we process in this part ONLY ACTIVE // also we need to explain !is_null($out[$parent_idx]) // if ($testCase['active'] == 1 && !is_null($out[$parent_idx])) { if (!isset($outRef['execution_order'])) { // Doing this I will set order for test cases that still are not linked. // But Because I loop over all version (linked and not) if I always write, // will overwrite right execution order of linked tcversion. // // N.B.: // As suggested by Martin Havlat order will be set to external_id * 10 $outRef['execution_order'] = $testCase['node_order'] * 10; } $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 1; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; $outRef['importance'][$testCase['id']] = $testCase['importance']; if (!isset($outRef['tcversions_qty'])) { $outRef['tcversions_qty'] = 0; } $outRef['tcversions_qty']++; } if (!is_null($linked_items)) { foreach ($linked_items as $linked_testcase) { $target = current($linked_testcase); if ($target['tc_id'] == $testCase['testcase_id'] && $target['tcversion_id'] == $testCase['id']) { // This can be written only once no matter platform qty if (!isset($outRef['tcversions'][$testCase['id']])) { $outRef['tcversions'][$testCase['id']] = $testCase['version']; $outRef['tcversions_active_status'][$testCase['id']] = 0; $outRef['external_id'] = $testCase['tc_external_id']; $outRef['tcversions_execution_type'][$testCase['id']] = $testCase['execution_type']; $outRef['importance'][$testCase['id']] = $testCase['importance']; } $outRef['execution_order'] = isset($target['execution_order']) ? $target['execution_order'] : 0; if (isset($target['priority'])) { $outRef['priority'] = priority_to_level($target['priority']); } $outRef['linked_version_id'] = $testCase['id']; $out[$parent_idx]['write_buttons'] = 'yes'; $out[$parent_idx]['linked_testcase_qty']++; $result['has_linked_items'] = 1; foreach ($linked_testcase as $item) { // 20120714 - franciscom - need t check if this info is needed. if (isset($item['executed']) && intval($item['executed']) > 0 || isset($item['exec_id']) && intval($item['exec_id']) > 0) { $outRef['executed'][$item['platform_id']] = 'yes'; } if (isset($item['linked_ts'])) { $outRef['linked_ts'][$item['platform_id']] = $item['linked_ts']; } foreach ($optionalIntegerFields as $fieldKey) { if (isset($item[$fieldKey])) { $outRef[$fieldKey][$item['platform_id']] = intval($item[$fieldKey]); } } } break; } } } } //foreach if (!is_null($out[0])) { $result['spec_view'] = $out; } return $result; }
$templateCfg = templateConfiguration(); $tplan_mgr = new testPlanUrgency($db); $gui = initializeGui($args, $tplan_mgr->tree_manager); if ($args->urgency != OFF || isset($args->urgency_tc)) { $gui->user_feedback = doProcess($args, $tplan_mgr); } // get the current urgency for child test cases $context = new stdClass(); $context->tplan_id = $args->tplan_id; $context->tsuite_id = $args->node_id; $context->tproject_id = $args->tproject_id; $context->platform_id = $args->platform_id; $gui->listTestCases = $tplan_mgr->getSuiteUrgency($context, array('build4testers' => $args->build4testers), array('testcases' => $args->testCaseSet)); foreach ($gui->listTestCases as $tcversion_id => $tcaseSet) { foreach ($tcaseSet as $idx => $tcase) { $gui->listTestCases[$tcversion_id][$idx]['priority'] = priority_to_level($tcase['priority']); } } $smarty = new TLSmarty(); $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $templateCfg->default_template); /* function: init_args() args: - returns: object with user input. */ function init_args() { $_REQUEST = strings_stripSlashes($_REQUEST); $args = new stdClass();