예제 #1
0
 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
  * - Test Cases assigned to user if $args->build_id > 0
  * - Test Cases assigned to me else
$result = $tcase_mgr->{$fname}($pathName);
new dBug($result);
die;
$tcase_id = 318;
$tplan_id = 389;
$build_id = 21;
$platform_id = 5;
$version_id = testcase::ALL_VERSIONS;
// $options = array('getNoExecutions' => true);
$options = null;
// function get_last_execution($id,$version_id,$tplan_id,$build_id,$platform_id,$options=null)
echo "<pre> testcase - get_last_execution(\$id,\$version_id,\$tplan_id,\$build_id,\$platform_id\$options=null)";
echo "</pre>";
echo "<pre>            get_last_execution({$tcase_id},{$version_id},{$tplan_id},{$build_id},{$platform_id},{$options})";
echo "</pre>";
$last_execution = $tcase_mgr->get_last_execution($tcase_id, $version_id, $tplan_id, $build_id, $platform_id, $options);
new dBug($last_execution);
die;
$tcase_id = 4;
echo "<pre> testcase - get_by_id(\$id,\$version_id = TC_ALL_VERSIONS, \$active_status='ALL',\$open_status='ALL')";
echo "</pre>";
echo "<pre>            get_by_id({$tcase_id})";
echo "</pre>";
$tcase_info = $tcase_mgr->get_by_id($tcase_id);
new dBug($tcase_info);
$set_of_tcase_id = array(4, 6);
echo "<pre>            get_by_id({$set_of_tcase_id})";
echo "</pre>";
$set_of_tcase_info = $tcase_mgr->get_by_id($set_of_tcase_id);
new dBug($set_of_tcase_info);
$tcase_name = 'Configuration';
예제 #3
0
function getLastExecutions(&$db, $tcaseSet, $tplanId)
{
    $execMap = array();
    if (sizeof($tcaseSet)) {
        $tcase_mgr = new testcase($db);
        $items = array_keys($tcaseSet);
        $path_info = $tcase_mgr->tree_manager->get_full_path_verbose($items);
        $options = array('getNoExecutions' => 1, 'groupByBuild' => 0);
        foreach ($tcaseSet as $tcaseId => $tcInfo) {
            $execMap[$tcaseId] = $tcase_mgr->get_last_execution($tcaseId, $tcInfo['tcversion_id'], $tplanId, testcase::ANY_BUILD, testcase::ANY_PLATFORM, $options);
            unset($path_info[$tcaseId][0]);
            // remove test project name
            $path_info[$tcaseId][] = '';
            $execMap[$tcaseId][$tcInfo['tcversion_id']]['tcase_path'] = implode(' / ', $path_info[$tcaseId]);
        }
        unset($tcase_mgr);
    }
    return $execMap;
}
/**
* initialize Gui
*/
function initializeGui(&$db, &$args, $dateFormat)
{
    $gui = new stdClass();
    $gui->glueChar = config_get('testcase_cfg')->glue_character;
    $gui->tproject_id = $args->tproject_id;
    $gui->tproject_name = $args->tproject_name;
    $gui->warning_msg = '';
    $gui->tableSet = null;
    $history_img = TL_THEME_IMG_DIR . "history_small.png";
    $exec_img = TL_THEME_IMG_DIR . "exec_icon.png";
    $edit_img = TL_THEME_IMG_DIR . "edit_icon.png";
    $l18n = init_labels(array('tcversion_indicator' => null, 'goto_testspec' => null, 'version' => null, 'testplan' => null, 'assigned_tc_overview' => null, 'testcases_created_per_user' => null, 'design' => null, 'execution' => null, 'execution_history' => null, 'low_priority' => null, 'medium_priority' => null, 'high_priority' => null));
    $gui->pageTitle = sprintf($l18n['testcases_created_per_user'], $gui->tproject_name);
    $results_config = config_get('results');
    $map_status_code = $results_config['status_code'];
    $map_code_status = $results_config['code_status'];
    $map_status_label = $results_config['status_label'];
    $map_statuscode_css = array();
    foreach ($map_code_status as $code => $status) {
        if (isset($map_status_label[$status])) {
            $label = $map_status_label[$status];
            $map_statuscode_css[$code] = array();
            $map_statuscode_css[$code]['translation'] = lang_get($label);
            $map_statuscode_css[$code]['css_class'] = $map_code_status[$code] . '_text';
        }
    }
    $options = new stdClass();
    // convert starttime to iso format for database usage
    if (isset($args->selected_start_date) && sizeof($args->selected_start_date) > 0) {
        $date_array = split_localized_date($args->selected_start_date[0], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $options->startTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    // convert starttime to iso format for database usage
    if (isset($args->selected_end_date) && sizeof($args->selected_end_date) > 0) {
        $date_array = split_localized_date($args->selected_end_date[0], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $options->endTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    $start_hour = isset($args->start_Hour) ? $args->start_Hour : "00";
    $options->startTime = $options->startTime . " " . $start_hour . ":00:00";
    $end_hour = isset($args->end_Hour) ? $args->end_Hour : "00";
    $options->endTime = $options->endTime . " " . $end_hour . ":59:59";
    $options->mode = 'full_path';
    // TBD: remove it
    $options->tplan_id = $args->tplan_id;
    // used to retrieve test cases from
    $tcase_mgr = new testcase($db);
    $gui->resultSet = $tcase_mgr->get_created_per_user($args->user_id, $args->tproject_id, $options);
    if (!is_null($gui->resultSet)) {
        $tables = tlObjectWithDB::getDBTables(array('nodes_hierarchy'));
        $tplanSet = array_keys($gui->resultSet);
        $sql = "SELECT name,id FROM {$tables['nodes_hierarchy']} " . "WHERE id IN (" . implode(',', $tplanSet) . ")";
        $gui->tplanNames = $db->fetchRowsIntoMap($sql, 'id');
        $optColumns = array('priority' => $args->priority_enabled);
        // For each test case set under a test plan ID, create the rows and columns
        foreach ($gui->resultSet as $tplan_id => $tcase_set) {
            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({$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']);
                    $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:
            $table_id = "tl_table_tc_created_per_user_";
            // Add test plan ID to table ID
            $table_id .= $tplan_id;
            $matrix = new tlExtTable($columns, $rows, $table_id);
            $matrix->title = $l18n['testplan'] . ": " . htmlspecialchars($gui->tplanNames[$tplan_id]['name']);
            // Default grouping by first column, which is user for overview, build otherwise
            $matrix->setGroupByColumnName(lang_get($columns[0]['title_key']));
            // Make table collapsible if more than 1 table is shown and surround by frame
            if (count($tplanSet) > 1) {
                $matrix->collapsible = true;
                $matrix->frame = true;
            }
            // Define toolbar
            $matrix->showToolbar = true;
            $matrix->toolbarExpandCollapseGroupsButton = true;
            $matrix->toolbarShowAllColumnsButton = true;
            $matrix->setSortByColumnName($sortByColumn);
            $matrix->sortDirection = 'DESC';
            $gui->tableSet[$tplan_id] = $matrix;
        }
    }
    return $gui;
}