コード例 #1
0
 /**
  * 
  *
  */
 function initGuiBean(&$argsObj, $mandatory = null)
 {
     $obj = new stdClass();
     $prop2scan = array('tproject_id' => 'Test project id can not be <= 0', 'tsuiteID' => 'Test suite id can not be <= 0');
     if (!is_null($mandatory)) {
         foreach ($mandatory as $key) {
             $p2check[$key] = $prop2scan[$key];
         }
     } else {
         $p2check =& $prop2scan;
     }
     foreach ($p2check as $prop => $msg) {
         if (($obj->{$prop} = intval($argsObj->{$prop})) <= 0) {
             throw new Exception(__METHOD__ . ':' . $msg);
         }
     }
     $tprojectMgr = new testproject($this->db);
     $dummy = $tprojectMgr->get_by_id($obj->tproject_id);
     $obj->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
     $obj->automationEnabled = $dummy['opt']->automationEnabled;
     $this->keywordSet = array('testproject' => $tprojectMgr->get_keywords_map($argsObj->tproject_id), 'testcase' => null);
     $obj->template_dir = $this->templateCfg->template_dir;
     $obj->action = '';
     $obj->attachments = null;
     $obj->cleanUpWebEditor = false;
     $obj->direct_link = null;
     $obj->execution_types = $this->execution_types;
     $obj->grants = $this->grants;
     $obj->has_been_executed = false;
     $obj->initWebEditorFromTemplate = false;
     $obj->viewerArgs = null;
     $obj->path_info = null;
     $obj->main_descr = '';
     $obj->name = '';
     $obj->sqlResult = '';
     $obj->step_id = -1;
     $obj->step_set = '';
     $obj->steps = '';
     $obj->tableColspan = 5;
     $obj->tcase_id = property_exists($argsObj, 'tcase_id') ? intval($argsObj->tcase_id) : -1;
     $p2check = array('goback_url' => '', 'show_mode' => 'show', 'refreshTree' => !tlTreeMenu::REFRESH_GUI);
     foreach ($p2check as $prop => $value) {
         if (property_exists($argsObj, $prop) && !is_null($argsObj->{$prop})) {
             $obj->{$prop} = $argsObj->{$prop};
         } else {
             $obj->{$prop} = $value;
         }
     }
     // need to check where is used -> on cancel button on tcStepEdit.tpl
     $obj->loadOnCancelURL = "archiveData.php?tproject_id={$obj->tproject_id}&edit=testcase" . "&show_mode={$obj->show_mode}&id=%s&version_id=%s";
     // Used on tcStepEdit.tpl to creare goback_url URL parameter
     $obj->goBackAction = $_SESSION['basehref'] . "lib/testcases/" . $obj->loadOnCancelURL;
     $obj->keywordsViewHREF = "lib/keywords/keywordsView.php?tproject_id={$obj->tproject_id} " . ' target="mainframe" class="bold" ' . ' title="' . lang_get('menu_manage_keywords') . '"';
     return $obj;
 }
コード例 #2
0
 /** 
  * Important Notice about algorithm
  * We are trying to provide WHOLE Test Plan metrics, then BUILD INFO
  * will not be IMPORTANT.
  *
  * In addition, Keywords are attributes used on Test Case specification,
  * for this reason, our choice is that platforms will be ignored
  * for this metrics.
  *
  * Example: Platform X and Y
  * Test Case: TC1 with one Keyword K1
  *
  * we can develop this data in this way
  *
  * Test Case - Platform - Keyword - Build - Exec. ID - Exec. Status
  *       TC1          X        K1     1.0        11         FAILED
  *       TC1          Y        K1     1.0         13         BLOCKED
  *       TC1          X        K1     2.0        16         PASSED
  *       TC1          Y        K1     2.0         15         BLOCKED
  *
  *
  * We have two choices:
  * OPT 1. Platform multiplication
  *
  * consider (as was done on Builds Overall Status) 
  * TC1 as two test cases.
  * If we proceed this way, may be user will be confused, because
  * when searching test case spec according keyword, we are going to
  * find ONLY ONE.
  *
  * OPT 2. IGNORE PLAFORMS
  * Consider only LATEST execution, means we are going to count ONE test case
  * no matter how many Platforms exists on test plan.
  *    
  * Our design choice is on OPT 1
  * 
  */
 function getExecCountersByKeywordExecStatus($id, $filters = null, $opt = null)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $safe_id = intval($id);
     list($my, $builds, $sqlStm) = $this->helperGetExecCounters($safe_id, $filters, $opt);
     // may be too brute force but ...
     if (($tprojectID = $my['opt']['tprojectID']) == 0) {
         $info = $this->tree_manager->get_node_hierarchy_info($safe_id);
         $tprojectID = $info['parent_id'];
     }
     $tproject_mgr = new testproject($this->db);
     $keywordSet = $tproject_mgr->get_keywords_map($tprojectID);
     $tproject_mgr = null;
     // This subquery is BETTER than a VIEW, need to understand why
     // Latest Execution Ignoring Build => Cross Build
     $sqlLEBP = $sqlStm['LEBP'];
     // Development Important Notice
     // DISTINCT is needed when you what to get data ONLY FOR test cases with assigned testers,
     // because we are (to make things worst) working on a BUILD SET, not on a SINGLE build,
     // Use of IN clause, will have a NOT wanted multiplier effect on this query.
     //
     // This do not happens with other queries on other metric attributes,
     // be careful before changing other queries.
     //
     $sqlUnionAK = "/* {$debugMsg} sqlUnionAK - executions */" . " SELECT DISTINCT NHTCV.parent_id, TCK.keyword_id, TPTCV.platform_id," . " COALESCE(E.status,'{$this->notRunStatusCode}') AS status " . " FROM {$this->tables['testplan_tcversions']} TPTCV " . $sqlStm['getAssignedFeatures'] . " /* GO FOR Absolute LATEST exec ID IGNORE BUILD */ " . " JOIN ({$sqlLEBP}) AS LEBP " . " ON  LEBP.testplan_id = TPTCV.testplan_id " . " AND LEBP.platform_id = TPTCV.platform_id " . " AND LEBP.tcversion_id = TPTCV.tcversion_id " . " AND LEBP.testplan_id = " . $safe_id . " /* Get execution status WRITTEN on DB */ " . " JOIN {$this->tables['executions']} E " . " ON  E.id = LEBP.id " . " /* Get ONLY Test case versions that has AT LEAST one Keyword assigned */ " . " JOIN {$this->tables['nodes_hierarchy']} NHTCV " . " ON NHTCV.id = TPTCV.tcversion_id " . " JOIN {$this->tables['testcase_keywords']} TCK " . " ON TCK.testcase_id = NHTCV.parent_id " . " WHERE TPTCV.testplan_id=" . $safe_id . $builds->whereAddExec;
     // See Note about DISTINCT, on sqlUnionAK
     $sqlUnionBK = "/* {$debugMsg} sqlUnionBK - NOT RUN */" . " SELECT DISTINCT NHTCV.parent_id, TCK.keyword_id, TPTCV.platform_id," . " COALESCE(E.status,'{$this->notRunStatusCode}') AS status " . " FROM {$this->tables['testplan_tcversions']} TPTCV " . $sqlStm['getAssignedFeatures'] . " /* Get REALLY NOT RUN => BOTH LEBP.id AND E.id ON LEFT OUTER see WHERE  */ " . " LEFT OUTER JOIN ({$sqlLEBP}) AS LEBP " . " ON  LEBP.testplan_id = TPTCV.testplan_id " . " AND LEBP.platform_id = TPTCV.platform_id " . " AND LEBP.tcversion_id = TPTCV.tcversion_id " . " AND LEBP.testplan_id = " . $safe_id . " LEFT OUTER JOIN {$this->tables['executions']} E " . " ON  E.tcversion_id = TPTCV.tcversion_id " . " AND E.testplan_id = TPTCV.testplan_id " . " AND E.platform_id = TPTCV.platform_id " . $builds->joinAdd . " /* Get ONLY Test case versions that has AT LEAST one Keyword assigned */ " . " JOIN {$this->tables['nodes_hierarchy']} NHTCV " . " ON NHTCV.id = TPTCV.tcversion_id " . " JOIN {$this->tables['testcase_keywords']} TCK " . " ON TCK.testcase_id = NHTCV.parent_id " . " /* FILTER BUILDS in set on target test plan */ " . " WHERE TPTCV.testplan_id=" . $safe_id . $builds->whereAddNotRun . " /* Get REALLY NOT RUN => BOTH E.id AND LEBP.id  NULL  */ " . " AND E.id IS NULL AND LEBP.id IS NULL";
     // Due to PLATFORMS we will have MULTIPLIER EFFECT
     $sql = " /* {$debugMsg} UNION Without ALL CLAUSE => DISCARD Duplicates */" . " SELECT keyword_id,status, count(0) AS exec_qty " . " FROM ({$sqlUnionAK} UNION {$sqlUnionBK} ) AS SQK " . " GROUP BY keyword_id,status ";
     $exec['with_tester'] = (array) $this->db->fetchMapRowsIntoMap($sql, 'keyword_id', 'status');
     $this->helperCompleteStatusDomain($exec, 'keyword_id');
     // On next queries:
     // we need to use distinct, because IF NOT we are going to get one record
     // for each build where test case has TESTER ASSIGNMENT
     //
     // $exec['total_assigned'] = null;
     $exec['total'] = null;
     $exec['key4total'] = 'total';
     if ($my['opt']['getOnlyAssigned']) {
         // $exec['key4total'] = 'total_assigned';
         $sql = "/* {$debugMsg} */ " . " SELECT COUNT(0) AS qty, keyword_id " . " FROM " . " ( /* Get test case,keyword pairs */ " . "  SELECT DISTINCT NHTCV.parent_id, TCK.keyword_id,TPTCV.platform_id " . "  FROM {$this->tables['user_assignments']} UA " . "  JOIN {$this->tables['testplan_tcversions']} TPTCV ON TPTCV.id = UA.feature_id " . "  /* Get ONLY Test case versions that has AT LEAST one Keyword assigned */ " . "  JOIN {$this->tables['nodes_hierarchy']} NHTCV " . "  ON NHTCV.id = TPTCV.tcversion_id " . "  JOIN {$this->tables['testcase_keywords']} TCK " . "  ON TCK.testcase_id = NHTCV.parent_id " . "  WHERE UA. build_id IN ( " . $builds->inClause . " ) " . "  AND UA.type = {$execCode} ) AS SQK " . " GROUP BY keyword_id";
     } else {
         $sql = "/* {$debugMsg} */ " . " SELECT COUNT(0) AS qty, keyword_id " . " FROM " . " ( /* Get test case,keyword pairs */ " . "  SELECT DISTINCT NHTCV.parent_id, TCK.keyword_id,TPTCV.platform_id " . "  FROM {$this->tables['testplan_tcversions']} TPTCV " . "  /* Get ONLY Test case versions that has AT LEAST one Keyword assigned */ " . "  JOIN {$this->tables['nodes_hierarchy']} NHTCV " . "  ON NHTCV.id = TPTCV.tcversion_id " . "  JOIN {$this->tables['testcase_keywords']} TCK " . "  ON TCK.testcase_id = NHTCV.parent_id " . "  WHERE TPTCV.testplan_id = " . $safe_id . " ) AS SQK " . " GROUP BY keyword_id";
     }
     $exec[$exec['key4total']] = (array) $this->db->fetchRowsIntoMap($sql, 'keyword_id');
     $exec['keywords'] = $keywordSet;
     return $exec;
 }
コード例 #3
0
$keywords = $tproject_mgr->getKeywords($tproject_id);
new dBug($keywords);
$tproject_id = 1;
echo "<pre> testproject - get_first_level_test_suites({$tproject_id},{$mode}='simple')";
echo "</pre>";
echo "<pre>               get_first_level_test_suites({$tproject_id},{$mode}='simple')";
echo "</pre>";
$info = $tproject_mgr->get_first_level_test_suites($tproject_id, $mode = 'simple');
new dBug($info);
die;
echo "<pre> testproject - get_keywords_map(\$testproject_id)";
echo "</pre>";
$tproject_id = 1;
echo "<pre>               get_keywords_map({$tproject_id})";
echo "</pre>";
$keywords_map = $tproject_mgr->get_keywords_map($tproject_id);
new dBug($keywords_map);
echo "<pre> testproject - get_keywords_tcases(\$testproject_id, \$keyword_id=0)";
echo "</pre>";
echo "<pre>               get_keywords_tcases({$tproject_id})";
echo "</pre>";
$keywords_tcases = $tproject_mgr->get_keywords_tcases($tproject_id);
new dBug($keywords_tcases);
echo "<pre> testproject - get_linked_custom_fields(\$id,\$node_type=null)";
echo "</pre>";
echo "<pre>               get_linked_custom_fields({$tproject_id})";
echo "</pre>";
$linked_custom_fields = $tproject_mgr->get_linked_custom_fields($tproject_id);
new dBug($linked_custom_fields);
echo "<pre> testproject - gen_combo_test_suites(\$id,\$exclude_branches=null,\$mode='dotted')";
echo "</pre>";
コード例 #4
0
ファイル: keywordsAssign.php プロジェクト: tamtrong/testlink
    // We can NOT assign/remove keywords on a whole test project
    show_instructions('keywordsAssign');
    exit;
}
$smarty = new TLSmarty();
$tproject_mgr = new testproject($db);
$tcase_mgr = new testcase($db);
$result = null;
$keyword_assignment_subtitle = null;
$can_do = 0;
$itemID = null;
$opt_cfg->global_lbl = '';
$opt_cfg->additional_global_lbl = null;
$opt_cfg->from->lbl = lang_get('available_kword');
$opt_cfg->to->lbl = lang_get('assigned_kword');
$opt_cfg->from->map = $tproject_mgr->get_keywords_map($args->testproject_id);
$opt_cfg->to->map = $tcase_mgr->get_keywords_map($args->id, " ORDER BY keyword ASC ");
if ($args->edit == 'testsuite') {
    // We are going to walk all test suites contained
    // in the selected container, and assign/remove keywords on each test case.
    $tsuite_mgr = new testsuite($db);
    $testsuite = $tsuite_mgr->get_by_id($args->id);
    $keyword_assignment_subtitle = lang_get('test_suite') . TITLE_SEP . $testsuite['name'];
    $tcs = $tsuite_mgr->get_testcases_deep($args->id, 'only_id');
    if (sizeof($tcs)) {
        $can_do = 1;
        if ($args->bAssignTestSuite) {
            $result = 'ok';
            for ($i = 0; $i < sizeof($tcs); $i++) {
                $tcID = $tcs[$i];
                $tcase_mgr->setKeywords($tcID, $args->keywordArray);
コード例 #5
0
 * @internal revisions
 */
require_once "../../config.inc.php";
require_once "common.php";
require_once "web_editor.php";
$editorCfg = getWebEditorCfg('design');
require_once require_web_editor($editorCfg['type']);
testlinkInitPage($db);
$tree_mgr = new tree($db);
$tproject_mgr = new testproject($db);
$tsuite_mgr = new testsuite($db);
$tcase_mgr = new testcase($db);
$assign_gui = true;
$refreshTree = false;
list($args, $gui) = initializeEnv($db, $tree_mgr);
$keywordSet = array('testproject' => $tproject_mgr->get_keywords_map($args->tproject_id), 'testsuite' => null);
if ($args->action == 'edit_testsuite') {
    $keywordSet['testsuite'] = $tsuite_mgr->get_keywords_map($args->testsuiteID, " ORDER BY keyword ASC ");
}
$gui_cfg = config_get('gui');
$tpl = null;
$smarty = new TLSmarty();
$smarty->tlTemplateCfg = templateConfiguration();
$smarty->assign('editorType', $editorCfg['type']);
switch ($args->action) {
    case 'edit_testsuite':
    case 'new_testsuite':
        renderTestSuiteForManagement($smarty, $args, $gui, $tsuite_mgr, $keywordSet);
        exit;
        break;
    case 'add_testsuite':
コード例 #6
0
function importTestCaseDataFromXML(&$db, $fileName, $parentID, $tproject_id, $userID, $options = null)
{
    tLog('importTestCaseDataFromXML called for file: ' . $fileName);
    $xmlTCs = null;
    $resultMap = null;
    $my = array();
    $my['options'] = array('useRecursion' => false, 'importIntoProject' => 0, 'duplicateLogic' => array('hitCriteria' => 'name', 'actionOnHit' => null));
    $my['options'] = array_merge($my['options'], (array) $options);
    foreach ($my['options'] as $varname => $value) {
        ${$varname} = $value;
    }
    if (file_exists($fileName)) {
        $xml = @simplexml_load_file_wrapper($fileName);
        if ($xml !== FALSE) {
            $xmlKeywords = $xml->xpath('//keywords');
            $kwMap = null;
            if ($xmlKeywords) {
                $tproject = new testproject($db);
                $loop2do = sizeof($xmlKeywords);
                for ($idx = 0; $idx < $loop2do; $idx++) {
                    $tproject->importKeywordsFromSimpleXML($tproject_id, $xmlKeywords[$idx]);
                }
                $kwMap = $tproject->get_keywords_map($tproject_id);
                $kwMap = is_null($kwMap) ? null : array_flip($kwMap);
            }
            if (!$useRecursion && $xml->getName() == 'testcases') {
                $resultMap = importTestCasesFromSimpleXML($db, $xml, $parentID, $tproject_id, $userID, $kwMap, $duplicateLogic);
            }
            if ($useRecursion && $xml->getName() == 'testsuite') {
                $resultMap = importTestSuitesFromSimpleXML($db, $xml, intval($parentID), intval($tproject_id), $userID, $kwMap, $importIntoProject, $duplicateLogic);
            }
        }
    }
    return $resultMap;
}