/**
 * 
 */
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);
    $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;
}
Example #3
0
function init_args(&$dbHandler, $cfgObj)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $tplan_mgr = new testplan($dbHandler);
    // Settings we put on session to create some sort of persistent scope,
    // because we have had issues when passing this info using GET mode (size limits)
    //
    // we get info about build_id, platform_id, etc ...
    getContextFromGlobalScope($args);
    $args->user = $_SESSION['currentUser'];
    $args->user_id = $args->user->dbID;
    $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature';
    $args->reload_caller = false;
    $args->tplan_id = intval(isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : $_SESSION['testplanID']);
    $args->tproject_id = intval(isset($_REQUEST['tproject_id']) ? $_REQUEST['tproject_id'] : $_SESSION['testprojectID']);
    if ($args->tproject_id <= 0) {
        $tree_mgr = new tree($dbHandler);
        $dm = $tree_mgr->get_node_hierarchy_info($args->tplan_id);
        $args->tproject_id = $dm['parent_id'];
    }
    if (is_null($args->build_id) || $args->build_id == 0) {
        // Go for the build
        // this info can be present in session, then we will try different ways
        // ATTENTION:
        // give a look to tlTestCaseFilterControl.class.php method init_setting_build()
        //
        $key = $args->tplan_id . '_stored_setting_build';
        $args->build_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
        if (is_null($args->build_id)) {
            $args->build_id = $tplan_mgr->get_max_build_id($args->tplan_id, 1, 1);
        }
    }
    if (is_null($args->platform_id) || $args->platform_id <= 0) {
        // Go for the platform (if any exists)
        // this info can be present in session, then we will try different ways
        // ATTENTION:
        // give a look to tlTestCaseFilterControl.class.php method init_setting_platform()
        //
        $itemSet = $tplan_mgr->getPlatforms($args->tplan_id);
        if (!is_null($itemSet)) {
            $key = $args->tplan_id . '_stored_setting_platform';
            $args->platform_id = isset($_SESSION[$key]) ? intval($_SESSION[$key]) : null;
            if (is_null($args->platform_id) || $args->platform_id <= 0) {
                $args->platform_id = $itemSet[0]['id'];
            }
        }
    }
    return array($args, $tplan_mgr);
}
Example #4
0
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->target_date = null;
    $args->start_date = null;
    // Important!!!
    // name of these variables is generated by smarty (See html_select_date in Smarty Manual)
    $date_vars = array('target_date_Year', 'target_date_Month', 'target_date_Day');
    $start_date_vars = array('start_date_Year', 'start_date_Month', 'start_date_Day');
    $create_date = true;
    $create_start_date = true;
    foreach ($date_vars as $my) {
        ${$my} = isset($_REQUEST[$my]) ? $_REQUEST[$my] : null;
        $create_date = $create_date && !is_null(${$my}) && trim(${$my}) != '';
    }
    if ($create_date) {
        $args->target_date = $target_date_Year . "-" . $target_date_Month . "-" . $target_date_Day;
    }
    foreach ($start_date_vars as $my) {
        ${$my} = isset($_REQUEST[$my]) ? $_REQUEST[$my] : null;
        $create_start_date = $create_start_date && !is_null(${$my}) && trim(${$my}) != '';
    }
    if ($create_start_date) {
        $args->start_date = $start_date_Year . "-" . $start_date_Month . "-" . $start_date_Day;
    }
    $key2loop = array('low_priority_tcases', 'medium_priority_tcases', 'high_priority_tcases');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
    }
    $args->id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
    $args->name = isset($_REQUEST['milestone_name']) ? $_REQUEST['milestone_name'] : null;
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : null;
    $args->basehref = $_SESSION['basehref'];
    $args->tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0;
    $args->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : "";
    $args->tplan_name = '';
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? $_REQUEST['tplan_id'] : 0;
    if ($args->tplan_id == 0) {
        $args->tplan_id = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : 0;
    }
    if ($args->tplan_id > 0) {
        $tplan_mgr = new testplan($dbHandler);
        $info = $tplan_mgr->get_by_id($args->tplan_id);
        $args->tplan_name = $info['name'];
    }
    return $args;
}
function init_args(&$dbHandler, $dateFormat)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->target_date_original = isset($_REQUEST['target_date']) ? $_REQUEST['target_date'] : null;
    $args->start_date_original = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : null;
    // convert target date to iso format to write to db
    if (isset($_REQUEST['target_date']) && $_REQUEST['target_date'] != '') {
        $date_array = split_localized_date($_REQUEST['target_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->target_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    // convert start date to iso format to write to db
    if (isset($_REQUEST['start_date']) && $_REQUEST['start_date'] != '') {
        $date_array = split_localized_date($_REQUEST['start_date'], $dateFormat);
        if ($date_array != null) {
            // set date in iso format
            $args->start_date = $date_array['year'] . "-" . $date_array['month'] . "-" . $date_array['day'];
        }
    }
    $key2loop = array('low_priority_tcases', 'medium_priority_tcases', 'high_priority_tcases');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
    }
    $args->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $args->name = isset($_REQUEST['milestone_name']) ? $_REQUEST['milestone_name'] : null;
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : null;
    $args->basehref = $_SESSION['basehref'];
    $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    $args->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : "";
    $args->tplan_name = '';
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    if ($args->tplan_id == 0) {
        $args->tplan_id = isset($_SESSION['testplanID']) ? intval($_SESSION['testplanID']) : 0;
    }
    if ($args->tplan_id > 0) {
        $tplan_mgr = new testplan($dbHandler);
        $info = $tplan_mgr->get_by_id($args->tplan_id);
        $args->tplan_name = $info['name'];
    }
    return $args;
}
function initializeGui(&$dbHandler, &$argsObj, &$userObj, &$tprojectMgr)
{
    $tcaseCfg = config_get('testcase_cfg');
    $guiObj = new stdClass();
    $guiObj->can_manage_testplans = $userObj->hasRight($dbHandler, "mgt_testplan_create", $argsObj->tproject_id, $argsObj->tplan_id);
    $guiObj->show_details = 0;
    $guiObj->user_feedback = '';
    $guiObj->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tproject_id) . $tcaseCfg->glue_character;
    $guiObj->tproject_name = $argsObj->tproject_name;
    $tplanMgr = new testplan($dbHandler);
    $tplan_info = $tplanMgr->get_by_id($argsObj->tplan_id);
    $guiObj->tplan_name = $tplan_info['name'];
    $guiObj->tplan_id = $argsObj->tplan_id;
    $guiObj->tproject_id = $argsObj->tproject_id;
    $guiObj->testcases = $tplanMgr->get_linked_and_newest_tcversions($argsObj->tplan_id);
    $linked_tcases = $tplanMgr->get_linked_items_id($argsObj->tplan_id);
    $guiObj->doIt = count($linked_tcases) > 0;
    $guiObj->tplans = array();
    $tplans = $userObj->getAccessibleTestPlans($dbHandler, $argsObj->tproject_id);
    foreach ($tplans as $key => $value) {
        $guiObj->tplans[$value['id']] = $value['name'];
    }
    return $guiObj;
}
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;
}
 /** 
  * class constructor 
  * @param resource &$db reference to database handler
  **/
 function __construct(&$db)
 {
     $this->resultsCfg = config_get('results');
     $this->testCaseCfg = config_get('testcase_cfg');
     $this->db = $db;
     parent::__construct($db);
     $this->map_tc_status = $this->resultsCfg['status_code'];
     // 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->statusCode = array_flip(array_keys($this->resultsCfg['status_label_for_exec_ui']));
     foreach ($this->statusCode as $key => $dummy) {
         $this->statusCode[$key] = $this->resultsCfg['status_code'][$key];
     }
 }
/**
 * initialize user input
 * 
 * @param resource dbHandler
 * @return array $args array with user input information
 */
function init_args(&$dbHandler)
{
    $iParams = array("apikey" => array(tlInputParameter::STRING_N, 0, 64), "tproject_id" => array(tlInputParameter::INT_N), "tplan_id" => array(tlInputParameter::INT_N), "format" => array(tlInputParameter::INT_N));
    $args = new stdClass();
    $pParams = R_PARAMS($iParams, $args);
    if (!is_null($args->apikey)) {
        $cerbero = new stdClass();
        $cerbero->args = new stdClass();
        $cerbero->args->tproject_id = $args->tproject_id;
        $cerbero->args->tplan_id = $args->tplan_id;
        if (strlen($args->apikey) == 32) {
            $cerbero->args->getAccessAttr = true;
            $cerbero->method = 'checkRights';
            $cerbero->redirect_target = "../../login.php?note=logout";
            setUpEnvForRemoteAccess($dbHandler, $args->apikey, $cerbero);
        } else {
            $args->addOpAccess = false;
            $cerbero->method = null;
            $cerbero->args->getAccessAttr = false;
            setUpEnvForAnonymousAccess($dbHandler, $args->apikey, $cerbero);
        }
    } else {
        testlinkInitPage($dbHandler, false, false, "checkRights");
        $args->tproject_id = isset($_SESSION['testprojectID']) ? intval($_SESSION['testprojectID']) : 0;
    }
    $tproject_mgr = new testproject($dbHandler);
    $tplan_mgr = new testplan($dbHandler);
    if ($args->tproject_id > 0) {
        $args->tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
        $args->tproject_name = $args->tproject_info['name'];
        $args->tproject_description = $args->tproject_info['notes'];
    }
    if ($args->tplan_id > 0) {
        $args->tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
    }
    return array($args, $tproject_mgr, $tplan_mgr);
}
Example #10
0
<?php

require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$gui = new stdClass();
$tplan_mgr = new testplan($db);
$build_mgr = new build_mgr($db);
$needsave = isset($_GET['save']) ? $_GET['save'] : 0;
$tplanid = isset($_GET['tplanid']) ? $_GET['tplanid'] : 1;
$buildid = isset($_GET['buildid']) ? $_GET['buildid'] : 1;
$deviceid = isset($_GET['deviceid']) ? $_GET['deviceid'] : 1;
$topotype = isset($_GET['topotype']) ? $_GET['topotype'] : 999;
$suite = isset($_GET['suite']) ? $_GET['suite'] : 1;
$gui->saveresult = 2;
if ($needsave == 1) {
    $result = isset($_POST['result']) ? $_POST['result'] : 'none';
    $result_summary = isset($_POST['result_summary']) ? $_POST['result_summary'] : '';
    $reviewer = isset($_POST['reviewer']) ? $_POST['reviewer'] : '';
    $review_summary = isset($_POST['review_summary']) ? $_POST['review_summary'] : '';
    $result_report = isset($_POST['result_report']) ? $_POST['result_report'] : '';
    $gui->saveresult = $tplan_mgr->setTestResult($tplanid, $deviceid, $buildid, $topotype, $suite, $result, $result_summary, $reviewer, $review_summary, $result_report);
}
$gui->reviewers = $tplan_mgr->get_review_users();
$dcnresult = $tplan_mgr->getTestResult($tplanid, $deviceid, $buildid, $topotype, $suite);
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->assign('tplanid', $tplanid);
$smarty->assign('buildid', $buildid);
Example #11
0
 *                          noew use method from test plan class.
 *
 *  20090209 - franciscom - BUGID 2080
 *  20080928 - franciscom - removed useless requires
 * 	20050807 - fm - refactoring:  changes in getTestSuiteReport() call
 * 	20050905 - fm - reduce global coupling
 *  20070101 - KL - upgraded to 1.7
 * 	20080626 - mht - added milestomes, priority report, refactorization
 * 
 * ----------------------------------------------------------------------------------- */
require '../../config.inc.php';
require_once 'common.php';
require_once 'results.class.php';
require_once 'displayMgr.php';
testlinkInitPage($db, true, false, "checkRights");
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$templateCfg = templateConfiguration();
$args = init_args();
$tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
$tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
$arrDataSuite = array();
$gui = new stdClass();
$gui->title = lang_get('title_gen_test_rep');
$gui->do_report = array();
$gui->showPlatforms = true;
$gui->columnsDefinition = new stdClass();
$gui->columnsDefinition->keywords = null;
$gui->columnsDefinition->testers = null;
$gui->columnsDefinition->platform = null;
$gui->statistics = new stdClass();
Example #12
0
<?php

//@TODO this file seems not to be in use
include "../../third_party/charts/charts.php";
require_once '../functions/results.class.php';
require_once '../functions/testplan.class.php';
testlinkInitPage($db);
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$tplan_id = $_REQUEST['tplan_id'];
$tproject_id = $_SESSION['testprojectID'];
$tplan_info = $tplan_mgr->get_by_id($tplan_id);
$tproject_info = $tproject_mgr->get_by_id($tproject_id);
$re = new results($db, $tplan_mgr, $tproject_info, $tplan_info, ALL_TEST_SUITES, ALL_BUILDS);
/**
* KEYWORDS REPORT
*/
$arrDataKeys = $re->getAggregateKeywordResults();
$i = 0;
$arrDataKeys2 = null;
if ($arrDataKeys != null) {
    while ($keywordId = key($arrDataKeys)) {
        $arr = $arrDataKeys[$keywordId];
        $arrDataKeys2[$i] = $arr;
        $i++;
        next($arrDataKeys);
    }
}
$namesOfKeywordsArray = array();
$namesOfKeywordsArray[0] = "";
$passArray = array();
Example #13
0
// get issue tracker config and object to manage TestLink - BTS integration
$its = null;
$tproject_mgr = new testproject($db);
$info = $tproject_mgr->get_by_id($args->tproject_id);
$gui->bugInterfaceOn = $info['issue_tracker_enabled'];
if ($info['issue_tracker_enabled']) {
    $it_mgr = new tlIssueTracker($db);
    $its = $it_mgr->getInterfaceObject($args->tproject_id);
    unset($it_mgr);
}
$smarty = new TLSmarty();
$img = $smarty->getImages();
$openBugs = array();
$resolvedBugs = array();
$arrData = array();
$tplan_mgr = new testplan($db);
$metricsMgr = new tlTestPlanMetrics($db);
$tproject_mgr = new testproject($db);
$tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
$tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
unset($tproject_mgr);
// $filters = array();
//$options = array('output' => 'array', 'only_executed' => true, 'details' => 'full');
// $execSet = $tplan_mgr->get_linked_tcversions($args->tplan_id, $filters, $options);
$execSet = (array) $metricsMgr->getLTCVNewGeneration($args->tplan_id, null, array('addExecInfo' => true, 'accessKeyType' => 'index', 'specViewFields' => true, 'testSuiteInfo' => true, 'includeNotRun' => false));
$testcase_bugs = array();
$mine = array();
$l18n = init_labels(array('execution_history' => null, 'design' => null, 'no_linked_bugs' => null));
foreach ($execSet as $execution) {
    $tc_id = $execution['tc_id'];
    $mine[] = $execution['exec_id'];
Example #14
0
function getMetrics(&$db, $args)
{
    $user_id = $args->currentUserID;
    $tproject_id = $args->tproject_id;
    $linked_tcversions = array();
    $metrics = array();
    $tplan_mgr = new testplan($db);
    $show_platforms = false;
    // BUGID 1215
    // get all tesplans accessibles  for user, for $tproject_id
    if ($args->show_only_active) {
        $options = array('active' => ACTIVE);
    } else {
        $options = array('active' => TP_ALL_STATUS);
    }
    $test_plans = $_SESSION['currentUser']->getAccessibleTestPlans($db, $tproject_id, null, $options);
    // Get count of testcases linked to every testplan
    foreach ($test_plans as $key => $value) {
        $tplan_id = $value['id'];
        $filters = null;
        $options = array('output' => 'mapOfMap', 'steps_info' => 0);
        $linked_tcversions[$tplan_id] = $tplan_mgr->get_linked_tcversions($tplan_id, $filters, $options);
        $platformSet = $tplan_mgr->getPlatforms($tplan_id);
        if (is_null($platformSet)) {
            //Julian: replaced array(0=>'')
            $platformSet = array(0 => array('id' => 0));
        } else {
            $show_platforms = true;
        }
        foreach ($platformSet as $platform_id => $platform_name) {
            $metrics[$tplan_id][$platform_name['id']]['tplan_name'] = $value['name'];
            $metrics[$tplan_id][$platform_name['id']]['platform_name'] = $platform_name['id'] == 0 ? lang_get('not_aplicable') : $platform_name['name'];
            $metrics[$tplan_id][$platform_name['id']]['executed'] = 0;
            $metrics[$tplan_id][$platform_name['id']]['active'] = 0;
            $metrics[$tplan_id][$platform_name['id']]['total'] = 0;
            $metrics[$tplan_id][$platform_name['id']]['executed_vs_active'] = -1;
            $metrics[$tplan_id][$platform_name['id']]['executed_vs_total'] = -1;
            $metrics[$tplan_id][$platform_name['id']]['active_vs_total'] = -1;
        }
    }
    // Get count of executed testcases
    foreach ($linked_tcversions as $tplan_id => $tcinfo) {
        if (!is_null($tcinfo)) {
            foreach ($tcinfo as $tcase_id => $tc) {
                foreach ($tc as $platform_id => $value) {
                    if ($value['exec_id'] > 0) {
                        $metrics[$tplan_id][$platform_id]['executed']++;
                    }
                    if ($value['active']) {
                        $metrics[$tplan_id][$platform_id]['active']++;
                    }
                    $metrics[$tplan_id][$platform_id]['total']++;
                }
            }
        }
    }
    // Calculate percentages
    $round_precision = config_get('dashboard_precision');
    foreach ($metrics as $tplan_id => $platform_metrics) {
        $platforms = array_keys($platform_metrics);
        foreach ($platforms as $platform_id) {
            $planMetrics =& $metrics[$tplan_id][$platform_id];
            if ($planMetrics['total'] > 0) {
                if ($planMetrics['active'] > 0) {
                    $planMetrics['executed_vs_active'] = $planMetrics['executed'] / $planMetrics['active'];
                    $planMetrics['executed_vs_active'] = round($planMetrics['executed_vs_active'] * 100, $round_precision);
                }
                $planMetrics['executed_vs_total'] = $planMetrics['executed'] / $planMetrics['total'];
                $planMetrics['executed_vs_total'] = round($planMetrics['executed_vs_total'] * 100, $round_precision);
                $planMetrics['active_vs_total'] = $planMetrics['active'] / $planMetrics['total'];
                $planMetrics['active_vs_total'] = round($planMetrics['active_vs_total'] * 100, $round_precision);
            }
        }
    }
    return array($metrics, $show_platforms);
}
Example #15
0
         case 'testsuite':
             $tsuite = new testsuite($db);
             $tInfo = $tsuite->get_by_id($args->itemID);
             $tInfo['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null;
             $treeForPlatform[0]['childNodes'] = array($tInfo);
             $doc_info->title = htmlspecialchars(isset($tInfo['name']) ? $args->tproject_name . $tlCfg->gui_title_separator_2 . $tInfo['name'] : $args->tproject_name);
             break;
     }
     break;
 case DOC_TEST_PLAN_DESIGN:
     $printingOptions['metrics'] = true;
     // FORCE
 // FORCE
 case DOC_TEST_PLAN_EXECUTION:
 case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
     $tplan_mgr = new testplan($db);
     $tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
     if ($args->build_id > 0) {
         $xx = $tplan_mgr->get_builds($args->tplan_id, null, null, array('buildID' => $args->build_id));
         $doc_info->build_name = htmlspecialchars($xx[$args->build_id]['name']);
     }
     $doc_info->testplan_name = htmlspecialchars($tplan_info['name']);
     $doc_info->testplan_scope = $tplan_info['notes'];
     $doc_info->title = $doc_info->testplan_name;
     // Changed to get ALL platform attributes.
     $getOpt = array('outputFormat' => 'mapAccessByID', 'addIfNull' => true);
     $platforms = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt);
     $platformIDSet = array_keys($platforms);
     $printingOptions['priority'] = $doc_info->test_priority_enabled;
     $items2use = (object) array('estimatedExecTime' => null, 'realExecTime' => null);
     $treeForPlatform = array();
Example #16
0
//$reports_mgr->get_count_builds();
tLog('Active Builds count = ' . $build_count);
if ($build_count == 0) {
    // Test plan without builds can have execution data
    $gui->do_report['status_ok'] = 0;
    $gui->do_report['msg'] = lang_get('report_tplan_has_no_build');
}
// -----------------------------------------------------------------------------
// get navigation data
$gui->menuItems = array();
if ($gui->do_report['status_ok']) {
    // create a list or reports
    $context = new stdClass();
    $context->tproject_id = $args->tproject_id;
    $context->tplan_id = $args->tplan_id;
    $tplan_mgr = new testplan($db);
    $dmy = $tplan_mgr->get_by_id($context->tplan_id);
    $gui->buildInfoSet = $tplan_mgr->get_builds($gui->tplan_id);
    $report_plans = $tplan_mgr->report_get_plans($args->tproject_id);
    $report_suites = $tplan_mgr->report_get_suites($args->tproject_id);
    $report_builds = $tplan_mgr->report_get_builds();
    $report_build_total = count($report_builds);
    $report_devices = $tplan_mgr->report_get_devices($args->tproject_id);
    $report_device_total = count($report_devices);
    unset($tplan_mgr);
    $context->apikey = $dmy['api_key'];
    // $context->apikey = $_SESSION['currentUser']->userApiKey;
    $context->imgSet = $smarty->getImages();
    $gui->menuItems = $reports_mgr->get_list_reports($context, $gui->btsEnabled, $args->optReqs, $tlCfg->reports_formats[$args->format]);
}
$smarty->assign('gui', $gui);
Example #17
0
 * TestLink Open Source Project - http://testlink.sourceforge.net/ 
 * This script is distributed under the GNU General Public License 2 or later. 
 *
 * Filename $RCSfile: buildView.php,v $
 *
 * @version $Revision: 1.14 $
 * @modified $Date: 2009/06/10 19:36:00 $ $Author: franciscom $
 *
 * rev:
 *      20090509 - franciscom - minor refactoring      
 *       
 *
*/
require '../../config.inc.php';
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$tplan_mgr = new testplan($db);
$build_mgr = new build_mgr($db);
$gui = new StdClass();
$gui->tplan_id = isset($_SESSION['testplanID']) ? $_SESSION['testplanID'] : 0;
$gui->tplan_name = $_SESSION['testplanName'];
$gui->buildSet = $tplan_mgr->get_builds($gui->tplan_id);
$gui->user_feedback = null;
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function checkRights(&$db, &$user)
{
    return $user->hasRight($db, 'testplan_create_build');
}
Example #18
0
/**
 * get Columns definition for table to display
 *
 */
function getColumnsDefinition($dbHandler, $tplan_id, $optionalColumns)
{
    static $labels;
    static $tplan_mgr;
    if (is_null($labels)) {
        $tplan_mgr = new testplan($dbHandler);
        $lbl2get = array('build' => null, 'testsuite' => null, 'testcase' => null, 'platform' => null, 'user' => null, 'priority' => null, 'status' => null, 'version' => null, 'low_priority' => null, 'medium_priority' => null, 'high_priority' => null, 'due_since' => null);
        $labels = init_labels($lbl2get);
    }
    $colDef = array();
    $sortByCol = $labels['testsuite'];
    // user column is only shown for assignment overview
    if ($optionalColumns['user']) {
        $colDef[] = array('title_key' => 'user', 'width' => 80);
        $sortByCol = $labels['build'];
    }
    $colDef[] = array('title_key' => 'build', 'width' => 80);
    $colDef[] = array('title_key' => 'testsuite', 'width' => 130);
    $colDef[] = array('title_key' => 'testcase', 'width' => 130);
    $platforms = $tplan_mgr->getPlatforms($tplan_id, array('outputFormat' => 'map'));
    if ($show_plat = !is_null($platforms)) {
        $colDef[] = array('title_key' => 'platform', 'width' => 50, 'filter' => 'list', 'filterOptions' => $platforms);
    }
    if ($optionalColumns['priority']) {
        $sortByCol = $labels['priority'];
        $colDef[] = array('title_key' => 'priority', 'width' => 50, 'filter' => 'ListSimpleMatch', 'filterOptions' => array($labels['low_priority'], $labels['medium_priority'], $labels['high_priority']));
    }
    $colDef[] = array('title_key' => 'status', 'width' => 50, 'type' => 'status');
    $colDef[] = array('title_key' => 'due_since', 'width' => 100);
    return array($colDef, $sortByCol, $show_plat);
}
Example #19
0
 /**
  * 
  *
  */
 private function copy_testplans($source_id, $target_id, $user_id, $mappings)
 {
     static $tplanMgr;
     $tplanSet = $this->get_all_testplans($source_id);
     if (!is_null($tplanSet)) {
         $keySet = array_keys($tplanSet);
         if (is_null($tplanMgr)) {
             $tplanMgr = new testplan($this->db);
         }
         foreach ($keySet as $itemID) {
             $new_id = $tplanMgr->create($tplanSet[$itemID]['name'], $tplanSet[$itemID]['notes'], $target_id, $tplanSet[$itemID]['active'], $tplanSet[$itemID]['is_public']);
             if ($new_id > 0) {
                 $tplanMgr->copy_as($itemID, $new_id, null, $target_id, $user_id, null, $mappings);
             }
         }
     }
 }
 * @copyright 2007-2014, TestLink community 
 * @version   planEdit.php
 * @link      http://www.testlink.org/
 *
 *
 * @internal revisions
 * @since 1.9.13
 **/
require_once '../../config.inc.php';
require_once "common.php";
require_once "web_editor.php";
$editorCfg = getWebEditorCfg('testplan');
require_once require_web_editor($editorCfg['type']);
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$smarty = new TLSmarty();
$do_display = false;
$template = null;
$args = init_args($_REQUEST);
if (!$args->tproject_id) {
    $smarty->assign('title', lang_get('fatal_page_title'));
    $smarty->assign('content', lang_get('error_no_testprojects_present'));
    $smarty->display('workAreaSimple.tpl');
    exit;
}
$gui = initializeGui($db, $args, $editorCfg, $tproject_mgr);
$of = web_editor('notes', $_SESSION['basehref'], $editorCfg);
$of->Value = getItemTemplateContents('testplan_template', $of->InstanceName, $args->notes);
// Checks on testplan name, and testplan name<=>testplan id
 /**
  * doAdd2testplan
  *
  */
 function doAdd2testplan(&$argsObj, $request)
 {
     $smartyObj = new TLSmarty();
     $smartyObj->assign('attachments', null);
     $guiObj = $this->initGuiBean($argsObj);
     $guiObj->refreshTree = $argsObj->refreshTree ? 1 : 0;
     $tplan_mgr = new testplan($this->db);
     // $request['add2tplanid']
     // main key: testplan id
     // sec key : platform_id
     $item2link = null;
     if (isset($request['add2tplanid'])) {
         foreach ($request['add2tplanid'] as $tplan_id => $platformSet) {
             foreach ($platformSet as $platform_id => $dummy) {
                 $item2link = null;
                 $item2link['tcversion'][$argsObj->tcase_id] = $argsObj->tcversion_id;
                 $item2link['platform'][$platform_id] = $platform_id;
                 $item2link['items'][$argsObj->tcase_id][$platform_id] = $argsObj->tcversion_id;
                 $tplan_mgr->link_tcversions($tplan_id, $item2link, $argsObj->user_id);
             }
         }
         $identity = new stdClass();
         $identity->tproject_id = $argsObj->tproject_id;
         $identity->id = $argsObj->tcase_id;
         $identity->version_id = $argsObj->tcversion_id;
         $this->tcaseMgr->show($smartyObj, $guiObj, $identity, $this->grants);
         exit;
     }
     return $guiObj;
 }
Example #22
0
 * @copyright 	2007-2009, TestLink community 
 * @version    	CVS: $Id: tcAssign2Tplan.php,v 1.8 2010/05/20 18:20:46 franciscom Exp $
 * @link 		http://www.teamst.org/index.php
 *
 *
 *	@internal revisions
 *	20100520 - franciscom - BUGID 3480 - add to test plan problem when platforms exist
 *	20100514 - franciscom - BUGID 3189
 *	20100124 - franciscom - BUGID 3064 - add logic to manage ONLY ACTIVE test plans
 **/
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$tcase_mgr = new testcase($db);
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$glue = config_get('testcase_cfg')->glue_character;
$args = init_args();
$gui = initializeGui($args);
$getOpt = array('outputFormat' => 'map', 'addIfNull' => true);
$gui->platformSet = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt);
$options['output'] = 'essential';
$tcase_all_info = $tcase_mgr->get_by_id($args->tcase_id, testcase::ALL_VERSIONS, null, $options);
if (!is_null($tcase_all_info)) {
    foreach ($tcase_all_info as $tcversion_info) {
        if ($tcversion_info['id'] == $args->tcversion_id) {
            $version = $tcversion_info['version'];
            $gui->pageTitle = lang_get('test_case') . ':' . $tcversion_info['name'];
            $gui->tcaseIdentity = $tproject_mgr->getTestCasePrefix($args->tproject_id);
            $gui->tcaseIdentity .= $glue . $tcversion_info['tc_external_id'] . ':' . $tcversion_info['name'];
Example #23
0
/**
 * 
 *
 */
function launch_inner_exec(&$dbHandler, &$tplMgr)
{
    $itemCode = array('exec' => 'lib/execute/execNavigator.php');
    $op = array('status_ok' => true, 'msg' => '');
    // First check for keys in _GET that MUST EXIST
    // key: key on _GET, value: labelID defined on strings.txt
    $mandatoryKeys = array('item' => 'item_not_set', 'build_id' => 'build_id_not_set');
    foreach ($mandatoryKeys as $key => $labelID) {
        $op['status_ok'] = isset($_GET[$key]);
        if (!$op['status_ok']) {
            $op['msg'] = lang_get($labelID);
            break;
        }
    }
    if ($op['status_ok']) {
        $op['status_ok'] = isset($_GET['feature_id']);
        if (!$op['status_ok']) {
            $keySet = array('tplan_id' => 'testplan_not_set', 'tcversion_id' => 'tcversion_id', 'platform_id' => 'platform_id_not_set');
            foreach ($keySet as $key => $labelID) {
                $op['status_ok'] = isset($_GET[$key]);
                if (!$op['status_ok']) {
                    $op['msg'] = lang_get($labelID);
                    break;
                }
            }
        }
    }
    $args = init_args($dbHandler);
    if ($op['status_ok']) {
        // Set Environment
        $tplan_mgr = new testplan($dbHandler);
        $info = $tplan_mgr->get_by_id($args->tplan_id, array('output' => 'minimun'));
        if (is_null($info)) {
            die('ltx - tplan info does not exist');
        }
        $tproject_mgr = new testproject($dbHandler);
        $tproject_mgr->setSessionProject($info['tproject_id']);
        $op['status_ok'] = true;
    }
    if ($op['status_ok']) {
        // Build  name of function to call for doing the job.
        $pfn = 'process_' . $args->item;
        $ctx = array();
        $ctx['setting_testplan'] = $args->tplan_id;
        $ctx['setting_build'] = $args->build_id;
        $ctx['setting_platform'] = $args->platform_id;
        $ctx['tcversion_id'] = $args->tcversion_id;
        $ctx['tcase_id'] = 0;
        $ctx['user_id'] = $args->user_id;
        $jump_to = $pfn($dbHandler, $ctx);
        $op['status_ok'] = !is_null($jump_to['url']);
        $op['msg'] = $jump_to['msg'];
    }
    if ($op['status_ok']) {
        $treeframe = $itemCode[$args->item] . '?loadExecDashboard=0' . '&setting_testplan=' . $args->tplan_id . '&setting_build=' . $args->build_id . '&setting_platform=' . $args->platform_id;
        $tplMgr->assign('title', lang_get('main_page_title'));
        $tplMgr->assign('treewidth', TL_FRMWORKAREA_LEFT_FRAME_WIDTH);
        $tplMgr->assign('workframe', $jump_to['url']);
        $tplMgr->assign('treeframe', $treeframe);
        $tplMgr->display('frmInner.tpl');
    } else {
        echo $op['msg'];
        ob_end_flush();
        exit;
    }
}
Example #24
0
/**
 * Initialize the HTML select box for selection of a source build when
 * user wants to copy the user assignments on creation of a new build.
 * 
 * @author Andreas Simon
 * @param testplan $testplan_mgr reference to testplan manager object
 * @param object $argsObj reference to user input object
 * @return array $htmlMenu array structure with all information needed for the menu
 *
 * @internal revision
 * 20100820 - franciscom - refactoring to remove unneeded support/temp variables and 
 *						   event viewer complain due to foreach() over a null variable.
 */
function init_source_build_selector(&$testplan_mgr, &$argsObj)
{
    $htmlMenu = array('items' => null, 'selected' => null, 'build_count' => 0);
    $htmlMenu['items'] = $testplan_mgr->get_builds_for_html_options($argsObj->tplan_id);
    // get the number of existing execution assignments with each build
    if (!is_null($htmlMenu['items'])) {
        $htmlMenu['build_count'] = count($htmlMenu['items']);
        foreach ($htmlMenu['items'] as $key => $name) {
            $count = $testplan_mgr->assignment_mgr->get_count_of_assignments_for_build_id($key);
            $htmlMenu['items'][$key] = $name . " (" . $count . ")";
        }
        // if no build has been chosen yet, select the newest build by default
        if (!$argsObj->source_build_id) {
            $htmlMenu['selected'] = key($htmlMenu['items']);
        }
    }
    return $htmlMenu;
}
Example #25
0
/**
* Get info about user(s) role at test plan level,
* with indication about the nature of role: inherited or assigned.
* 
* To get a user role we consider a 3 layer model:
*          layer 1 - user           <--- uplayer
*          layer 2 - test project   <--- in this fuction we are interested in this level.
*          layer 3 - test plan
 
 args : $tplan_id
        $tproject_id
        [$user_id]
 
* @return array map with effetive_role in context ($tplan_id)
          key: user_id 
          value: map with keys:
                 login                (from users table - useful for debug)
                 user_role_id         (from users table - useful for debug)
                 uplayer_role_id      user role for test project
                 uplayer_is_inherited 1 -> uplayer role is inherited 
                                      0 -> uplayer role is written in table
                 effective_role_id    user role for test plan
                 is_inherited   
                 
 @internal revisions
 20101111 - franciscom - BUGID 4006: test plan is_public                    
*/
function get_tplan_effective_role(&$db, $tplan_id, $tproject, $user_id = null, $users = null)
{
    $tplan_mgr = new testplan($db);
    $tplan = $tplan_mgr->get_by_id($tplan_id);
    unset($tplan_mgr);
    $effective_role = get_tproject_effective_role($db, $tproject, $user_id, $users);
    foreach ($effective_role as $user_id => $row) {
        $isInherited = 1;
        $effective_role[$user_id]['uplayer_role_id'] = $effective_role[$user_id]['effective_role_id'];
        $effective_role[$user_id]['uplayer_is_inherited'] = $effective_role[$user_id]['is_inherited'];
        // Manage administrator exception DO NOT ENTER HERE
        if ($row['user']->globalRoleID != TL_ROLES_ADMIN && !$tplan['is_public']) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = TL_ROLES_NO_RIGHTS;
            $effective_role[$user_id]['effective_role'] = '<no rights>';
        }
        if (isset($row['user']->tplanRoles[$tplan_id])) {
            $isInherited = 0;
            $effective_role[$user_id]['effective_role_id'] = $row['user']->tplanRoles[$tplan_id]->dbID;
            $effective_role[$user_id]['effective_role'] = $row['user']->tplanRoles[$tplan_id];
        }
        $effective_role[$user_id]['is_inherited'] = $isInherited;
    }
    return $effective_role;
}
Example #26
0
function saveImportedResultData(&$db, $resultData, $context)
{
    if (!$resultData) {
        return;
    }
    $debugMsg = ' FUNCTION: ' . __FUNCTION__;
    $tables = tlObjectWithDB::getDBTables(array('executions', 'execution_bugs'));
    $l18n = array('import_results_tc_not_found' => '', 'import_results_invalid_result' => '', 'tproject_id_not_found' => '', 'import_results_ok' => '');
    foreach ($l18n as $key => $value) {
        $l18n[$key] = lang_get($key);
    }
    // Get Column definitions to get size dinamically instead of create constants
    $columnDef = array();
    $adodbObj = $db->get_dbmgr_object();
    $columnDef['execution_bugs'] = $adodbObj->MetaColumns($tables['execution_bugs']);
    $keySet = array_keys($columnDef['execution_bugs']);
    foreach ($keySet as $keyName) {
        if (($keylow = strtolower($keyName)) != $keyName) {
            $columnDef['execution_bugs'][$keylow] = $columnDef['execution_bugs'][$keyName];
            unset($columnDef['execution_bugs'][$keyName]);
        }
    }
    $user = new tlUser($context->userID);
    $user->readFromDB($db);
    $tcase_mgr = new testcase($db);
    $resulstCfg = config_get('results');
    $tcaseCfg = config_get('testcase_cfg');
    $resultMap = array();
    $tplan_mgr = null;
    $tc_qty = sizeof($resultData);
    if ($tc_qty) {
        $tplan_mgr = new testplan($db);
        $tproject_mgr = new testproject($db);
        $build_mgr = new build_mgr($db);
    }
    // Need to do checks on common settings
    //
    // test project exists
    //
    // test plan id:
    //              belongs to target test project
    //              is active
    // build id:
    //          belongs to target test plan
    //          is open
    //
    // platform id:
    //          is linked  to target test plan
    //
    // execution type if not present -> set to MANUAL
    //          if presente is valid i.e. inside the TL domain
    //
    $checks = array();
    $checks['status_ok'] = true;
    $checks['msg'] = null;
    $dummy = null;
    if (!is_null($context->tprojectID) && intval($context->tprojectID) > 0) {
        $dummy = array($tproject_mgr->get_by_id($context->tprojectID, array('output' => 'existsByID')));
    } else {
        if (!is_null($context->tprojectName)) {
            $dummy = $tproject_mgr->get_by_name($context->tprojectName, null, array('output' => 'existsByName'));
        }
    }
    $checks['status_ok'] = !is_null($dummy);
    if (!$checks['status_ok']) {
        $checks['msg'][] = sprintf($l18n['tproject_id_not_found'], $context->tprojectID);
    }
    if (!$checks['status_ok']) {
        foreach ($checks['msg'] as $warning) {
            $resultMap[] = array($warning);
        }
    }
    if ($doIt = $checks['status_ok']) {
        $context->tprojectID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    $dummy = null;
    if (!is_null($context->tplanID) && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->get_by_id($context->tplanID, array('output' => 'minimun'));
        if (!is_null($dummy)) {
            $dummy['id'] = $context->tplanID;
        }
    } else {
        if (!is_null($context->tplanName)) {
            $dummy = $tplan_mgr->get_by_name($context->tplanName, $context->tprojectID, array('output' => 'minimun'));
            if (!is_null($dummy)) {
                $dummy = $dummy[0];
            }
        }
    }
    if (!is_null($dummy)) {
        $context->tplanID = $dummy['id'];
    }
    if (intval($context->tprojectID) <= 0 && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->tree_manager->get_node_hierarchy_info($context->tplanID);
        $context->tprojectID = $dummy['parent_id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $dummy = null;
    $tplan_mgr->platform_mgr->setTestProjectID($context->tprojectID);
    if (!is_null($context->platformID) && intval($context->platformID) > 0) {
        $dummy = array($tplan_mgr->platform_mgr->getByID($context->platformID));
    } else {
        if (property_exists($context, 'platformName') && !is_null($context->platformName)) {
            if (!is_null($xx = $tplan_mgr->platform_mgr->getID($context->platformName))) {
                $dummy = array(0 => array('id' => $xx));
            }
        }
    }
    if (!is_null($dummy)) {
        $context->platformID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $optGB = array('tplan_id' => $context->tplanID, 'output' => 'minimun');
    $dummy = null;
    if (!is_null($context->buildID) && intval($context->buildID) > 0) {
        $dummy = array($build_mgr->get_by_id($context->buildID, $optGB));
    } else {
        if (!is_null($context->buildName)) {
            $dummy = $build_mgr->get_by_name($context->buildName, $optGB);
        }
    }
    if (!is_null($dummy)) {
        $context->buildID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    for ($idx = 0; $doIt && $idx < $tc_qty; $idx++) {
        $tester_id = 0;
        $tester_name = '';
        $using_external_id = false;
        $message = null;
        $status_ok = true;
        $tcase_exec = $resultData[$idx];
        // New attribute "execution type" makes old XML import files incompatible
        // Important NOTICE:
        // tcase_exec is passed BY REFERENCE to allow check_exec_values()change execution type if needed
        //
        $checks = check_exec_values($db, $tcase_mgr, $user_mgr, $tcaseCfg, $tcase_exec, $columnDef['execution_bugs']);
        $status_ok = $checks['status_ok'];
        if ($status_ok) {
            $tcase_id = $checks['tcase_id'];
            $tcase_external_id = trim($tcase_exec['tcase_external_id']);
            $tester_id = $checks['tester_id'];
            // external_id has precedence over internal id
            $using_external_id = $tcase_external_id != "";
        } else {
            foreach ($checks['msg'] as $warning) {
                $resultMap[] = array($warning);
            }
        }
        if ($status_ok) {
            $tcase_identity = $using_external_id ? $tcase_external_id : $tcase_id;
            $result_code = strtolower($tcase_exec['result']);
            $result_is_acceptable = isset($resulstCfg['code_status'][$result_code]) ? true : false;
            $notes = $tcase_exec['notes'];
            $message = null;
            $info_on_case = $tplan_mgr->getLinkInfo($context->tplanID, $tcase_id, $context->platformID);
            if (is_null($info_on_case)) {
                $message = sprintf($l18n['import_results_tc_not_found'], $tcase_identity);
            } else {
                if (!$result_is_acceptable) {
                    $message = sprintf($l18n['import_results_invalid_result'], $tcase_identity, $tcase_exec['result']);
                } else {
                    $info_on_case = current($info_on_case);
                    $tcversion_id = $info_on_case['tcversion_id'];
                    $version = $info_on_case['version'];
                    $notes = $db->prepare_string(trim($notes));
                    // N.B.: db_now() returns an string ready to be used in an SQL insert
                    //       example '2008-09-04', while $tcase_exec["timestamp"] => 2008-09-04
                    //
                    $execution_ts = $tcase_exec['timestamp'] != '' ? "'" . $tcase_exec["timestamp"] . "'" : $db->db_now();
                    if ($tester_id != 0) {
                        $tester_name = $tcase_exec['tester'];
                    } else {
                        $tester_name = $user->login;
                        $tester_id = $context->userID;
                    }
                    $addExecDuration = strlen($tcase_exec['execution_duration']) > 0 && is_numeric($tcase_exec['execution_duration']);
                    $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['executions']} (build_id,tester_id,status,testplan_id," . " tcversion_id,execution_ts,notes,tcversion_number,platform_id,execution_type" . ($addExecDuration ? ',execution_duration' : '') . ")" . " VALUES ({$context->buildID}, {$tester_id},'{$result_code}',{$context->tplanID}, " . " {$tcversion_id},{$execution_ts},'{$notes}', {$version}, " . " {$context->platformID}, {$tcase_exec['execution_type']}" . ($addExecDuration ? ",{$tcase_exec['execution_duration']}" : '') . ")";
                    $db->exec_query($sql);
                    if (isset($tcase_exec['bug_id']) && !is_null($tcase_exec['bug_id']) && is_array($tcase_exec['bug_id'])) {
                        $execution_id = $db->insert_id($tables['executions']);
                        foreach ($tcase_exec['bug_id'] as $bug_id) {
                            $bug_id = trim($bug_id);
                            $sql = " /* {$debugMsg} */ " . " SELECT execution_id AS check_qty FROM  {$tables['execution_bugs']} " . " WHERE bug_id = '{$bug_id}' AND execution_id={$execution_id} ";
                            $rs = $db->get_recordset($sql);
                            if (is_null($rs)) {
                                $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['execution_bugs']} (bug_id,execution_id)" . " VALUES ('" . $db->prepare_string($bug_id) . "', {$execution_id} )";
                                $db->exec_query($sql);
                            }
                        }
                    }
                    $message = sprintf($l18n['import_results_ok'], $tcase_identity, $version, $tester_name, $resulstCfg['code_status'][$result_code], $execution_ts);
                }
            }
        }
        if (!is_null($message)) {
            $resultMap[] = array($message);
        }
    }
    return $resultMap;
}
Example #27
0
 * @link 		http://www.teamst.org/index.php
 *
 * @internal Revisions:
 * 20091222 - eloff - fixed extraction of data to current data structures
 *
 *
**/
require_once '../../config.inc.php';
require_once 'common.php';
define('PCHART_PATH', '../../third_party/pchart');
include PCHART_PATH . "/pChart/pData.class";
include PCHART_PATH . "/pChart/pChart.class";
testlinkInitPage($db, true, false, "checkRights");
$resultsCfg = config_get('results');
$args = init_args();
$tplan_mgr = new testplan($db);
$totalsByPlatform = $tplan_mgr->getStatusTotalsByPlatform($args->tplan_id);
// new dBug($totalsByPlatform);
$totals = $totalsByPlatform[$args->platform_id]['details'];
unset($totals['total']);
$values = array();
$labels = array();
$series_color = array();
foreach ($totals as $key => $value) {
    $value = $value['qty'];
    $values[] = $value;
    $labels[] = lang_get($resultsCfg['status_label'][$key]) . " ({$value})";
    if (isset($resultsCfg['charts']['status_colour'][$key])) {
        $series_color[] = $resultsCfg['charts']['status_colour'][$key];
    }
    // else
Example #28
0
        break;
}
$getArguments = "&type=" . $args->doc_type;
if ($addTestPlanID) {
    $getArguments .= '&docTestPlanId=' . $args->tplan_id;
}
// generate tree
$tree = null;
$additionalArgs = '';
switch ($args->doc_type) {
    case 'testspec':
    case 'reqspec':
        break;
    case 'testplan':
    case 'testreport':
        $tplan_mgr = new testplan($db);
        $tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
        $testplan_name = htmlspecialchars($tplan_info['name']);
        $latestBuild = $tplan_mgr->get_max_build_id($args->tplan_id);
        $filters = new stdClass();
        $additionalInfo = new stdClass();
        // ----- BUGID 3451 and related ---------------------------------------
        // Notice: these variables were wrong since the changes to filtering system,
        // but they did not cause the bug responsible for 3451.
        // See print.inc.php for the real solution!
        // Set of filters Off
        //		$filters->keyword_id = null;
        //		$filters->keywordsFilterType = null;
        //		$filters->tc_id = null;
        //		$filters->assignedTo = null;
        //		$filters->status = null;
function migrate_test_plans(&$source_db, &$target_db, &$tplans, &$old_new)
{
    $tplan_mgr = new testplan($target_db);
    $tplan_qty = count($tplans);
    echo "<pre>   Test plans to migrate: " . $tplan_qty;
    echo "</pre>";
    foreach ($tplans as $item_id => $idata) {
        $old_prodid = intval($idata['prodid']);
        $tproj_id = 0;
        if ($old_prodid > 0) {
            $tproj_id = $old_new['product'][$old_prodid];
        }
        $old_new['tplan'][$item_id] = $tplan_mgr->create($idata['name'], $idata['notes'], $tproj_id);
        //echo "OLD TPlan ID {$item_id} {$idata['name']} -> {$old_new['tplan'][$item_id]} <br>";
        // 20070130 - jbarchibald
        if (intval($idata['active']) == 0) {
            $sql = "UPDATE testplans SET active=0 WHERE testplans.id={$old_new['tplan'][$item_id]}";
            $target_db->exec_query($sql);
        }
    }
}
/**
 * Migrate the existing user assignments for all test plans and test projects.
 * All test case execution assignments will be stored per build in TL 1.9.
 * So all tester assignments for the test cases in each test plan will be updated 
 * with the ID of the newest available build for that test plan.
 * 
 * @author Andreas Simon
 * @param database $dbHandler
 * @param array $tableSet
 */
function migrate_user_assignments(&$dbHandler, $tableSet)
{
    //$starttime = microtime(true);
    echo 'Step - User Execution Assignment Migration - STARTED <br> ';
    echo 'Working - User Execution Assignment Migration <br> ';
    $testplan_mgr = new testplan($dbHandler);
    // get assignment type for execution
    $assignment_mgr = new assignment_mgr($dbHandler);
    $assignment_types = $assignment_mgr->get_available_types();
    $execution = $assignment_types['testcase_execution']['id'];
    // get table names
    $ua = $tableSet['user_assignments'];
    $tp_tcv = $tableSet['testplan_tcversions'];
    // get list of test plan IDs from the assigned test cases
    $sql = " SELECT distinct T.testplan_id " . " FROM {$ua} UA, {$tp_tcv} T " . " WHERE UA.feature_id = T.id " . " AND (UA.type={$execution} OR UA.type IS NULL) ";
    $testplans = $dbHandler->fetchColumnsIntoArray($sql, 'testplan_id');
    // Get the newest (max) build ID for each of these test plan IDs and store them.
    // In $testplan_builds, we then have an array consisting of testplan_id => max_build_id
    // If no build for a test plan is found, its assignments will not be changed (build_id=0).
    $testplan_builds = array();
    if (!is_null($testplans)) {
        foreach ($testplans as $key => $tp_id) {
            // first we try to get an active build
            $max_build_id = $testplan_mgr->get_max_build_id($tp_id, testplan::GET_ACTIVE_BUILD);
            // if there is no active build, we get the max id no matter if it is active or not
            if ($max_build_id == 0) {
                $max_build_id = $testplan_mgr->get_max_build_id($tp_id);
            }
            if ($max_build_id > 0) {
                $testplan_builds[$tp_id] = $max_build_id;
            }
        }
        // now update all assignments for these test plans
        foreach ($testplan_builds as $testplan_id => $build_id) {
            $subquery = " SELECT id as feature_id FROM {$tp_tcv} " . " WHERE testplan_id = {$testplan_id} ";
            // This update with ALIAS is not LIKED by Postgres
            //
            // OK
            // UPDATE user_assignments UA
            // SET build_id = 2  WHERE UA.feature_id IN
            // ( SELECT id AS feature_id FROM testplan_tcversions  WHERE testplan_id = 70)
            //
            // if used UA.build_id -> problems on Postgre 8.4
            // Message:
            // ERROR:  column "ua" of relation "user_assignments" does not exist
            // LINE 2: SET UA.build_id = 2  WHERE UA.feature_id IN
            // $sql = " UPDATE {$ua} UA " .
            //        " SET UA.build_id = {$build_id} " .
            //        " WHERE UA.feature_id IN($subquery) " .
            //        " AND (UA.type={$execution} OR UA.type IS NULL) ";
            //
            // 20101212 - franciscom
            $sql = " UPDATE {$ua} " . " SET build_id = {$build_id} " . " WHERE feature_id IN({$subquery}) " . " AND (type={$execution} OR type IS NULL) ";
            $dbHandler->exec_query($sql);
        }
    }
    // delete objects
    unset($testplan_mgr);
    // check how long the function is running on huge databases...
    //$endtime = microtime(true) - $starttime;
    //echo "<br/>migrate_user_assignments() needed $endtime seconds to finish<br/>";
    echo 'Step - User Execution Assignment Migration - Finished <br><br> ';
}