function initializeGui(&$dbHandler, $argsObj)
{
    $issueTrackerMgr = new tlIssueTracker($dbHandler);
    $gui = new stdClass();
    $gui->items = $issueTrackerMgr->getAll(array('output' => 'add_link_count', 'checkEnv' => true));
    $gui->user_feedback = $argsObj->user_feedback;
    $gui->canManage = $argsObj->canManage;
    $gui->tproject_id = $argsObj->tproject_id;
    $gui->body_onload = '';
    return $gui;
}
function getIssues(&$dbHandler, &$execSet, $tprojectID)
{
    $it_mgr = new tlIssueTracker($dbHandler);
    $its = $it_mgr->getInterfaceObject($tprojectID);
    unset($it_mgr);
    // we will see in future if we can use a better algorithm
    $issues = array();
    $tcv2loop = array_keys($execSet);
    foreach ($tcv2loop as $tcvid) {
        $execQty = count($execSet[$tcvid]);
        for ($idx = 0; $idx < $execQty; $idx++) {
            $exec_id = $execSet[$tcvid][$idx]['execution_id'];
            $dummy = get_bugs_for_exec($dbHandler, $its, $exec_id);
            if (count($dummy) > 0) {
                $issues[$exec_id] = $dummy;
            }
        }
    }
    return $issues;
}
Exemple #3
0
require_once 'exec.inc.php';
// used for bug string lookup
require_once 'exttable.class.php';
testlinkInitPage($db, true, false, "checkRights");
$gui = new stdClass();
$gui->warning_msg = '';
$gui->tableSet = null;
$templateCfg = templateConfiguration();
$args = init_args();
// 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();
<?php

/**
 * TestLink Open Source Project - http://testlink.sourceforge.net/ 
 *
 * @filesource	test.jirasoapInterface.class.php
 * @author		Francisco Mancardi
 *
 * @internal revisions
 *
**/
require_once '../../../../config.inc.php';
require_once 'common.php';
$it_mgr = new tlIssueTracker($db);
$itt = $it_mgr->getTypes();
$systems = $it_mgr->getSystems();
new dBug($itt);
new dBug($systems);
// last test ok:
$cfg = "<issuetracker>\n" . "<dbhost>192.168.1.201</dbhost>\n" . "<dbname>jiradb</dbname>\n" . "<dbtype>mysql</dbtype>\n" . "<dbuser>root</dbuser>\n" . "<dbpassword>mysqlroot</dbpassword>\n" . "<uribase>http://testlink.atlassian.net/</uribase>\n" . "<uriview>http://testlink.atlassian.net/browse/</uriview>\n" . "<uricreate>http://testlink.atlassian.net/secure/CreateIssue!default.jspa</uricreate>\n" . "</issuetracker>\n";
echo '<hr><br>';
echo "<b>Testing  BTS Integration - jiradbInterface </b>";
echo '<hr><br>';
echo "Configuration settings<br>";
echo "<pre><xmp>" . $cfg . "</xmp></pre>";
echo '<hr><br><br>';
// $safe_cfg = str_replace("\n",'',$cfg);
// echo $safe_cfg;
echo 'Creating INTERFACE<br>';
// @20121215 -> 6 => jiradbInterface
$its = new jiradbInterface(6, $cfg);
Exemple #5
0
/**
 *
 */
function getIssueTracker(&$dbHandler, $argsObj, &$guiObj)
{
    $its = null;
    $tprojectMgr = new testproject($dbHandler);
    $info = $tprojectMgr->get_by_id($argsObj->tproject_id);
    $guiObj->issueTrackerCfg = new stdClass();
    $guiObj->issueTrackerCfg->createIssueURL = null;
    $guiObj->issueTrackerCfg->VerboseID = '';
    $guiObj->issueTrackerCfg->VerboseType = '';
    $guiObj->issueTrackerCfg->bugIDMaxLength = 0;
    $guiObj->issueTrackerCfg->bugSummaryMaxLength = 100;
    // MAGIC
    $guiObj->issueTrackerCfg->tlCanCreateIssue = false;
    $guiObj->issueTrackerCfg->tlCanAddIssueNote = true;
    if ($info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $issueTrackerCfg = $it_mgr->getLinkedTo($argsObj->tproject_id);
        if (!is_null($issueTrackerCfg)) {
            $its = $it_mgr->getInterfaceObject($argsObj->tproject_id);
            $guiObj->issueTrackerCfg->VerboseType = $issueTrackerCfg['verboseType'];
            $guiObj->issueTrackerCfg->VerboseID = $issueTrackerCfg['issuetracker_name'];
            $guiObj->issueTrackerCfg->bugIDMaxLength = $its->getBugIDMaxLength();
            $guiObj->issueTrackerCfg->createIssueURL = $its->getEnterBugURL();
            $guiObj->issueTrackerCfg->bugSummaryMaxLength = $its->getBugSummaryMaxLength();
            $guiObj->issueTrackerCfg->tlCanCreateIssue = method_exists($its, 'addIssue');
            $guiObj->issueTrackerCfg->tlCanAddIssueNote = method_exists($its, 'addNote');
        }
    }
    return array($its, $issueTrackerCfg);
}
 * 
 * @filesource	getissuetrackercfgtemplate.php
 * @package 	TestLink
 * @author 		Francisco Mancardi - francisco.mancardi@gmail.com
 * @copyright 	2012, TestLink community 
 *
 * @internal revisions
 * @since 1.9.4
 * 20120311 - franciscom - TICKET 4904: integrate with ITS on test project basis
 **/
require_once '../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
$info = array('sucess' => true, 'cfg' => '');
$type = intval($_REQUEST['type']);
$itemMgr = new tlIssueTracker($db);
$itt = $itemMgr->getTypes();
if (isset($itt[$type])) {
    unset($itt);
    $iname = $itemMgr->getImplementationForType($type);
    $info['cfg'] = stream_resolve_include_path($iname . '.class.php');
    // Notes for developers
    // Trying to use try/catch to manage missing interface file, results on nothing good.
    // This way worked.
    if (stream_resolve_include_path($iname . '.class.php') !== FALSE) {
        $info['cfg'] = '<pre><xmp>' . $iname::getCfgTemplate() . '</xmp></pre>';
    } else {
        $info['cfg'] = sprintf(lang_get('issuetracker_interface_not_implemented'), $iname);
    }
} else {
    $info['cfg'] = sprintf(lang_get('issuetracker_invalid_type'), $type);
/**
 * TestLink Open Source Project - http://testlink.sourceforge.net/
 * This script is distributed under the GNU General Public License 2 or later.
 *
 * @filesource  issueTrackerView.php
 *
 * @author   francisco.mancardi@gmail.com
 * @internal revisions
 * 
 *
**/
require_once dirname(__FILE__) . "/../../config.inc.php";
require_once "common.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$issueTrackerMgr = new tlIssueTracker($db);
$gui = new stdClass();
$args = init_args();
$gui->items = $issueTrackerMgr->getAll(array('output' => 'add_link_count', 'checkEnv' => true));
$gui->canManage = $args->currentUser->hasRight($db, "issuetracker_management");
$gui->user_feedback = $args->user_feedback;
if ($args->id > 0) {
    $gui->items[$args->id]['connection_status'] = $issueTrackerMgr->checkConnection($args->id) ? 'ok' : 'ko';
}
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/**
 * @return object returns the arguments for the page
 */
function init_args()
 function getIssueTrackerMgr($id)
 {
     $its = array(false, null);
     $info = $this->get_by_id($id);
     if ($info['issue_tracker_enabled']) {
         $it_mgr = new tlIssueTracker($this->db);
         $its = $it_mgr->getInterfaceObject($id);
         unset($it_mgr);
     }
     return array($info['issue_tracker_enabled'], $its);
 }
function init_args(&$dbHandler, $cfgObj)
{
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    // Settings and Filters that 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 ...
    getSettingsAndFilters($args);
    manageCookies($args, $cfgObj);
    // need to comunicate with left frame, will do via $_SESSION and form_token
    if (($args->treeFormToken = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0) > 0) {
        // do not understand why this do not works OK
        // $_SESSION[$args->treeFormToken]['loadExecDashboard'] = false;
        $_SESSION['loadExecDashboard'][$args->treeFormToken] = false;
    }
    if (is_null($args->refreshTree)) {
        $args->refreshTree = isset($_REQUEST['refresh_tree']) ? intval($_REQUEST['refresh_tree']) : 0;
    }
    $args->basehref = $_SESSION['basehref'];
    $args->assignTask = isset($_REQUEST['assignTask']) ? 1 : 0;
    $args->createIssue = isset($_REQUEST['createIssue']) ? 1 : 0;
    $args->copyIssues = isset($_REQUEST['copyIssues']) ? 1 : 0;
    $args->tc_id = null;
    $args->tsuite_id = null;
    $args->user = $_SESSION['currentUser'];
    $args->user_id = intval($args->user->dbID);
    $args->id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
    $args->caller = isset($_REQUEST['caller']) ? $_REQUEST['caller'] : 'exec_feature';
    $args->reload_caller = false;
    $args->doExec = isset($_REQUEST['execute_cases']) ? 1 : 0;
    $args->doDelete = isset($_REQUEST['do_delete']) ? $_REQUEST['do_delete'] : 0;
    // $args->doMoveNext = isset($_REQUEST['move2next']) ? $_REQUEST['move2next'] : 0;
    $args->doMoveNext = isset($_REQUEST['move2next']) ? 1 : 0;
    $args->doMovePrevious = isset($_REQUEST['move2previous']) ? $_REQUEST['move2previous'] : 0;
    $args->moveTowards = $args->doMoveNext ? 'forward' : ($args->doMovePrevious ? 'backward' : null);
    // can be a list, will arrive via form POST
    $args->tc_versions = isset($_REQUEST['tc_version']) ? $_REQUEST['tc_version'] : null;
    $key2loop = array('level' => '', 'status' => null, 'statusSingle' => null, 'do_bulk_save' => 0, 'save_results' => 0, 'save_and_next' => 0, 'save_and_exit' => 0);
    foreach ($key2loop as $key => $value) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : $value;
    }
    // See details on: "When nullify filter_status - 20080504" in this file
    if ($args->level == 'testcase' || is_null($args->filter_status) || !is_array($args->filter_status) && trim($args->filter_status) == '') {
        $args->filter_status = null;
    } else {
        // 20130306 - franciscom
        // This (without the strlen() check) generated issue 5541: When "Result" filter is used ...
        // at least when result DIFFERENT that NOT RUN is used on filter
        //
        // 20120616 - franciscom
        // some strange thing to investigate, seems that unserialize is invoked
        // under the hood when getting data from $_REQUEST, then this piece
        // of code not only will be useless BUT WRONG, because will try
        // to unserialize something that IS NOT SERIALIZED!!!!
        // After TICKET 6651, may be need to limit size of $args->filter_status
        if (is_string($args->filter_status) && strlen($args->filter_status) > 1) {
            $args->filter_status = json_decode($args->filter_status);
        }
    }
    switch ($args->level) {
        case 'testcase':
            $args->tc_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            if (!is_null($args->tc_versions)) {
                $args->tc_id = current($args->tc_versions);
                $args->id = $args->tc_id;
                $args->version_id = key($args->tc_versions);
            }
            $args->tsuite_id = null;
            break;
        case 'testsuite':
            $args->tsuite_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null;
            $args->tc_id = null;
            break;
    }
    $args->tsuitesInBranch = null;
    if (!is_null($args->tsuite_id)) {
        // will get all test suites in this branch, in order to limit amount of data returned
        // by functions/method that collect linked tcversions
        // THIS COLLECT ONLY FIRST LEVEL UNDER test suite, do not do deep search
        // Need to understand is still needed
        $tsuite_mgr = new testsuite($dbHandler);
        $xx = $tsuite_mgr->get_children($args->tsuite_id, array('details' => 'id'));
        $ldx = count($xx);
        $xx[$ldx] = $args->tsuite_id;
        $args->tsuitesInBranch = $xx;
        unset($tsuite_mgr);
    }
    // TICKET 5630: Test Results by direct link ...
    $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'];
    }
    // Do this only on single execution mode
    // get issue tracker config and object to manage TestLink - BTS integration
    $args->itsCfg = null;
    $its = null;
    $tproject_mgr = new testproject($dbHandler);
    $info = $tproject_mgr->get_by_id($args->tproject_id);
    unset($tproject_mgr);
    $bug_summary['minLengh'] = 1;
    $bug_summary['maxLengh'] = 1;
    if ($args->issue_tracker_enabled = $info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $args->itsCfg = $it_mgr->getLinkedTo($args->tproject_id);
        $its = $it_mgr->getInterfaceObject($args->tproject_id);
        if (!is_null($args->itsCfg) && !is_null($its)) {
            $bug_summary['maxLengh'] = $its->getBugSummaryMaxLength();
        }
        unset($it_mgr);
    }
    initArgsIssueOnTestCase($args, $bug_summary);
    initArgsIssueOnSteps($args, $bug_summary);
    return array($args, $its);
}
/**
 * render Test Case content for generated documents
 * 
 * @param $integer db DB connection identifier 
 * @return string generated html code
 *
 * @internal revisions
 */
function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context, $indentLevel)
{
    static $req_mgr;
    static $tc_mgr;
    static $build_mgr;
    static $tplan_mgr;
    static $tplan_urgency;
    static $labels;
    static $tcase_prefix;
    static $userMap = array();
    static $cfg;
    static $tables = null;
    static $force = null;
    static $bugInterfaceOn = false;
    static $its;
    static $buildCfields;
    static $statusL10N;
    static $docRepo;
    static $st;
    $code = null;
    $tcInfo = null;
    $tcResultInfo = null;
    $tcase_pieces = null;
    $id = $node['id'];
    $level = $indentLevel;
    $prefix = isset($context['prefix']) ? $context['prefix'] : null;
    $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
    $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
    $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0;
    $build_id = isset($context['build_id']) ? $context['build_id'] : 0;
    // init static elements
    if (!$tables) {
        $st = new stdClass();
        $tables = tlDBObject::getDBTables(array('executions', 'builds', 'execution_tcsteps'));
        $tc_mgr = new testcase($db);
        $tplan_urgency = new testPlanUrgency($db);
        $build_mgr = new build_mgr($db);
        $tplan_mgr = new testplan($db);
        $req_mgr = new requirement_mgr($db);
        list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options);
        if (!is_null($prefix)) {
            $tcase_prefix = $prefix;
        } else {
            list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id);
        }
        $tcase_prefix .= $cfg['testcase']->glue_character;
        $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false;
        $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false;
        $its = null;
        $tproject_mgr = new testproject($db);
        $info = $tproject_mgr->get_by_id($tprojectID);
        $bugInterfaceOn = $info['issue_tracker_enabled'];
        if ($info['issue_tracker_enabled']) {
            $it_mgr = new tlIssueTracker($db);
            $its = $it_mgr->getInterfaceObject($tprojectID);
            unset($it_mgr);
        }
        $statusL10N = null;
        foreach ($cfg['results']['code_status'] as $vc => $vstat) {
            if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) {
                $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]);
            }
        }
        $docRepo = tlAttachmentRepository::create($db);
        $st->locationFilters = $tc_mgr->buildCFLocationMap();
        // change table style in case of single TC printing to not be indented
        $st->table_style = "";
        if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) {
            $st->table_style = 'style="margin-left: 0;"';
        }
        $st->cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => ' colspan = "' . ($cfg['tableColspan'] - 1) . '" ');
        $info = null;
    }
    /** 
     * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, 
     * using existent methods - franciscom - 20090329 
     * Need to get CF with execution scope
     */
    $exec_info = null;
    $getByID['filters'] = null;
    $opt = array();
    $opt['step_exec_notes'] = isset($options['step_exec_notes']) && $options['step_exec_notes'];
    $opt['step_exec_status'] = isset($options['step_exec_status']) && $options['step_exec_status'];
    switch ($options["docType"]) {
        case DOC_TEST_SPEC:
            $getByID['tcversion_id'] = testcase::LATEST_VERSION;
            $getExecutions = false;
            break;
        case SINGLE_TESTCASE:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
        default:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status'];
            break;
    }
    if ($getExecutions) {
        // Thanks to Evelyn from Cortado, have found a very old issue never reported.
        // 1. create TC-1A VERSION 1
        // 2. add to test plan and execute FAILED ON BUILD 1
        // 3. Request Test Report (Test Plan EXECUTION REPORT).
        //    You will get spec for VERSION 1 and result for VERSION 1 - OK cool!
        // 4. create VERSION 2
        // 5. update linked Test Case Versions
        // 6. do nothing more than repeat step 3
        //    without this fix you will get
        //    You will get spec for VERSION 2 and result for VERSION 1 - Hmmm
        //    and in addition is not clear that execution was on VERSION 1 . No GOOD!!
        //
        // HOW has been fixed ?
        // Getting info about THE CURRENT LINKED test case version and looking for
        // exec info for this.
        //
        // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided
        //
        //
        // Get Linked test case version
        $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id);
        $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " E.execution_type, E.execution_duration, " . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON B.id = E.build_id " . " WHERE 1 = 1 ";
        if (isset($context['exec_id'])) {
            $sql .= " AND E.id=" . intval($context['exec_id']);
        } else {
            $sql .= " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']);
            if ($build_id > 0) {
                $sql .= " AND E.build_id = " . intval($build_id);
            } else {
                // We are looking for LATEST EXECUTION of CURRENT LINKED test case version
                $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']);
            }
            $sql .= " ORDER BY execution_id DESC";
        }
        $exec_info = $db->get_recordset($sql, null, 1);
        $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id'];
        $getByID['filters'] = null;
        $linkedItem = null;
        if (!is_null($exec_info)) {
            $getByID['tcversion_id'] = null;
            $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']);
            if (isset($options['build_cfields']) && $options['build_cfields']) {
                if (!isset($buildCfields[$exec_info[0]['build_id']])) {
                    $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID);
                }
            }
        }
    }
    $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true, 'renderImageInline' => true));
    if ($tcInfo) {
        $tcInfo = $tcInfo[0];
    }
    $external_id = $tcase_prefix . $tcInfo['tc_external_id'];
    $name = htmlspecialchars($node['name']);
    $cfields = array('specScope' => null, 'execScope' => null);
    if ($options['cfields']) {
        // Get custom fields that has specification scope
        // Custom Field values at Test Case VERSION Level
        foreach ($st->locationFilters as $fkey => $fvalue) {
            $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $st->cfieldFormatting, $tcInfo['id']);
        }
        if (!is_null($exec_info)) {
            $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($tcInfo['id'], 'execution', null, $exec_info[0]['execution_id'], $tplan_id, $tprojectID, $st->cfieldFormatting);
        }
    }
    if ($options['toc']) {
        // EXTERNAL ID added
        $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>';
        $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>';
    }
    $code .= '<p>&nbsp;</p><div> <table class="tc" width="90%" ' . $st->table_style . '>';
    $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name;
    // add test case version
    switch ($env->reportType) {
        case DOC_TEST_PLAN_DESIGN:
            $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version'];
            break;
        case DOC_TEST_PLAN_EXECUTION:
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $version_number = $tcInfo['version'];
            break;
        default:
            $version_number = $tcInfo['version'];
            break;
    }
    if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) {
        $code .= '&nbsp;<span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>';
    }
    $code .= "</th></tr>\n";
    if ($options['author']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']);
        if (isset($options['displayDates']) && $options['displayDates']) {
            $dummy = null;
            $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']);
        }
        $code .= "</td></tr>\n";
        if ($tcInfo['updater_id'] > 0) {
            // add updater if available and differs from author OR forced
            if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) {
                $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']);
                if (isset($options['displayDates']) && $options['displayDates']) {
                    $dummy = null;
                    $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']);
                }
                $code .= "</td></tr>\n";
            }
        }
    }
    if ($options['body'] || $options['summary']) {
        $tcase_pieces = array('summary');
    }
    if ($options['body']) {
        $tcase_pieces[] = 'preconditions';
    }
    if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) {
        $tcase_pieces[] = 'steps';
    }
    if (!is_null($tcase_pieces)) {
        // Check user rights in order to understand if can delete attachments here
        //   function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false)
        // $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
        // $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
        $canManageAttachments = false;
        if (isset($context['user']) && !is_null($context['user'])) {
            $canManageAttachments = $context['user']->hasRight($db, 'testplan_execute', $tprojectID, $tplan_id);
        }
        // Multiple Test Case Steps Feature
        foreach ($tcase_pieces as $key) {
            if ($key == 'steps') {
                if (isset($cfields['specScope']['before_steps_results'])) {
                    $code .= $cfields['specScope']['before_steps_results'];
                }
                if (!is_null($tcInfo[$key]) && $tcInfo[$key] != '') {
                    $td_colspan = 3;
                    $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>';
                    $sxni = null;
                    if ($opt['step_exec_notes'] || $opt['step_exec_status']) {
                        $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']);
                        if ($opt['step_exec_notes']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>';
                        }
                        if ($opt['step_exec_status']) {
                            $td_colspan++;
                            $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>';
                        }
                    }
                    $code .= '</tr>';
                    $loop2do = count($tcInfo[$key]);
                    for ($ydx = 0; $ydx < $loop2do; $ydx++) {
                        $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>';
                        $nike = !is_null($sxni) && isset($sxni[$tcInfo[$key][$ydx]['id']]) && !is_null($sxni[$tcInfo[$key][$ydx]['id']]);
                        if ($opt['step_exec_notes']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $sxni[$tcInfo[$key][$ydx]['id']]['notes'];
                            }
                            $code .= '</td>';
                        }
                        if ($opt['step_exec_status']) {
                            $code .= '<td>';
                            if ($nike) {
                                $code .= $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']];
                            }
                            $code .= '</td>';
                        }
                        $code .= '</tr>';
                        // Attachment management
                        if ($getExecutions) {
                            if (isset($sxni[$tcInfo[$key][$ydx]['id']])) {
                                $attachInfo = getAttachmentInfos($docRepo, $sxni[$tcInfo[$key][$ydx]['id']]['id'], $tables['execution_tcsteps'], true, 1);
                                if (!is_null($attachInfo)) {
                                    $code .= '<tr><td colspan="' . $td_colspan . '">';
                                    $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                                    foreach ($attachInfo as $fitem) {
                                        $code .= '<form method="POST" name="fda' . $fitem['id'] . '" ' . ' id="fda' . $fitem['id'] . "' " . ' action="' . $env->base_href . 'lib/execute/execPrint.php">';
                                        $code .= '<input type="hidden" name="id" value="' . intval($context['exec_id']) . '">';
                                        $code .= '<input type="hidden" name="deleteAttachmentID" value="' . intval($fitem['id']) . '">';
                                        if ($fitem['is_image']) {
                                            $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                                            $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '">';
                                        } else {
                                            $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a>';
                                        }
                                        $code .= '<input type="image" alt="' . $labels['alt_delete_attachment'] . '"' . 'src="' . $env->base_href . TL_THEME_IMG_DIR . 'trash.png"></li></form>';
                                    }
                                    $code .= '</td></tr>';
                                }
                            }
                        }
                        // $getExecutions
                    }
                }
            } else {
                // disable the field if it's empty
                if ($tcInfo[$key] != '') {
                    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>";
                }
            }
        }
    }
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
    // This is what have been choosen DURING DESIGN, but may be we can choose at DESIGN
    // manual and the execute AUTO, or may be choose AUTO and execute MANUAL.
    // After report on MANTIS, seems that we need to provide in output two values:
    // DESIGN execution type
    // EXECUTION execution type
    switch ($tcInfo['execution_type']) {
        case TESTCASE_EXECUTION_TYPE_AUTO:
            $code .= $labels['execution_type_auto'];
            break;
        case TESTCASE_EXECUTION_TYPE_MANUAL:
        default:
            $code .= $labels['execution_type_manual'];
            break;
    }
    $code .= "</td></tr>\n";
    //
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration'];
    $code .= "</td></tr>\n";
    if (isset($options['importance']) && $options['importance']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']];
        $code .= "</td></tr>\n";
    }
    // print priority when printing test plan
    if (isset($options['priority']) && $options['priority']) {
        // Get priority of this tc version for this test plan by using testplanUrgency class.
        // Is there maybe a better method than this one?
        $filters = array('tcversion_id' => $tcInfo['id']);
        $opt = array('details' => 'tcversion');
        $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt);
        $prio = $prio_info[$tcInfo['id']]['priority_level'];
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio];
        $code .= "</td></tr>\n";
    }
    // Spacer
    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>";
    $code .= $cfields['specScope']['standard_location'] . $cfields['execScope'];
    //
    $cfields = null;
    $prio_info = null;
    // $code = null;
    // 20140813
    $relSet = $tc_mgr->getRelations($id);
    if (!is_null($relSet['relations'])) {
        // $fx = str_repeat('&nbsp;',5); // MAGIC allowed
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['relations'] . '</span></td>';
        $code .= '<td>';
        for ($rdx = 0; $rdx < $relSet['num_relations']; $rdx++) {
            if ($relSet['relations'][$rdx]['source_id'] == $id) {
                $ak = 'source_localized';
            } else {
                $ak = 'destination_localized';
            }
            $code .= htmlspecialchars($relSet['relations'][$rdx][$ak]) . ' - ' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['fullExternalID']) . ':' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['name']) . '<br>';
        }
        $code .= '</td></tr>';
    }
    $relSet = null;
    // collect REQ for TC
    if ($options['requirement']) {
        $requirements = $req_mgr->get_all_for_tcase($id);
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        if (sizeof($requirements)) {
            foreach ($requirements as $req) {
                $code .= htmlspecialchars($req['req_doc_id'] . ":  " . $req['title']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br />';
        }
        $code .= "</td></tr>\n";
    }
    $requirements = null;
    // collect keywords for TC
    if ($options['keyword']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        $kwSet = $tc_mgr->getKeywords($id, null, array('fields' => 'keyword_id,keywords.keyword'));
        if (sizeof($kwSet)) {
            foreach ($kwSet as $kw) {
                $code .= htmlspecialchars($kw['keyword']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br>';
        }
        $code .= "</td></tr>\n";
    }
    $kwSet = null;
    // Attachments
    $attachSet = (array) $tc_mgr->getAttachmentInfos($id);
    if (count($attachSet) > 0) {
        $code .= '<tr><td> <span class="label">' . $labels['attached_files'] . '</span></td>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 2) . '"><ul>';
        foreach ($attachSet as $item) {
            $fname = "";
            if ($item['title']) {
                $fname .= htmlspecialchars($item['title']) . " : ";
            }
            $fname .= htmlspecialchars($item['file_name']);
            $code .= "<li>{$fname}</li>";
            if ($item['is_image']) {
                $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
            } else {
                $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>';
            }
        }
        $code .= "</ul></td></tr>";
    }
    $attachSet = null;
    // generate test results data for test report
    if ($options['passfail']) {
        $tsp = $cfg['tableColspan'] - 1;
        $code .= '<tr style="' . "font-weight: bold;background: #EEE;text-align: left;" . '">' . '<td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['execution_details'] . '</td>' . '<td colspan="' . $tsp . '">' . "&nbsp;" . "</b></td></tr>\n";
        $bn = '';
        switch ($env->reportType) {
            case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
                $ib = $build_mgr->get_by_id($build_id);
                $bn = htmlspecialchars($ib['name']);
                break;
            case DOC_TEST_PLAN_EXECUTION:
                if ($exec_info) {
                    $bn = htmlspecialchars($exec_info[0]['build_name']);
                }
                break;
        }
        if ($bn != '') {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['build'] . '</td>' . '<td ' . $tsp . '>' . $bn . "</b></td></tr>\n";
        }
        if (isset($node['assigned_to'])) {
            $crew = explode(',', $node['assigned_to']);
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['assigned_to'] . '</td>' . '<td colspan="' . $tsp . '">';
            $xdx = 0;
            foreach ($crew as $mm) {
                if ($xdx != 0) {
                    $code .= ',';
                }
                $xdx = -1;
                echo $mm . '<br>';
                $code .= gendocGetUserName($db, $mm);
            }
            $code .= "</td></tr>\n";
        }
        if ($exec_info) {
            $settings['cfg'] = $cfg;
            $settings['lbl'] = $labels;
            $settings['opt'] = array('show_notes' => $options['notes']);
            $settings['colspan'] = $cfg['tableColspan'] - 1;
            $code .= buildTestExecResults($db, $its, $exec_info, $settings, $buildCfields);
            // Get Execution Attachments
            $execAttachInfo = getAttachmentInfos($docRepo, $exec_info[0]['execution_id'], $tables['executions'], true, 1);
            if (!is_null($execAttachInfo)) {
                $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">';
                $code .= '<b>' . $labels['exec_attachments'] . '</b><br>';
                foreach ($execAttachInfo as $fitem) {
                    if ($fitem['is_image']) {
                        $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>";
                        $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '"> </li>';
                    } else {
                        $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a></li>';
                    }
                }
                $code .= '</td></tr>';
            }
        } else {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['report_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n";
        }
        $execAttachInfo = null;
        $exec_info = null;
    }
    $code .= "</table>\n</div>\n";
    return $code;
}
Exemple #11
0
function itsProcess(&$dbHandler, $argsObj, &$guiObj)
{
    $its = null;
    $tprojectMgr = new testproject($dbHandler);
    $info = $tprojectMgr->get_by_id($argsObj->tproject_id);
    if ($info['issue_tracker_enabled']) {
        $it_mgr = new tlIssueTracker($dbHandler);
        $issueT = $it_mgr->getLinkedTo($argsObj->tproject_id);
        if (!is_null($issueT)) {
            $its = $it_mgr->getInterfaceObject($argsObj->tproject_id);
            $guiObj->issueTrackerVerboseType = $issueT['verboseType'];
            $guiObj->issueTrackerVerboseID = $issueT['issuetracker_name'];
            $guiObj->bugIDMaxLength = $its->getBugIDMaxLength();
            $guiObj->createIssueURL = $its->getEnterBugURL();
            if (method_exists($its, 'addIssue') && $argsObj->user_action == 'create') {
                list($guiObj->tlCanCreateIssue, $guiObj->msg) = addIssue($dbHandler, $argsObj, $its);
            }
        }
    }
    return array($its, $issueT);
}
Exemple #12
0
/**
 * render Test Case content for generated documents
 * 
 * @param $integer db DB connection identifier 
 * @return string generated html code
 *
 * @internal revisions
 */
function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context)
{
    static $req_mgr;
    static $tc_mgr;
    static $build_mgr;
    static $tplan_mgr;
    static $tplan_urgency;
    static $labels;
    static $tcase_prefix;
    static $userMap = array();
    static $cfg;
    static $locationFilters;
    static $tables = null;
    static $force = null;
    static $bugInterfaceOn = false;
    static $its;
    static $buildCfields;
    static $statusL10N;
    $code = null;
    $tcInfo = null;
    $tcResultInfo = null;
    $tcase_pieces = null;
    $id = $node['id'];
    $level = $context['level'];
    $prefix = isset($context['prefix']) ? $context['prefix'] : null;
    $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0;
    $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0;
    $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0;
    $build_id = isset($context['build_id']) ? $context['build_id'] : 0;
    // init static elements
    if (!$tables) {
        $tables = tlDBObject::getDBTables(array('executions', 'builds'));
        $tc_mgr = new testcase($db);
        $tplan_urgency = new testPlanUrgency($db);
        $build_mgr = new build_mgr($db);
        $tplan_mgr = new testplan($db);
        list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options);
        if (!is_null($prefix)) {
            $tcase_prefix = $prefix;
        } else {
            list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id);
        }
        $tcase_prefix .= $cfg['testcase']->glue_character;
        $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false;
        $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false;
        $its = null;
        $tproject_mgr = new testproject($db);
        $info = $tproject_mgr->get_by_id($tprojectID);
        $bugInterfaceOn = $info['issue_tracker_enabled'];
        if ($info['issue_tracker_enabled']) {
            $it_mgr = new tlIssueTracker($db);
            $its = $it_mgr->getInterfaceObject($tprojectID);
            unset($it_mgr);
        }
        $statusL10N = null;
        foreach ($cfg['results']['code_status'] as $vc => $vstat) {
            if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) {
                $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]);
            }
        }
    }
    $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" ';
    $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan);
    /** 
     * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, 
     * using existent methods - franciscom - 20090329 
     * Need to get CF with execution scope
     */
    $exec_info = null;
    $getExecutions = false;
    $getByID['filters'] = null;
    switch ($options["docType"]) {
        case DOC_TEST_SPEC:
            $getByID['tcversion_id'] = testcase::LATEST_VERSION;
            break;
        case SINGLE_TESTCASE:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status'];
            break;
        default:
            $getByID['tcversion_id'] = $node['tcversion_id'];
            $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status'];
            break;
    }
    if ($getExecutions) {
        // Thanks to Evelyn from Cortado, have found a very old issue never reported.
        // 1. create TC-1A VERSION 1
        // 2. add to test plan and execute FAILED ON BUILD 1
        // 3. Request Test Report (Test Plan EXECUTION REPORT).
        //    You will get spec for VERSION 1 and result for VERSION 1 - OK cool!
        // 4. create VERSION 2
        // 5. update linked Test Case Versions
        // 6. do nothing more than repeat step 3
        //    without this fix you will get
        //    You will get spec for VERSION 2 and result for VERSION 1 - Hmmm
        //    and in addition is not clear that execution was on VERSION 1 . No GOOD!!
        //
        // HOW has been fixed ?
        // Getting info about THE CURRENT LINKED test case version and looking for
        // exec info for this.
        //
        // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided
        //
        //
        // Get Linked test case version
        $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id);
        $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " B.name AS build_name,E.execution_duration " . " FROM {$tables['executions']} E, {$tables['builds']} B" . " WHERE E.build_id = B.id " . " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']);
        if ($build_id > 0) {
            $sql .= " AND E.build_id = " . intval($build_id);
        } else {
            // We are looking for LATEST EXECUTION of CURRENT LINKED test case version
            $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']);
        }
        $sql .= " ORDER BY execution_id DESC";
        $exec_info = $db->get_recordset($sql, null, 1);
        $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id'];
        $getByID['filters'] = null;
        if (!is_null($exec_info)) {
            //
            $getByID['tcversion_id'] = null;
            $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']);
            if ($options['build_cfields']) {
                if (!isset($buildCfields[$exec_info[0]['build_id']])) {
                    $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID);
                }
            }
        }
    }
    $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true));
    if ($tcInfo) {
        $tcInfo = $tcInfo[0];
    }
    $external_id = $tcase_prefix . $tcInfo['tc_external_id'];
    $name = htmlspecialchars($node['name']);
    $versionID = $tcInfo['id'];
    $cfields = array('specScope' => null, 'execScope' => null);
    if ($options['cfields']) {
        if (!$locationFilters) {
            $locationFilters = $tc_mgr->buildCFLocationMap();
        }
        // Get custom fields that has specification scope
        // Custom Field values at Test Case VERSION Level
        foreach ($locationFilters as $fkey => $fvalue) {
            $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $cfieldFormatting, $tcInfo['id']);
        }
        if (!is_null($exec_info)) {
            $execution_id = $exec_info[0]['execution_id'];
            $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $tplan_id, $tprojectID, $cfieldFormatting);
        }
    }
    if ($options['toc']) {
        // EXTERNAL ID added
        $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>';
        $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>';
    }
    // change table style in case of single TC printing to not be indented
    $table_style = "";
    if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) {
        $table_style = 'style="margin-left: 0;"';
    }
    $code .= '<p>&nbsp;</p><div> <table class="tc" width="90%" ' . $table_style . '>';
    $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name;
    // add test case version
    switch ($env->reportType) {
        case DOC_TEST_PLAN_DESIGN:
            $version_number = $node['version'];
            break;
        case DOC_TEST_PLAN_EXECUTION:
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $version_number = $tcInfo['version'];
            break;
        default:
            $version_number = $tcInfo['version'];
            break;
    }
    if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) {
        $code .= '&nbsp;<span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>';
    }
    $code .= "</th></tr>\n";
    if ($options['author']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']);
        if (isset($options['displayDates']) && $options['displayDates']) {
            $dummy = null;
            $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']);
        }
        $code .= "</td></tr>\n";
        if ($tcInfo['updater_id'] > 0) {
            // add updater if available and differs from author OR forced
            if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) {
                $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']);
                if (isset($options['displayDates']) && $options['displayDates']) {
                    $dummy = null;
                    $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']);
                }
                $code .= "</td></tr>\n";
            }
        }
    }
    if ($options['body'] || $options['summary']) {
        $tcase_pieces = array('summary');
    }
    if ($options['body']) {
        $tcase_pieces[] = 'preconditions';
    }
    if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) {
        $tcase_pieces[] = 'steps';
    }
    if (!is_null($tcase_pieces)) {
        // Multiple Test Case Steps Feature
        foreach ($tcase_pieces as $key) {
            if ($key == 'steps') {
                if (isset($cfields['specScope']['before_steps_results'])) {
                    $code .= $cfields['specScope']['before_steps_results'];
                }
                if ($tcInfo[$key] != '') {
                    $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>';
                    if ($options['step_exec_notes'] || $options['step_exec_status']) {
                        $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']);
                        if ($options['step_exec_notes']) {
                            $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>';
                        }
                        if ($options['step_exec_status']) {
                            $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>';
                        }
                    }
                    $code .= '</tr>';
                    $loop2do = count($tcInfo[$key]);
                    for ($ydx = 0; $ydx < $loop2do; $ydx++) {
                        $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>';
                        if ($options['step_exec_notes']) {
                            $code .= '<td>' . $sxni[$tcInfo[$key][$ydx]['id']]['notes'] . '</td>';
                        }
                        if ($options['step_exec_status']) {
                            $code .= '<td>' . $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']] . '</td>';
                        }
                        $code .= '</tr>';
                    }
                }
            } else {
                // disable the field if it's empty
                if ($tcInfo[$key] != '') {
                    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>";
                }
            }
        }
    }
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
    switch ($tcInfo['execution_type']) {
        case TESTCASE_EXECUTION_TYPE_AUTO:
            $code .= $labels['execution_type_auto'];
            break;
        case TESTCASE_EXECUTION_TYPE_MANUAL:
        default:
            $code .= $labels['execution_type_manual'];
            break;
    }
    $code .= "</td></tr>\n";
    //
    $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration'];
    $code .= "</td></tr>\n";
    if (isset($options['importance']) && $options['importance']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']];
        $code .= "</td></tr>\n";
    }
    // print priority when printing test plan
    if (isset($options['priority']) && $options['priority']) {
        // Get priority of this tc version for this test plan by using testplanUrgency class.
        // Is there maybe a better method than this one?
        $filters = array('tcversion_id' => $tcInfo['id']);
        $opt = array('details' => 'tcversion');
        $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt);
        $prio = $prio_info[$tcInfo['id']]['priority_level'];
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio];
        $code .= "</td></tr>\n";
    }
    // Spacer
    $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>";
    $code .= $cfields['specScope']['standard_location'] . $cfields['execScope'];
    // generate test results data for test report
    if ($options['passfail']) {
        if ($exec_info) {
            $code .= buildTestExecResults($db, $its, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes'], $buildCfields);
        } else {
            $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n";
        }
    }
    // collect REQ for TC
    if ($options['requirement']) {
        if (!$req_mgr) {
            $req_mgr = new requirement_mgr($db);
        }
        $requirements = $req_mgr->get_all_for_tcase($id);
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        if (sizeof($requirements)) {
            foreach ($requirements as $req) {
                $code .= htmlspecialchars($req['req_doc_id'] . ":  " . $req['title']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br />';
        }
        $code .= "</td></tr>\n";
    }
    // collect keywords for TC
    if ($options['keyword']) {
        $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>';
        $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">';
        $arrKeywords = $tc_mgr->getKeywords($id);
        if (sizeof($arrKeywords)) {
            foreach ($arrKeywords as $kw) {
                $code .= htmlspecialchars($kw['keyword']) . "<br />";
            }
        } else {
            $code .= '&nbsp;' . $labels['none'] . '<br>';
        }
        $code .= "</td></tr>\n";
    }
    // Attachments
    $attachSet = (array) $tc_mgr->getAttachmentInfos($id);
    if (count($attachSet) > 0) {
        $code .= "<tr><td><span class=\"label\">" . $labels['attached_files'] . "</span></td><td><ul>";
        foreach ($attachSet as $item) {
            $fname = "";
            if ($item['title']) {
                $fname .= htmlspecialchars($item['title']) . " : ";
            }
            $fname .= htmlspecialchars($item['file_name']);
            $code .= "<li>{$fname}</li>";
            if ($item['is_image']) {
                $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
            }
        }
        $code .= "</ul></td></tr>";
    }
    $code .= "</table>\n</div>\n";
    return $code;
}
<?php

require_once '../../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
define('DBUG_ON', 1);
$it = new tlIssueTracker($db);
new dBug($it);
$issueTrackerDomain = array_flip($it->getTypes());
$tprojectSet = array(32674, 2, 27);
/*
$dx = new stdClass();
$dx->name = 'Francisco2';
$dx->type = $issueTrackerDomain['MANTIS'];
$dx->cfg = " I'm Mantis ";
$info = $it->create($dx);
new dBug($info);
*/
$str = "<?xml version='1.0'?>";
$str = '';
$str .= "<issuetracker>" . "<dbhost>localhost</dbhost>" . "<dbname>mantis_tlorg</dbname>" . "<dbtype>mysql</dbtype>" . "<dbuser>root</dbuser>" . "<dbpassword>mysqlroot</dbpassword>" . "<hrefview>http://localhost:8080/development/mantisbt-1.2.5/my_view_page.php?id=</hrefview>" . "<hrefcreate>http://localhost:8080/development/mantisbt-1.2.5/</hrefcreate>" . "</issuetracker>";
$dx = new stdClass();
$dx->name = 'Francisco3';
$dx->type = $issueTrackerDomain['MANTIS'];
$dx->cfg = $str;
$info = $it->create($dx);
new dBug($info);
$info = $it->getByName('Francisco3');
new dBug($info);
die;
$links = $it->getLinks(4);
<?php

/**
 * TestLink Open Source Project - http://testlink.sourceforge.net/ 
 *
 * @filesource	test.getIssue.jiraOnDeman.jirarestInterface.class.php
 * @author		Francisco Mancardi
 *
 * @internal revisions
 *
**/
require_once '../../../../../config.inc.php';
require_once 'common.php';
$it_mgr = new tlIssueTracker($db);
$itt = $it_mgr->getTypes();
// http://testlink.atlassian.net/rest/api/latest/user/search/?username=admin
$username = '******';
$password = '******';
// $password = '';
$uribase = 'https://testlink.atlassian.net/';
$uriapi = 'https://testlink.atlassian.net/rest/api/latest/';
$cfg = "<issuetracker>\n" . "<username>{$username}</username>\n" . "<password>{$password}</password>\n" . "<uribase>{$uribase}</uribase>\n" . "<uriapi>{$uriapi}</uriapi>\n" . "<projectkey>ZOFF</projectkey>\n" . "<issuetype>1</issuetype>\n" . "</issuetracker>\n";
echo '<hr><br>';
echo "<b>Testing  BST Integration - jirarestInterface </b>";
echo '<hr><br>';
echo "Configuration settings<br>";
echo "<pre><xmp>" . $cfg . "</xmp></pre>";
echo '<hr><br><br>';
echo 'Creating INTERFACE<br>';
$its = new jirarestInterface(7, $cfg);
echo 'Connection OK?<br>';
Exemple #15
0
    require_once 'remote_exec.php';
}
// CRITIC:
// If call to testlinkInitPage() is done AFTER require_once for BTS
// log to event viewer fails, but log to file works ok
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$tcversion_id = null;
$submitResult = null;
$args = init_args($db, $cfg);
// 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);
if ($info['issue_tracker_enabled']) {
    $it_mgr = new tlIssueTracker($db);
    $its = $it_mgr->getInterfaceObject($args->tproject_id);
    $issueT = $it_mgr->getLinkedTo($args->tproject_id);
    unset($it_mgr);
}
$smarty = new TLSmarty();
$tree_mgr = new tree($db);
$tplan_mgr = new testplan($db);
$tcase_mgr = new testcase($db);
$exec_cfield_mgr = new exec_cfield_mgr($db, $args->tproject_id);
$attachmentRepository = tlAttachmentRepository::create($db);
$req_mgr = new requirement_mgr($db);
$gui = initializeGui($db, $args, $cfg, $tplan_mgr, $tcase_mgr);
if ($info['issue_tracker_enabled']) {
    if (!is_null($its) && $its->isConnected()) {
        $gui->issueTrackerIntegrationOn = true;
function doUpdate($argsObj, &$tprojectMgr, $sessionTprojectID)
{
    $key2get = array('status_ok', 'msg');
    $op = new stdClass();
    $op->ui = new stdClass();
    $op->status_ok = 0;
    $op->msg = '';
    $op->template = null;
    $op->reloadType = 'none';
    $oldObjData = $tprojectMgr->get_by_id($argsObj->tprojectID);
    $op->oldName = $oldObjData['name'];
    $check_op = crossChecks($argsObj, $tprojectMgr);
    foreach ($key2get as $key) {
        $op->{$key} = $check_op[$key];
    }
    if ($op->status_ok) {
        $options = prepareOptions($argsObj);
        if ($tprojectMgr->update($argsObj->tprojectID, trim($argsObj->tprojectName), $argsObj->color, $argsObj->notes, $options, $argsObj->active, $argsObj->tcasePrefix, $argsObj->is_public)) {
            $op->msg = '';
            $tprojectMgr->activate($argsObj->tprojectID, $argsObj->active);
            $tprojectMgr->setIssueTrackerEnabled($argsObj->tprojectID, $argsObj->issue_tracker_enabled);
            $itMgr = new tlIssueTracker($tprojectMgr->db);
            if ($doLink = $argsObj->issue_tracker_id > 0) {
                $itMgr->link($argsObj->issue_tracker_id, $argsObj->tprojectID);
            } else {
                $issueT = $itMgr->getLinkedTo($argsObj->tprojectID);
                if (!is_null($issueT)) {
                    $itMgr->unlink($issueT['issuetracker_id'], $issueT['testproject_id']);
                }
            }
            $tprojectMgr->setReqMgrIntegrationEnabled($argsObj->tprojectID, $argsObj->reqmgr_integration_enabled);
            $mgr = new tlReqMgrSystem($tprojectMgr->db);
            if ($doLink = $argsObj->reqmgrsystem_id > 0) {
                $mgr->link($argsObj->reqmgrsystem_id, $argsObj->tprojectID);
            } else {
                $et = $mgr->getLinkedTo($argsObj->tprojectID);
                if (!is_null($et)) {
                    $mgr->unlink($et['reqmgrsystem_id'], $et['testproject_id']);
                }
            }
            if (!$argsObj->is_public) {
                // does user have an SPECIFIC role on Test Project ?
                // if answer is yes => do nothing
                if (!tlUser::hasRoleOnTestProject($tprojectMgr->db, $argsObj->userID, $argsObj->tprojectID)) {
                    $tprojectMgr->addUserRole($argsObj->userID, $argsObj->tprojectID, $argsObj->user->globalRole->dbID);
                }
            }
            $event = new stdClass();
            $event->message = TLS("audit_testproject_saved", $argsObj->tprojectName);
            $event->logLevel = "AUDIT";
            $event->source = "GUI";
            $event->objectID = $argsObj->tprojectID;
            $event->objectType = "testprojects";
            $event->code = "UPDATE";
            logEvent($event);
        } else {
            $op->status_ok = 0;
        }
    }
    if ($op->status_ok) {
        if ($sessionTprojectID == $argsObj->tprojectID) {
            $op->reloadType = 'reloadNavBar';
        }
    } else {
        $op->ui->doActionValue = 'doUpdate';
        $op->ui->buttonValue = lang_get('btn_save');
        $op->ui->caption = sprintf(lang_get('caption_edit_tproject'), $op->oldName);
    }
    return $op;
}
/**
 * initialize page ENVironment
 *
 * @return array
 * @internal revisions
 */
function initializeEnv(&$dbHandler)
{
    $tprojectMgr = new testproject($dbHandler);
    $argsObj = init_args($tprojectMgr);
    // Gui
    $guiObj = $argsObj;
    $guiObj->canManage = $guiObj->user->hasRight($dbHandler, "mgt_modify_product");
    $guiObj->mgt_view_events = $guiObj->user->hasRight($dbHandler, "mgt_view_events");
    $guiObj->found = 'yes';
    $guiObj->cfg = config_get('gui');
    $guiObj->user_feedback = '';
    $guiObj->feedback_type = 'ultrasoft';
    $guiObj->main_descr = lang_get('title_testproject_management');
    $itMgr = new tlIssueTracker($dbHandler);
    $guiObj->issueTrackers = $itMgr->getAll();
    unset($itMgr);
    // UI
    $uiObj = new stdClass();
    $uiObj->doActionValue = $uiObj->buttonValue = $uiObj->caption = '';
    return array($tprojectMgr, $argsObj, $guiObj, $uiObj);
}