/**
 * 
 */
function initializeGui(&$dbHandler, $args)
{
    $locale = isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB';
    $localesDateFormat = config_get('locales_date_format');
    $date_format = $localesDateFormat[$locale];
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $gui_open = config_get('gui_separator_open');
    $gui_close = config_get('gui_separator_close');
    $gui->str_option_any = $gui_open . lang_get('any') . $gui_close;
    $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close;
    $gui->tplan_id = $args->tplan_id;
    $gui->tproject_id = $args->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    unset($tplan_mgr);
    $gui->tplan_name = $tplan_info['name'];
    $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id);
    unset($tproject_mgr);
    $gui->tproject_name = $tproject_info['name'];
    $gui->users = new stdClass();
    $gui->users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->users->qty = count($gui->users->items);
    $reports_cfg = config_get('reportsCfg');
    $startDate = strftime($date_format, time() - $reports_cfg->start_date_offset);
    $gui->selected_start_date = $startDate;
    $gui->selected_start_time = $reports_cfg->start_time;
    $gui->selected_end_date = strftime($date_format, time());
    $gui->selected_end_time = null;
    return $gui;
}
function initializeGui(&$dbHandler, $args)
{
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $gui_open = config_get('gui_separator_open');
    $gui_close = config_get('gui_separator_close');
    $gui->str_option_any = $gui_open . lang_get('any') . $gui_close;
    $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close;
    $gui->tplan_id = $args->tplan_id;
    $gui->tproject_id = $args->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $gui->tplan_name = $tplan_info['name'];
    unset($tplan_info);
    $ni = $tplan_mgr->tree_manager->get_node_hierarchy_info($gui->tproject_id);
    $gui->tproject_name = $ni['name'];
    unset($ni);
    $gui->assigned_users = new stdClass();
    $gui->keywords = new stdClass();
    $gui->builds = new stdClass();
    $gui->platforms = new stdClass();
    $gui->testsuites = new stdClass();
    // 20090107 - franciscom
    // Show only users that are able to execute test cases ?
    // What happens if a user that has loose right to execute, but
    // before loosing this right has been assigned some tests, or have executed it?
    //
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION);
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER,
    // 	                                                   array(TL_USER_ANYBODY => $gui->str_option_any,
    //                                                            TL_USER_NOBODY => $gui->str_option_none) );
    //
    $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS);
    $gui->platforms->items = $tplan_mgr->getPlatforms($gui->tplan_id);
    $gui->testsuites->items = $tplan_mgr->getRootTestSuites($gui->tplan_id, $gui->tproject_id, array('output' => 'plain'));
    $gui->keywords->items[0] = $gui->str_option_any;
    if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) {
        $gui->keywords->items += $tplan_keywords_map;
    }
    $key2loop = array('keywords', 'builds', 'platforms', 'testsuites', 'assigned_users');
    foreach ($key2loop as $kx) {
        $gui->{$kx}->qty = count($gui->{$kx}->items);
    }
    $gui->status_code_label = get_status_for_reports_html_options();
    $gui->report_type = $args->format;
    $reports_cfg = config_get('reportsCfg');
    $ldf = config_get('locales_date_format');
    $date_format = $ldf[isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB'];
    $gui->selected_start_date = strftime($date_format, time() - $reports_cfg->start_date_offset);
    $gui->selected_start_time = $reports_cfg->start_time;
    $gui->selected_end_date = strftime($date_format, time());
    $gui->selected_end_time = null;
    return $gui;
}
Пример #3
0
function initializeGui(&$dbHandler, $args)
{
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $gui_open = config_get('gui_separator_open');
    $gui_close = config_get('gui_separator_close');
    $gui->str_option_any = $gui_open . lang_get('any') . $gui_close;
    $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close;
    $gui->tplan_id = $args->tplan_id;
    $gui->tproject_id = $args->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $gui->tplan_name = $tplan_info['name'];
    $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id);
    $gui->tproject_name = $tproject_info['name'];
    $re = new results($dbHandler, $tplan_mgr, $tproject_info, $tplan_info);
    $gui->assigned_users = new stdClass();
    $gui->keywords = new stdClass();
    $gui->builds = new stdClass();
    $gui->testsuites = new stdClass();
    // 20090107 - franciscom
    // Show only users that are able to execute test cases ?
    // What happens if a user that has loose right to execute, but
    // before loosing this right has been assigned some tests, or have executed it?
    //
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION);
    // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER,
    // 	                                                   array(TL_USER_ANYBODY => $gui->str_option_any,
    //                                                            TL_USER_NOBODY => $gui->str_option_none) );
    //
    $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->assigned_users->qty = count($gui->assigned_users->items);
    // BUGID 2012 - franciscom
    $gui->keywords->items[0] = $gui->str_option_any;
    if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) {
        $gui->keywords->items += $tplan_keywords_map;
    }
    $gui->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS);
    $gui->testsuites->items = $re->getTopLevelSuites();
    $gui->keywords->qty = count($gui->keywords->items);
    $gui->builds->qty = count($gui->builds->items);
    $gui->testsuites->qty = count($gui->testsuites->items);
    $gui->status_code_label = get_status_for_reports_html_options();
    $gui->report_type = $args->format;
    $reports_cfg = config_get('reportsCfg');
    $startDate = time() - $reports_cfg->start_date_offset;
    $gui->selected_start_date = $startDate;
    $gui->selected_start_time = $reports_cfg->start_time;
    $gui->selected_end_date = null;
    $gui->selected_end_time = null;
    return $gui;
}
function initializeGuiForInput(&$dbHandler, $argsObj, &$guiObj)
{
    $room = config_get('gui_room');
    $guiObj->str_option_any = sprintf($room, lang_get('any'));
    $guiObj->str_option_none = sprintf($room, lang_get('nobody'));
    $guiObj->users = new stdClass();
    $guiObj->users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $guiObj->str_option_any));
    $dateFormat = config_get('date_format');
    $cfg = config_get('reportsCfg');
    $now = time();
    $guiObj->selected_start_date = strftime($dateFormat, $now - $cfg->start_date_offset);
    $guiObj->selected_start_time = $cfg->start_time;
    $guiObj->selected_end_date = strftime($dateFormat, $now);
    $guiObj->selected_end_time = null;
}
function initializeGui(&$dbHandler, $argsObj, &$tplanMgr, &$tcaseMgr)
{
    $platform_mgr = new tlPlatform($dbHandler, $argsObj->tproject_id);
    $tcase_cfg = config_get('testcase_cfg');
    $gui = new stdClass();
    $gui->platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->usePlatforms = $platform_mgr->platformsActiveForTestplan($argsObj->tplan_id);
    $gui->bulk_platforms = $platform_mgr->getLinkedToTestplanAsMap($argsObj->tplan_id);
    $gui->bulk_platforms[0] = lang_get("all_platforms");
    ksort($gui->bulk_platforms);
    $gui->send_mail = $argsObj->send_mail;
    $gui->send_mail_checked = "";
    if ($gui->send_mail) {
        $gui->send_mail_checked = ' checked="checked" ';
    }
    $gui->glueChar = $tcase_cfg->glue_character;
    if ($argsObj->level != 'testproject') {
        $gui->testCasePrefix = $tcaseMgr->tproject_mgr->getTestCasePrefix($argsObj->tproject_id);
        $gui->testCasePrefix .= $tcase_cfg->glue_character;
        $gui->keywordsFilterType = $argsObj->keywordsFilterType;
        $gui->build_id = $argsObj->build_id;
        $gui->tplan_id = $argsObj->tplan_id;
        $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
        $gui->testPlanName = $tplan_info['name'];
        $build_info = $tplanMgr->get_build_by_id($argsObj->tplan_id, $argsObj->build_id);
        $gui->buildName = $build_info['name'];
        $gui->main_descr = sprintf(lang_get('title_tc_exec_assignment'), $gui->buildName, $gui->testPlanName);
        $tproject_mgr = new testproject($dbHandler);
        $tproject_info = $tproject_mgr->get_by_id($argsObj->tproject_id);
        $gui->all_users = tlUser::getAll($dbHandler, null, "id", null);
        $gui->users = getUsersForHtmlOptions($dbHandler, null, null, null, $gui->all_users);
        $gui->testers = getTestersForHtmlOptions($dbHandler, $argsObj->tplan_id, $tproject_info, $gui->all_users);
    }
    return $gui;
}
/**
 *
 */
function initializeGuiForInput(&$dbHandler, $argsObj, &$guiObj)
{
    $room = config_get('gui_room');
    $guiObj->str_option_any = sprintf($room, lang_get('any'));
    $guiObj->str_option_none = sprintf($room, lang_get('nobody'));
    $guiObj->warning_msg = '';
    $guiObj->searchDone = 0;
    $guiObj->users = new stdClass();
    $guiObj->users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $guiObj->str_option_any));
    $guiObj->user_id = intval($argsObj->user_id);
    $dateFormat = config_get('date_format');
    $cfg = config_get('reportsCfg');
    $now = time();
    if (is_null($argsObj->selected_start_date)) {
        $guiObj->selected_start_date = strftime($dateFormat, $now - $cfg->start_date_offset);
        $guiObj->selected_start_time = $cfg->start_time;
        $guiObj->selected_end_date = strftime($dateFormat, $now);
        $guiObj->selected_end_time = null;
    } else {
        $guiObj->selected_start_date = $argsObj->selected_start_date[0];
        $guiObj->selected_end_date = $argsObj->selected_end_date[0];
        // we are using html_select_time (provided by Smarty Templates)
        // then we need to provide selected in a format she likes.
        $guiObj->selected_start_time = sprintf('%02d:00', $argsObj->start_Hour);
        $guiObj->selected_end_time = sprintf('%02d:59', $argsObj->end_Hour);
    }
}
Пример #7
0
if (is_null($gui->platformSet)) {
    $gui->platformSet = array('');
}
$gui->bugInterfaceOn = config_get('bugInterfaceOn');
$bugInterface = null;
if ($gui->bugInterfaceOn) {
    $bugInterface = config_get('bugInterface');
}
$labels = init_labels(array('deleted_user' => null, 'design' => null, 'execution' => null));
$gui->tplan_name = $tplan_info['name'];
$gui->tproject_name = $tproject_info['name'];
$testCaseCfg = config_get('testcase_cfg');
$exec_img = TL_THEME_IMG_DIR . "exec_icon.png";
$edit_img = TL_THEME_IMG_DIR . "edit_icon.png";
$mailCfg = buildMailCfg($gui);
$arrOwners = getUsersForHtmlOptions($db);
$fl = $tproject_mgr->tree_manager->get_children($args->tproject_id, array('testcase', 'exclude_me', 'testplan' => 'exclude_me', 'requirement_spec' => 'exclude_me'));
$loop2do = count($fl);
$topLevelSuites = null;
$myRBB = null;
for ($idx = 0; $idx < $loop2do; $idx++) {
    $topLevelSuites[$fl[$idx]['id']] = array('name' => $fl[$idx]['name'], 'items' => null);
}
if ($args->type == $statusCode['not_run']) {
    //BUGID 3722
    $cfg = config_get('results');
    $filters = array('exec_status' => $cfg['status_code']['not_run']);
    $options = array('output' => 'array', 'details' => 'summary');
    $myRBB = $tplan_mgr->get_linked_tcversions($args->tplan_id, $filters, $options);
    $user_key = 'user_id';
    //to be able to use only one php file to generate not run and failed/blocked report
Пример #8
0
/**
 * 
 *
 */
function initializeGui(&$dbHandler, &$argsObj)
{
    $gui = new stdClass();
    $gui->logLevels = array(tlLogger::AUDIT => lang_get("log_level_AUDIT"), tlLogger::ERROR => lang_get("log_level_ERROR"), tlLogger::WARNING => lang_get("log_level_WARNING"), tlLogger::INFO => lang_get("log_level_INFO"), tlLogger::DEBUG => lang_get("log_level_DEBUG"));
    $gui->allusers = tlUser::getAll($dbHandler);
    // THIS IS AN OVERKILL because get ALL USER OBJECTS
    $gui->testers = getUsersForHtmlOptions($dbHandler, null, null, true, $gui->allusers);
    $gui->users = getUsersForHtmlOptions($dbHandler);
    $gui->users[0] = false;
    $gui->startDate = $argsObj->startDate;
    $gui->endDate = $argsObj->endDate;
    $gui->object_id = $argsObj->object_id;
    $gui->object_type = $argsObj->object_type;
    $gui->selectedLogLevels = $argsObj->logLevel ? array_values($argsObj->logLevel) : array();
    $gui->selectedTesters = $argsObj->testers ? array_values($argsObj->testers) : array();
    // $gui->canDelete = has_rights($db,"events_mgt") ? 1 : 0;
    $gui->canDelete = $argsObj->currentUser->hasRight($dbHandler, "events_mgt");
    $gui->warning_msg = "";
    $gui->tableSet = null;
    return $gui;
}
Пример #9
0
/**
 * initialize Gui
 */
function initializeGui(&$dbHandler, &$argsObj, $dateFormat)
{
    $reports_cfg = config_get('reportsCfg');
    $gui = new stdClass();
    $tplan_mgr = new testplan($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $getOpt = array('outputFormat' => 'map');
    $gui->platformSet = $tplan_mgr->getPlatforms($argsObj->tplan_id, $getOpt);
    $gui->title = lang_get('query_metrics_report');
    $gui->showPlatforms = true;
    if (is_null($gui->platformSet)) {
        $gui->platformSet = array('');
        $gui->showPlatforms = false;
    }
    $gui->resultsCfg = config_get('results');
    // BUGID 3716, BUGID 3930
    // convert starttime to iso format for database usage
    if (isset($_REQUEST['selected_start_date']) && $_REQUEST['selected_start_date'] != '') {
        $date_array = split_localized_date($_REQUEST['selected_start_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $gui->startTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    // convert starttime to iso format for database usage
    if (isset($_REQUEST['selected_end_date']) && $_REQUEST['selected_end_date'] != '') {
        $date_array = split_localized_date($_REQUEST['selected_end_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $gui->endTime = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    $start_hour = isset($_REQUEST['start_Hour']) ? $_REQUEST['start_Hour'] : "00";
    $gui->startTime = $gui->startTime . " " . $start_hour . ":00:00";
    $end_hour = isset($_REQUEST['end_Hour']) ? $_REQUEST['end_Hour'] : "00";
    $gui->endTime = $gui->endTime . " " . $end_hour . ":59:59";
    $gui_open = config_get('gui_separator_open');
    $gui_close = config_get('gui_separator_close');
    $gui->str_option_any = $gui_open . lang_get('any') . $gui_close;
    $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close;
    $gui->search_notes_string = $argsObj->search_notes_string;
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id);
    $gui->tplan_name = $tplan_info['name'];
    $gui->tproject_name = $tproject_info['name'];
    $testsuiteIds = null;
    $testsuiteNames = null;
    $tsuites_qty = sizeOf($argsObj->testsuitesSelected);
    for ($id = 0; $id < $tsuites_qty; $id++) {
        list($suiteId, $suiteName) = preg_split("/\\,/", $argsObj->testsuitesSelected[$id], 2);
        $testsuiteIds[$id] = $suiteId;
        $testsuiteNames[$id] = $suiteName;
    }
    $buildsToQuery = -1;
    if (sizeof($argsObj->buildsSelected)) {
        $buildsToQuery = implode(",", $argsObj->buildsSelected);
    }
    // statusForClass is used for results.class.php
    // lastStatus is used to be displayed
    $statusForClass = 'a';
    // amitkhullar - added this parameter to get the latest results.
    $latest_resultset = $argsObj->display->latest_results;
    // BUGID 2500
    // $assignee = $argsObj->ownerSelected ? TL_USER_ANYBODY : null;
    // $tester = $argsObj->executorSelected ? TL_USER_ANYBODY : null;
    $assignee = $argsObj->ownerSelected > 0 ? $argsObj->ownerSelected : TL_USER_ANYBODY;
    $tester = $argsObj->executorSelected > 0 ? $argsObj->executorSelected : TL_USER_ANYBODY;
    // BUGID 4027
    $re = new newResults($dbHandler, $tplan_mgr, $tproject_info, $tplan_info, $testsuiteIds, $buildsToQuery, $argsObj->platformsSelected, $statusForClass, $latest_resultset, $argsObj->keywordSelected, $assignee, $gui->startTime, $gui->endTime, $tester, $argsObj->search_notes_string, null);
    $gui->suiteList = $re->getSuiteList();
    // test executions results
    // Filter test cases on selected platforms
    foreach ($gui->suiteList as $suiteid => $tcases) {
        $filtered = array();
        foreach ($tcases as $index => $tcase) {
            if ($tcase['platform_id'] == 0 || $argsObj->platformsSelected[0] == ALL_PLATFORMS || array_search($tcase['platform_id'], $argsObj->platformsSelected) !== false) {
                array_push($filtered, $tcase);
            }
        }
        unset($gui->suiteList[$suiteid]);
        $gui->suiteList[$suiteid] = $filtered;
    }
    $gui->flatArray = $re->getFlatArray();
    $gui->mapOfSuiteSummary = $re->getAggregateMap();
    $gui->totals = new stdClass();
    $gui->totals->items = $re->getTotalsForPlan();
    $gui->totals->labels = array();
    foreach ($gui->totals->items as $key => $value) {
        $l18n = $key == 'total' ? 'th_total_cases' : $gui->resultsCfg['status_label'][$key];
        $gui->totals->labels[$key] = lang_get($l18n);
    }
    // BUGID 2012 - franciscom
    $gui->keywords = new stdClass();
    $gui->keywords->items[0] = $gui->str_option_any;
    if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) {
        $gui->keywords->items += $tplan_keywords_map;
    }
    $gui->keywords->qty = count($gui->keywords->items);
    $gui->keywordSelected = $gui->keywords->items[$argsObj->keywordSelected];
    $gui->builds_html = $tplan_mgr->get_builds_for_html_options($gui->tplan_id);
    $gui->users = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->ownerSelected = $gui->users[$argsObj->ownerSelected];
    $gui->executorSelected = $gui->users[$argsObj->executorSelected];
    $gui->testsuitesSelected = $testsuiteNames;
    $gui->buildsSelected = $argsObj->buildsSelected;
    $gui->platformsSelected = $argsObj->platformsSelected;
    $gui->display = $argsObj->display;
    // init display rows attribute and some status localized labels
    $gui->displayResults = array();
    $gui->lastStatus = array();
    foreach ($reports_cfg->exec_status as $verbose => $label) {
        $gui->displayResults[$gui->resultsCfg['status_code'][$verbose]] = false;
    }
    foreach ($gui->resultsCfg['status_label'] as $status_verbose => $label_key) {
        $gui->statusLabels[$gui->resultsCfg['status_code'][$status_verbose]] = lang_get($label_key);
    }
    $lastStatus_localized = null;
    foreach ($argsObj->lastStatus as $key => $status_code) {
        $verbose = $gui->resultsCfg['code_status'][$status_code];
        $gui->displayResults[$status_code] = true;
        $lastStatus_localized[] = lang_get($gui->resultsCfg['status_label'][$verbose]);
    }
    $gui->lastStatus = $lastStatus_localized;
    return $gui;
}
Пример #10
0
 /**
  * $builds_to_query = 'a' will query all build, $builds_to_query = -1 will prevent
  * most logic in constructor from executing/ executions table from being queried
  * if keyword = 0, search by keyword would not be performed
  * @author kevinlevy
  *
  * @internal Revisions:
  *      20100720 - asimon - BUGID 3406, 1508: added logic to get result counts on build level
  * 	    20090327 - amitkhullar - added parameter $latest_results to get the latest results only.	
  *      20071013 - franciscom - changes to fix MSSQL problems
  *                 $startTime = "0000-00-00 00:00:00" -> null
  *                 $endTime = "9999-01-01 00:00:00" -> null
  *
  *      20070916 - franciscom - interface changes
  */
 public function results_overload(&$db, &$tplan_mgr, $tproject_info, $tplan_info, $suitesSelected = 'all', $builds_to_query = -1, $platforms_to_query = array(ALL_PLATFORMS), $lastResult = 'a', $keywordId = 0, $owner = null, $startTime = null, $endTime = null, $executor = null, $search_notes_string = null, $linkExecutionBuild = null, &$suiteStructure = null, &$flatArray = null, &$linked_tcversions = null)
 {
     $this->resultsCfg = config_get('results');
     $this->testCaseCfg = config_get('testcase_cfg');
     $this->db = $db;
     tlObjectWithDB::__construct($db);
     $this->tplanMgr = $tplan_mgr;
     $this->map_tc_status = $this->resultsCfg['status_code'];
     // TestLink standard configuration is (at least for me)
     // not_run not available at user interface level on execution feature as choice.
     //
     // if( !isset($dummy['not_run']) )
     // {
     //     $dummy['not_run']=$this->map_tc_status['not_run'];
     // }
     // This will be used to create dynamically counters if user add new status
     foreach ($this->resultsCfg['status_label_for_exec_ui'] as $tc_status_verbose => $label) {
         $this->tc_status_for_statistics[$tc_status_verbose] = $this->map_tc_status[$tc_status_verbose];
     }
     if (!isset($this->resultsCfg['status_label_for_exec_ui']['not_run'])) {
         $this->tc_status_for_statistics['not_run'] = $this->map_tc_status['not_run'];
     }
     $this->suitesSelected = $suitesSelected;
     $this->tprojectID = $tproject_info['id'];
     $this->testCasePrefix = $tproject_info['prefix'];
     $this->testPlanID = $tplan_info['id'];
     $this->tplanName = $tplan_info['name'];
     $this->suiteStructure = $suiteStructure;
     $this->flatArray = $flatArray;
     $this->linked_tcversions = $linked_tcversions;
     // build suiteStructure and flatArray
     if ($this->suiteStructure == null && $this->flatArray == null && $this->linked_tcversions == null) {
         list($this->suiteStructure, $this->linked_tcversions) = $this->generateExecTree($db, $keywordId, $owner);
     }
     // KL - if no builds are specified, no need to execute the following block of code
     if ($builds_to_query != -1) {
         // retrieve results from executions table
         // get keyword id -> keyword name pairs used in this test plan
         $keywords_in_tplan = $tplan_mgr->get_keywords_map($this->testPlanID, 'ORDER BY keyword');
         // KL - 20061229 - this call may not be necessary for all reports
         // only those that require info on results for keywords
         // Map of test case ids to array of associated keywords
         $this->keywordData = null;
         if (!is_null($keywords_in_tplan)) {
             $this->keywordData = $this->getKeywordData(array_keys($keywords_in_tplan));
         }
         //$tplan_mgr->get_keywords_tcases($this->testPlanID);
         // get owner id -> owner name pairs used in this test plan
         $arrOwners = getUsersForHtmlOptions($db);
         // create data object which tallies last result for each test case
         // this function now also creates mapOfLastResultByKeyword ???
         // KL - 2/01/07
         // we should NOT build executions map with cases that are just pass/failed/or blocked.
         // we should always populate the executions map with all results
         // and then programmatically figure out the last result
         // if you just query the executions table for those rows with status = $this->map_tc_status['passed']
         // that is not the way to determine last result
         $all_results = $this->latest_results;
         $this->executionsMap = $this->buildExecutionsMap($builds_to_query, $platforms_to_query, 'a', $keywordId, $owner, $startTime, $endTime, $executor, $search_notes_string, $linkExecutionBuild, $all_results);
         // new dBug($this->executionsMap);
         $this->createMapOfLastResult($this->suiteStructure, $this->executionsMap, $lastResult);
         $this->aggregateKeywordResults = $this->tallyKeywordResults($this->mapOfLastResultByKeyword, $keywords_in_tplan);
         $this->aggregateOwnerResults = $this->tallyOwnerResults($this->mapOfLastResultByOwner, $arrOwners);
         // create data object which tallies totals for individual suites
         // child suites are NOT taken into account in this step
         $this->createMapOfSuiteSummary($this->mapOfLastResult);
         // create data object which tallies totals for suites taking
         // child suites into account
         $this->createAggregateMap($this->suiteStructure, $this->mapOfSuiteSummary);
         $this->totalsForPlan = $this->createTotalsForPlan($this->suiteStructure);
         // must be done after totalsForPlan is performed because the total # of cases is needed
         // BUGID 3682
         $arrBuilds = $tplan_mgr->get_builds($this->testPlanID, testplan::GET_ACTIVE_BUILD);
         // BUGID 3406, BUGID 1508 - we need the totals per build here, not for the whole plan anymore
         $this->totalsForBuilds = $this->createTotalsForBuilds($arrBuilds);
         $this->aggregateBuildResults = $this->tallyBuildResults($this->mapOfLastResultByBuild, $arrBuilds, $this->totalsForBuilds);
     }
     // end if block
 }
Пример #11
0
/**
 *
 *
 */
function buildSpreadsheetData(&$db, &$args, &$gui, &$exec, $labels)
{
    $userSet = getUsersForHtmlOptions($db, null, null, null, null, array('userDisplayFormat' => '%first% %last%'));
    $det = array(TESTCASE_EXECUTION_TYPE_MANUAL => $labels['execution_type_manual'], TESTCASE_EXECUTION_TYPE_AUTO => $labels['execution_type_auto']);
    $metrics = $exec['metrics'];
    $latestExecution = $exec['latestExec'];
    $cols = $args->cols;
    /*
    tsuite_id 741
    tcase_id  742  => name  TC-1A
    tcversion_id  743
    platform_id 16  => NEED TO DECODE
    build_id  19    => NEED TO DECODE
    version 1
    external_id 1
    executions_id 64
    status  f       => NEED TO DECODE
    execution_notes [empty string]
    tester_id 1     => NEED TO DECODE
    execution_ts  2015-05-23 16:38:22
    execution_duration  NULL
    user_id 1       => NEED TO DECODE
    urg_imp 4       => NEED TO DECODE
    execution_type => NEED TO DECODE 
    */
    $loop2do = count($metrics);
    $uk2 = array('user_id', 'tester_id');
    for ($ix = 0; $ix < $loop2do; $ix++) {
        $rows = array();
        $rows[$cols['tsuite']] = $metrics[$ix]['suiteName'];
        $eid = $args->tcPrefix . $metrics[$ix]['external_id'];
        $rows[$cols['tcase']] = htmlspecialchars("{$eid}:{$metrics[$ix]['name']}", ENT_QUOTES);
        $rows[$cols['version']] = $metrics[$ix]['version'];
        if ($gui->show_platforms) {
            $rows[$cols['platform']] = $gui->platforms[$metrics[$ix]['platform_id']];
        }
        if ($gui->options->testPriorityEnabled) {
            $rows[$cols['priority']] = $args->cfg['priority'][$metrics[$ix]['priority_level']];
        }
        // build,assigned to,exec result,data,tested by,notes,duration
        $rows[] = $gui->buildInfoSet[$metrics[$ix]['build_id']]['name'];
        $u = "";
        if (isset($userSet, $metrics[$ix]['user_id'])) {
            $u = $userSet[$metrics[$ix]['user_id']];
        }
        $rows[] = $u;
        // $rows[] = $args->cfg['results']['code_status'][$metrics[$ix]['status']];
        $rows[] = $labels[$metrics[$ix]['status']];
        $rows[] = $metrics[$ix]['execution_ts'];
        $u = "";
        if (isset($userSet, $metrics[$ix]['tester_id'])) {
            $u = $userSet[$metrics[$ix]['tester_id']];
        }
        $rows[] = $u;
        $rows[] = $metrics[$ix]['execution_notes'];
        $rows[] = $metrics[$ix]['execution_duration'];
        $rows[] = isset($det[$metrics[$ix]['exec_type']]) ? $det[$metrics[$ix]['exec_type']] : 'not configured';
        $gui->matrix[] = $rows;
    }
}
/**
 * initialize Gui
 */
function initializeGui(&$dbHandler, &$argsObj, $dateFormat)
{
    new dBug($argsObj);
    /*		$my['filters'] = array('exec_ts_from' => null, 'exec_ts_to' => null,
    							   'assigned_to' => null, 'tester_id' => null,
    							   'keywords' => null, 'builds' => null,
    							   'plaforms' => null, 'top_level_tsuites' => null);
    	
    */
    $reports_cfg = config_get('reportsCfg');
    $tplan_mgr = new tlTestPlanMetrics($dbHandler);
    $tproject_mgr = new testproject($dbHandler);
    $gui = new stdClass();
    $gui->resultsCfg = config_get('results');
    $gui->title = lang_get('query_metrics_report');
    $gui->tplan_id = $argsObj->tplan_id;
    $gui->tproject_id = $argsObj->tproject_id;
    $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id);
    $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id);
    $gui->tplan_name = $tplan_info['name'];
    $gui->tproject_name = $tproject_info['name'];
    $getOpt = array('outputFormat' => 'map');
    $gui->platformSet = $tplan_mgr->getPlatforms($argsObj->tplan_id, $getOpt);
    $gui->showPlatforms = true;
    if (is_null($gui->platformSet)) {
        $gui->platformSet = null;
        $gui->showPlatforms = false;
    } else {
        $filters['platforms'] = array_keys($gui->platformSet);
    }
    // convert starttime to iso format for database usage
    list($gui->startTime, $gui->endTime) = helper2ISO($_REQUEST);
    //die();
    $gui_open = config_get('gui_separator_open');
    $gui_close = config_get('gui_separator_close');
    $gui->str_option_any = $gui_open . lang_get('any') . $gui_close;
    $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close;
    $gui->search_notes_string = $argsObj->search_notes_string;
    $testsuiteNames = null;
    $everest = $tplan_mgr->getRootTestSuites($gui->tplan_id, $gui->tproject_id, array('output' => 'plain'));
    $tsuites_qty = sizeOf($argsObj->testsuitesSelected);
    $userWantsAll = $tsuits_qty == 0 || $tsuits_qty == count($everest);
    $filters['top_level_tsuites'] = $tsuites_qty == 0 || $tsuites_qty == count($everest) ? null : $argsObj->testsuitesSelected;
    $gui->testsuitesSelected = array();
    foreach ($argsObj->testsuitesSelected as $dmy) {
        $gui->testsuitesSelected[$dmy] = $everest[$dmy]['name'];
    }
    $filters['builds'] = null;
    if (sizeof($argsObj->buildsSelected)) {
        $filters['builds'] = implode(",", $argsObj->buildsSelected);
    }
    $filters['keywords'] = (array) $argsObj->keywordSelected;
    if (in_array(0, $filters['keywords'])) {
        $filters['keywords'] = null;
    }
    // statusForClass is used for results.class.php
    // lastStatus is used to be displayed
    $statusForClass = 'a';
    // amitkhullar - added this parameter to get the latest results.
    $latest_resultset = $argsObj->display->latest_results;
    $assignee = $argsObj->ownerSelected > 0 ? $argsObj->ownerSelected : TL_USER_ANYBODY;
    $tester = $argsObj->executorSelected > 0 ? $argsObj->executorSelected : TL_USER_ANYBODY;
    //$rs = $tplan_mgr->queryMetrics($gui->tplan_id,$filters);
    //new dBug($rs);
    // die();
    //$re = new newResults($dbHandler, $tplan_mgr,$tproject_info,$tplan_info,
    //                  	 $testsuiteIds, $buildsToQuery,
    //                     $argsObj->platformsSelected, $statusForClass,
    //                     $latest_resultset, $argsObj->keywordSelected,
    //                     $assignee, $gui->startTime,
    //                     $gui->endTime, $tester,
    //                     $argsObj->search_notes_string, null);
    //
    //$gui->suiteList = $re->getSuiteList();  // test executions results
    //// Filter test cases on selected platforms
    //foreach ($gui->suiteList as $suiteid => $tcases)
    //{
    //    $filtered = array();
    //    foreach ($tcases as $index => $tcase) {
    //        if ($tcase['platform_id'] == 0 ||
    //            $argsObj->platformsSelected[0] == ALL_PLATFORMS ||
    //            array_search($tcase['platform_id'], $argsObj->platformsSelected) !== false) {
    //            array_push($filtered, $tcase);
    //        }
    //    }
    //    unset($gui->suiteList[$suiteid]);
    //    $gui->suiteList[$suiteid] = $filtered;
    //}
    //$gui->flatArray = $re->getFlatArray();
    //$gui->mapOfSuiteSummary =  $re->getAggregateMap();
    //
    // Prepare User Feedback
    $gui->totals = new stdClass();
    $gui->totals->items = 0;
    $gui->totals->labels = array();
    foreach ($gui->totals->items as $key => $value) {
        $l18n = $key == 'total' ? 'th_total_cases' : $gui->resultsCfg['status_label'][$key];
        $gui->totals->labels[$key] = lang_get($l18n);
    }
    $gui->keywords = new stdClass();
    $gui->keywords->items[0] = $gui->str_option_any;
    // Sorry MAGIC 0
    if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) {
        $gui->keywords->items += $tplan_keywords_map;
    }
    $gui->keywords->qty = count($gui->keywords->items);
    $gui->keywordSelected = $gui->keywords->items[$argsObj->keywordSelected];
    $gui->builds_html = $tplan_mgr->get_builds_for_html_options($gui->tplan_id);
    $gui->users = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any));
    $gui->ownerSelected = $gui->users[$argsObj->ownerSelected];
    $gui->executorSelected = $gui->users[$argsObj->executorSelected];
    $gui->buildsSelected = $argsObj->buildsSelected;
    $gui->platformsSelected = $argsObj->platformsSelected;
    $gui->display = $argsObj->display;
    // init display rows attribute and some status localized labels
    $gui->displayResults = array();
    $gui->lastStatus = array();
    foreach ($reports_cfg->exec_status as $verbose => $label) {
        $gui->displayResults[$gui->resultsCfg['status_code'][$verbose]] = false;
    }
    foreach ($gui->resultsCfg['status_label'] as $status_verbose => $label_key) {
        $gui->statusLabels[$gui->resultsCfg['status_code'][$status_verbose]] = lang_get($label_key);
    }
    $lastStatus_localized = null;
    foreach ($argsObj->lastStatus as $key => $status_code) {
        $verbose = $gui->resultsCfg['code_status'][$status_code];
        $gui->displayResults[$status_code] = true;
        $lastStatus_localized[] = lang_get($gui->resultsCfg['status_label'][$verbose]);
    }
    $gui->lastStatus = $lastStatus_localized;
    return $gui;
}
Пример #13
0
 $execStatus = $metricsMgr->getExecStatusMatrix($args->tplan_id, array('buildSet' => $buildIDSet), $opt);
 $metrics = $execStatus['metrics'];
 $latestExecution = $execStatus['latestExec'];
 //displayMemUsage('Before UNSET');
 unset($execStatus);
 // displayMemUsage('AFTER UNSET');
 // Every Test suite a row on matrix to display will be created
 // One matrix will be created for every platform that has testcases
 $tcols = array('tsuite', 'link');
 if ($show_platforms = !is_null($gui->platforms)) {
     $tcols[] = 'platform';
 }
 $tcols[] = 'priority';
 $cols = array_flip($tcols);
 if (!is_null($metrics)) {
     $userSet = getUsersForHtmlOptions($db, null, null, null, null, array('userDisplayFormat' => '%first% %last%'));
     // invariant pieces  => avoid wasting time on loops
     $dlink = '<a href="' . str_replace(" ", "%20", $args->basehref) . 'linkto.php?tprojectPrefix=' . urlencode($tproject_info['prefix']) . '&item=testcase&id=';
     $hist_img_tag = '<img title="' . $labels['history'] . '"' . ' src="' . $gui->img->history . '" /></a> ';
     $edit_img_tag = '<img title="' . $labels['design'] . '"' . ' src="' . $gui->img->edit . '" /></a> ';
     $tsuiteSet = array_keys($metrics);
     foreach ($tsuiteSet as $tsuiteID) {
         $tcaseSet = array_keys($metrics[$tsuiteID]);
         foreach ($tcaseSet as $tcaseID) {
             $platformSet = array_keys($metrics[$tsuiteID][$tcaseID]);
             foreach ($platformSet as $platformID) {
                 $rf =& $metrics[$tsuiteID][$tcaseID][$platformID];
                 $rows = null;
                 // some info does not change on different executions
                 $build2loop = array_keys($rf);
                 $top = current($build2loop);
    $metrics = $metricsMgr->getExecutionsByStatus($args->tplan_id, $args->type, null, array('output' => 'mapByExecID', 'getOnlyAssigned' => true));
    $notesAccessKey = 'execution_notes';
    $userAccessKey = 'tester_id';
}
$cfOnExec = $cfSet = null;
// done here in order to get some config about images
$smarty = new TLSmarty();
if (!is_null($metrics) and count($metrics) > 0) {
    if ($args->addOpAccess) {
        $links = featureLinks($labels, $smarty->getImages());
    }
    $urlSafeString = array();
    $urlSafeString['tprojectPrefix'] = urlencode($tproject_info['prefix']);
    $urlSafeString['basehref'] = str_replace(" ", "%20", $args->basehref);
    $out = array();
    $users = getUsersForHtmlOptions($db);
    $pathCache = $topCache = $levelCache = null;
    $nameCache = initNameCache($gui);
    $odx = 0;
    if ($args->type != $statusCode['not_run']) {
        // get Custom fields definition to understand columns to be added
        $cfSet = $tcase_mgr->cfield_mgr->get_linked_cfields_at_execution($args->tproject_id, true, 'testcase');
        $execSet = array_keys($metrics);
        // go for Custom fields values of all executions on ONE SHOT!
        $cfOnExec = $tcase_mgr->cfield_mgr->get_linked_cfields_at_execution($args->tproject_id, true, 'testcase', null, $execSet);
    }
    foreach ($metrics as $execID => &$exec) {
        // --------------------------------------------------------------------------------------------
        // do some decode work, using caches
        if (!isset($pathCache[$exec['tcase_id']])) {
            $dummy = $tcase_mgr->getPathLayered(array($exec['tcase_id']));
/**
 *
 *
 */
function buildDataSet(&$db, &$args, &$gui, &$exec, $labels)
{
    $userSet = getUsersForHtmlOptions($db, null, null, null, null, array('userDisplayFormat' => '%first% %last%'));
    // invariant pieces  => avoid wasting time on loops
    $dlink = '<a href="' . str_replace(" ", "%20", $args->basehref) . 'linkto.php?tprojectPrefix=' . urlencode($args->prefix) . '&item=testcase&id=';
    $hist_img_tag = '<img title="' . $labels['history'] . '"' . ' src="' . $gui->img->history . '" /></a> ';
    $edit_img_tag = '<img title="' . $labels['design'] . '"' . ' src="' . $gui->img->edit . '" /></a> ';
    $metrics = $exec['metrics'];
    $latestExecution = $exec['latestExec'];
    $cols = $args->cols;
    $tsuiteSet = array_keys($metrics);
    foreach ($tsuiteSet as $tsuiteID) {
        $tcaseSet = array_keys($metrics[$tsuiteID]);
        foreach ($tcaseSet as $tcaseID) {
            $platformSet = array_keys($metrics[$tsuiteID][$tcaseID]);
            foreach ($platformSet as $platformID) {
                $rf =& $metrics[$tsuiteID][$tcaseID][$platformID];
                $rows = null;
                // some info does not change on different executions
                $build2loop = array_keys($rf);
                $top = current($build2loop);
                $external_id = $args->tcPrefix . $rf[$top]['external_id'];
                $rows[$cols['tsuite']] = $rf[$top]['suiteName'];
                $name = htmlspecialchars("{$external_id}:{$rf[$top]['name']}", ENT_QUOTES);
                if ($args->format == FORMAT_HTML) {
                    $rows[$cols['link']] = "<!-- " . sprintf("%010d", $rf[$top]['external_id']) . " -->";
                    if ($args->addOpAccess) {
                        $rows[$cols['link']] .= "<a href=\"javascript:openExecHistoryWindow({$tcaseID});\">" . $hist_img_tag . "<a href=\"javascript:openTCEditWindow({$tcaseID});\">" . $edit_img_tag;
                    }
                    $rows[$cols['link']] .= $name;
                } else {
                    $rows[$cols['link']] = "{$external_id}:{$rf[$top]['name']}";
                }
                if ($gui->show_platforms) {
                    $rows[$cols['platform']] = $gui->platforms[$platformID];
                }
                if ($gui->options->testPriorityEnabled) {
                    switch ($args->format) {
                        case FORMAT_XLS:
                            $rows[$cols['priority']] = $args->cfg['priority'][$rf[$top]['priority_level']];
                            break;
                        default:
                            // is better to use code to do reorder instead of localized string ???
                            $rows[$cols['priority']] = $rf[$top]['priority_level'];
                            break;
                    }
                }
                // Now loop on result on each build, but following order
                $buildExecStatus = null;
                $execOnLastBuild = null;
                foreach ($args->builds->idSet as $buildID) {
                    $r4build['text'] = "";
                    if ($args->format == FORMAT_XLS) {
                        $r4build = $labels[$rf[$buildID]['status']] . sprintf($labels['versionTag'], $rf[$buildID]['version']);
                        $tester = '';
                        if (isset($userSet, $rf[$buildID]['tester_id'])) {
                            $tester = $userSet[$rf[$buildID]['tester_id']];
                        }
                        $assignee = '';
                        if (isset($userSet, $rf[$buildID]['user_id'])) {
                            $assignee = $userSet[$rf[$buildID]['user_id']];
                        }
                        $bella = array($r4build, $assignee, $rf[$buildID]['execution_ts'], $tester, $rf[$buildID]['execution_notes'], $rf[$buildID]['execution_duration']);
                        $buildExecStatus = array_merge((array) $buildExecStatus, $bella);
                    } else {
                        $r4build['text'] = "";
                    }
                    if ($args->format == FORMAT_HTML && $args->addOpAccess) {
                        $r4build['text'] = "<a href=\"javascript:openExecutionWindow(" . "{$tcaseID}, {$rf[$buildID]['tcversion_id']}, {$buildID}, " . "{$args->tplan_id}, {$platformID});\">" . "<img title=\"{$labels['execution']}\" src=\"{$gui->img->exec}\" /></a> ";
                        $r4build['text'] .= $labels[$rf[$buildID]['status']] . sprintf($labels['versionTag'], $rf[$buildID]['version']);
                        $r4build['value'] = $rf[$buildID]['status'];
                        $r4build['cssClass'] = $gui->map_status_css[$rf[$buildID]['status']];
                        $buildExecStatus[] = $r4build;
                    }
                    if ($gui->matrixCfg->buildColumns['showStatusLastExecuted'] && $args->builds->latest->id == $buildID) {
                        $execOnLastBuild = $r4build;
                    }
                    // why we do special reasoning on NOT RUN ???
                    if ($latestExecution[$platformID][$tcaseID]['status'] == $args->cfg['results']['status_code']['not_run'] || $latestExecution[$platformID][$tcaseID]['build_id'] == $buildID && $latestExecution[$platformID][$tcaseID]['id'] == $rf[$buildID]['executions_id']) {
                        $lexec = $r4build;
                    }
                }
                // foreach buildIDSet
                // Ok, now the specials
                // If configured, add column with Exec result on Latest Created Build
                if ($gui->matrixCfg->buildColumns['showStatusLastExecuted']) {
                    $buildExecStatus[] = $execOnLastBuild;
                }
                if ($gui->matrixCfg->buildColumns['latestBuildOnLeft']) {
                    $buildExecStatus = array_reverse($buildExecStatus);
                }
                $rows = array_merge($rows, $buildExecStatus);
                // Always righmost column will display lastest execution result
                $rows[] = $lexec;
                $gui->matrix[] = $rows;
                unset($r4build);
                unset($rows);
                unset($buildExecStatus);
            }
            // $platformSet
        }
        // $tcaseSet
    }
    // $tsuiteSet
}