コード例 #1
0
ファイル: resultsReqs.php プロジェクト: mokal/DCN_TestLink
     $value = 0;
     if ($total_count) {
         $percentage = 100 / $total_count * $count;
         $percentage_string = comment_percentage($percentage) . " ({$count}/{$total_count})";
         $value = $percentage_string;
         // if status is not "not run", add it to progress percentage
         if ($code != $status_code_map['not_run']) {
             $progress_percentage += $percentage;
         }
     } else {
         $value = $labels['na'];
     }
     $single_row[] = $value;
 }
 // complete progress
 $single_row[] = $total_count ? comment_percentage($progress_percentage) : $labels['na'];
 // show all linked tcversions incl exec result
 $linked_tcs_with_status = '';
 if (count($req_info['linked_testcases']) > 0) {
     foreach ($req_info['linked_testcases'] as $testcase) {
         $tc_id = $testcase['id'];
         $status = $status_code_map['not_run'];
         if (isset($testcases[$tc_id]['exec_status'])) {
             $status = $testcases[$tc_id]['exec_status'];
         }
         $colored_status = '<span class="' . $eval_status_map[$status]['css_class'] . '">[' . $eval_status_map[$status]['label'] . ']</span>';
         $tc_name = $prefix . $testcase['tc_external_id'] . $title_sep . $testcase['name'];
         $exec_history_link = "<a href=\"javascript:openExecHistoryWindow({$tc_id});\">" . "<img title=\"{$labels['execution_history']}\" " . " src=\"{$images['history_small']}\" /></a> ";
         $edit_link = "<a href=\"javascript:openTCEditWindow({$tc_id});\">" . "<img title=\"{$labels['design']}\" src=\"{$images['edit_icon']}\" /></a> ";
         $exec_link = "";
         if (isset($testcases[$tc_id]['exec_status']) && $testcases[$tc_id]['exec_status'] != $status_code_map['not_run']) {
コード例 #2
0
function build_rows($args, $status_code_map, $tproject_mgr, $req_spec_map, $req_mgr, $edit_icon, $glue_char, $charset, $req_cfg, $labels, &$eval_status_map, $glue_char_tc, $testcases, $exec_img, $history_icon)
{
    // data for rows
    $rows = array();
    $prefix = $tproject_mgr->getTestCasePrefix($args->tproject_id);
    foreach ($req_spec_map as $req_spec_id => $req_spec_info) {
        // build the evaluation data string and attache it to req spec name for table group feature
        $req_spec_description = build_req_spec_description($eval_status_map, $req_spec_info, $req_cfg->external_req_management, $labels);
        foreach ($req_spec_info['requirements'] as $req_id => $req_info) {
            $single_row = array();
            // first column (grouped, not shown) is req spec information
            $path = $req_mgr->tree_mgr->get_path($req_info['srs_id']);
            foreach ($path as $key => $val) {
                $path[$key] = $val['name'];
            }
            $path = implode("/", $path);
            $single_row[] = htmlentities($path, ENT_QUOTES, $charset) . $req_spec_description;
            // create the linked title to display
            $title = htmlentities($req_info['req_doc_id'], ENT_QUOTES, $charset) . $glue_char . htmlentities($req_info['title'], ENT_QUOTES, $charset);
            $edit_link = "<a href=\"javascript:openLinkedReqWindow({$args->tproject_id}," . $req_id . ")\">" . "<img title=\"{$labels['requirement']}\" src=\"{$edit_icon}\" /></a> ";
            $link = $edit_link . $title;
            $single_row[] = $link;
            // version number
            $version_num = $req_info['version'];
            $padded_version_num = sprintf("%010d", $version_num);
            $version_str = "<!-- {$padded_version_num} -->{$version_num}";
            $single_row[] = $version_str;
            // coverage
            if ($req_cfg->expected_coverage_management) {
                $expected_coverage = $req_info['expected_coverage'];
                $current = count($req_info['linked_testcases']);
                if ($expected_coverage) {
                    $coverage_string = "<!-- -1 -->" . $labels['na'] . " ({$current}/0)";
                    if ($expected_coverage) {
                        $percentage = 100 / $expected_coverage * $current;
                        $coverage_string = comment_percentage($percentage) . " ({$current}/{$expected_coverage})";
                    }
                    $single_row[] = $coverage_string;
                } else {
                    // no expected value, no percentage, just absolute number
                    $single_row[] = $current;
                }
            }
            $eval = $req_info['evaluation'];
            // BUGID 4205 - add the count of each evaluation
            $eval_status_map[$eval]['count'] += 1;
            $colored_eval = '<span class="' . $eval_status_map[$eval]['css_class'] . '">' . $eval_status_map[$eval]['label'] . '</span>';
            $single_row[] = $colored_eval;
            // BUGID 4034
            $single_row[] = isset($labels['req_types'][$req_info['type']]) ? $labels['req_types'][$req_info['type']] : sprintf($labels['no_label_for_req_type'], $req_info['type']);
            $single_row[] = $labels['status'][$req_info['status']];
            // add count and percentage for each possible status and progress
            $progress_percentage = 0;
            $total_count = $req_cfg->expected_coverage_management && $expected_coverage > 0 ? $expected_coverage : $req_info['tc_counters']['total'];
            foreach ($status_code_map as $status => $code) {
                $count = isset($req_info['tc_counters'][$code]) ? $req_info['tc_counters'][$code] : 0;
                $value = 0;
                if ($total_count) {
                    $percentage = 100 / $total_count * $count;
                    $percentage_string = comment_percentage($percentage) . " ({$count}/{$total_count})";
                    $value = $percentage_string;
                    // if status is not "not run", add it to progress percentage
                    if ($code != $status_code_map['not_run']) {
                        $progress_percentage += $percentage;
                    }
                } else {
                    $value = $labels['na'];
                }
                $single_row[] = $value;
            }
            // complete progress
            $single_row[] = $total_count ? comment_percentage($progress_percentage) : $labels['na'];
            $linked_tcs_with_status = '';
            if (count($req_info['linked_testcases']) > 0) {
                foreach ($req_info['linked_testcases'] as $testcase) {
                    $tc_id = $testcase['id'];
                    $status = $status_code_map['not_run'];
                    if (isset($testcases[$tc_id]['exec_status'])) {
                        $status = $testcases[$tc_id]['exec_status'];
                    }
                    $colored_status = '<span class="' . $eval_status_map[$status]['css_class'] . '">[' . $eval_status_map[$status]['label'] . ']</span>';
                    $tc_name = $prefix . $glue_char_tc . $testcase['tc_external_id'] . $glue_char . $testcase['name'];
                    $exec_history_link = "<a href=\"javascript:openExecHistoryWindow({$tc_id});\">" . "<img title=\"{$labels['execution_history']}\" src=\"{$history_icon}\" /></a> ";
                    $edit_link = "<a href=\"javascript:openTCEditWindow({$args->tproject_id},{$tc_id});\">" . "<img title=\"{$labels['design']}\" src=\"{$edit_icon}\" /></a> ";
                    $exec_link = "";
                    if (isset($testcases[$tc_id]['exec_status'])) {
                        $exec_link = "<a href=\"javascript:openExecutionWindow(" . "{$tc_id}, {$testcases[$tc_id]['tcversion_number']}, {$testcases[$tc_id]['exec_on_build']} , " . "{$testcases[$tc_id]['exec_on_tplan']}, {$testcases[$tc_id]['platform_id']});\">" . "<img title=\"{$labels['execution']}\" src=\"{$exec_img}\" /></a> ";
                    }
                    $linked_tcs_with_status .= "{$exec_history_link} {$edit_link} {$exec_link} {$colored_status} {$tc_name}<br>";
                }
            } else {
                $linked_tcs_with_status = $labels['no_linked_tcs'];
            }
            $single_row[] = $linked_tcs_with_status;
            $rows[] = $single_row;
        }
    }
    return $rows;
}