示例#1
0
function addIssue($dbHandler, $argsObj, $itsObj)
{
    $opOK = false;
    $msg = '';
    $resultsCfg = config_get('results');
    $tcaseMgr = new testcase($dbHandler);
    $dummy = $tcaseMgr->tree_manager->get_node_hierarchy_info($argsObj->tcversion_id);
    $auditSign = $tcaseMgr->getAuditSignature((object) array('id' => $dummy['parent_id']));
    $exec = current($tcaseMgr->getExecution($argsObj->exec_id, $argsObj->tcversion_id));
    $dummy = $exec['status'];
    if (isset($resultsCfg['code_status'][$exec['status']])) {
        $dummy = $resultsCfg['code_status'][$exec['status']];
    }
    $exec['statusVerbose'] = sprintf(lang_get('issue_exec_result'), $dummy);
    unset($tcaseMgr);
    $signature = sprintf(lang_get('issue_generated_description'), $argsObj->exec_id, $exec['tester_login'], $exec['testplan_name']);
    if ($exec['platform_id'] > 0) {
        $signature .= sprintf(lang_get('issue_platform'), $exec['platform_name']);
    }
    $signature .= sprintf(lang_get('issue_build') . lang_get('execution_ts_iso'), $exec['build_name'], $exec['execution_ts']) . "\n" . $exec['statusVerbose'] . "\n\n" . $exec['execution_notes'];
    $rs = $itsObj->addIssue($auditSign . ' - ' . sprintf(lang_get('execution_ts_iso'), $exec['execution_ts']), $signature);
    if ($rs['status_ok']) {
        $msg = $rs['msg'];
        $opOK = true;
        if (write_execution_bug($dbHandler, $argsObj->exec_id, $rs['id'])) {
            logAuditEvent(TLS("audit_executionbug_added", $rs['id']), "CREATE", $argsObj->exec_id, "executions");
        }
    } else {
        $msg = $rs['msg'];
    }
    return array($opOK, $msg);
}
function initializeGUI(&$dbHandler, $argsObj)
{
    $gui = new stdClass();
    $gui->tc_id = $argsObj->tcase_id;
    $gui->compare_selected_versions = $argsObj->compare_selected_versions;
    $gui->context = $argsObj->context;
    $tcaseMgr = new testcase($dbHandler);
    $gui->tc_versions = $tcaseMgr->get_by_id($argsObj->tcase_id);
    $gui->tcaseName = $gui->tc_versions[0]['name'];
    unset($tcaseMgr);
    $lblkeys = array('num_changes' => null, 'no_changes' => null, 'version_short' => null, 'diff_subtitle_tc' => null);
    $gui->labels = init_labels($lblkeys);
    $gui->version_short = $gui->labels['version_short'];
    $gui->subtitle = sprintf($gui->labels['diff_subtitle_tc'], $argsObj->version_left, $argsObj->version_left, $argsObj->version_right, $argsObj->version_right, $gui->tcaseName);
    $gui->leftID = "v{$argsObj->version_left}";
    $gui->rightID = "v{$argsObj->version_right}";
    return $gui;
}
 /**
  * 
  *
  */
 function initGuiBean(&$argsObj)
 {
     $obj = new stdClass();
     $obj->action = '';
     $obj->attachments = null;
     $obj->cleanUpWebEditor = false;
     $obj->containerID = '';
     $obj->direct_link = null;
     $obj->execution_types = $this->execution_types;
     $obj->grants = $this->grants;
     $obj->has_been_executed = false;
     $obj->initWebEditorFromTemplate = false;
     $obj->main_descr = '';
     $obj->name = '';
     $obj->path_info = null;
     $obj->refreshTree = 0;
     $obj->sqlResult = '';
     $obj->step_id = -1;
     $obj->step_set = '';
     $obj->steps = '';
     $dummy = testcase::getLayout();
     $obj->tableColspan = $dummy->tableToDisplayTestCaseSteps->colspan;
     $obj->tcase_id = property_exists($argsObj, 'tcase_id') ? $argsObj->tcase_id : -1;
     $obj->viewerArgs = null;
     $p2check = 'goback_url';
     $obj->{$p2check} = '';
     if (property_exists($argsObj, $p2check)) {
         $obj->{$p2check} = !is_null($argsObj->{$p2check}) ? $argsObj->{$p2check} : '';
     }
     $p2check = 'show_mode';
     if (property_exists($argsObj, $p2check)) {
         $obj->{$p2check} = !is_null($argsObj->{$p2check}) ? $argsObj->{$p2check} : 'show';
     }
     // need to check where is used
     $obj->loadOnCancelURL = "archiveData.php?edit=testcase&show_mode={$obj->show_mode}&id=%s&version_id=%s";
     return $obj;
 }
示例#4
0
require_once "../../config.inc.php";
require_once "common.php";
require_once "opt_transfer.php";
testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$opt_cfg = opt_transf_empty_cfg();
$opt_cfg->js_ot_name = 'ot';
$args = init_args($opt_cfg);
if ($args->edit == 'testproject') {
    // 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);
 * @filesource	tcAssignedToUser.php
 * @package 	  TestLink
 * @copyright 	2005,2012 TestLink community 
 * @author 		  Francisco Mancardi - francisco.mancardi@gmail.com
 * @link 		    http://www.teamst.org/index.php
 *
 * @internal revisions
 * @since 2.0
 */
require_once "../../config.inc.php";
require_once "common.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$results_config = config_get('results');
$args = init_args($db);
$tcase_mgr = new testcase($db);
$gui = new stdClass();
$gui->show_build_selector = $args->build_id == 0;
$gui->glueChar = config_get('testcase_cfg')->glue_character;
$gui->tproject_id = $args->tproject_id;
$gui->tproject_name = $args->tproject_name;
$gui->warning_msg = '';
$gui->tableSet = null;
$history_img = TL_THEME_IMG_DIR . "history_small.png";
$exec_img = TL_THEME_IMG_DIR . "exec_icon.png";
$edit_img = TL_THEME_IMG_DIR . "edit_icon.png";
$l18n = init_labels(array('tcversion_indicator' => null, 'goto_testspec' => null, 'version' => null, 'testplan' => null, 'assigned_tc_overview' => null, 'testcases_created_per_user' => null, 'design' => null, 'execution' => null, 'execution_history' => null));
$gui->pageTitle = sprintf($l18n['testcases_created_per_user'], $gui->tproject_name);
$priority = array(LOW => lang_get('low_priority'), MEDIUM => lang_get('medium_priority'), HIGH => lang_get('high_priority'));
$map_status_code = $results_config['status_code'];
$map_code_status = $results_config['code_status'];
示例#6
0
function getLastExecutions(&$db, $tcaseSet, $tplanId)
{
    $execMap = array();
    if (sizeof($tcaseSet)) {
        $tcase_mgr = new testcase($db);
        $items = array_keys($tcaseSet);
        $path_info = $tcase_mgr->tree_manager->get_full_path_verbose($items);
        $options = array('getNoExecutions' => 1, 'groupByBuild' => 0);
        foreach ($tcaseSet as $tcaseId => $tcInfo) {
            $execMap[$tcaseId] = $tcase_mgr->get_last_execution($tcaseId, $tcInfo['tcversion_id'], $tplanId, testcase::ANY_BUILD, testcase::ANY_PLATFORM, $options);
            unset($path_info[$tcaseId][0]);
            // remove test project name
            $path_info[$tcaseId][] = '';
            $execMap[$tcaseId][$tcInfo['tcversion_id']]['tcase_path'] = implode(' / ', $path_info[$tcaseId]);
        }
        unset($tcase_mgr);
    }
    return $execMap;
}
示例#7
0
        if ($exporting_just_one_tc) {
            $optExport['ROOTELEM'] = "<testcases>{{XMLCODE}}</testcases>";
            $content = $tcase_mgr->{$pfn}($args->tcase_id, $args->tcversion_id, $args->tproject_id, null, $optExport);
        } else {
            $content = TL_XMLEXPORT_HEADER;
            $content .= $tsuite_mgr->{$pfn}($args->container_id, $args->tproject_id, $optExport);
        }
        downloadContentsToFile($content, $gui->export_filename);
        exit;
    }
}
if ($args->useRecursion) {
    // we are working on a testsuite
    $obj_mgr = new testsuite($db);
} else {
    $obj_mgr = new testcase($db);
}
$gui->object_name = $node['name'];
$gui->exportTypes = $obj_mgr->get_export_file_types();
$gui->tproject_name = $args->tproject_name;
$gui->tproject_id = $args->tproject_id;
$gui->tcID = $args->tcase_id;
$gui->useRecursion = $args->useRecursion ? 1 : 0;
$gui->tcVersionID = $args->tcversion_id;
$gui->containerID = $args->container_id;
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/*
  function: init_args
  args:
示例#8
0
     $date_from = date_create_from_format('Y-n-j', $args->creation_date_from);
     $date_to = date_create_from_format('Y-n-j', $args->creation_date_to);
 }
 if (!is_null($args->creation_date_from)) {
     $db_date = $db->db->DBdate($args->creation_date_from);
     $filter['by_creation_date_from'] = " AND TCV.creation_ts >= {$db_date} ";
 }
 if (!is_null($args->creation_date_to)) {
     $db_date = $db->db->DBdate($args->creation_date_to);
     $filter['by_creation_date_to'] = " AND TCV.creation_ts <= {$db_date} ";
 }
 if ($args->targetTestCase != "" && strcmp($args->targetTestCase, $gui->tcasePrefix) != 0) {
     if (strpos($args->targetTestCase, $tcase_cfg->glue_character) === false) {
         $args->targetTestCase = $gui->tcasePrefix . $args->targetTestCase;
     }
     $tcase_mgr = new testcase($db);
     $tcaseID = $tcase_mgr->getInternalID($args->targetTestCase, $tcase_cfg->glue_character);
     $filter['by_tc_id'] = " AND NH_TCV.parent_id = {$tcaseID} ";
 } else {
     $tproject_mgr->get_all_testcases_id($args->tprojectID, $a_tcid);
     $filter['by_tc_id'] = " AND NH_TCV.parent_id IN (" . implode(",", $a_tcid) . ") ";
 }
 if ($args->version) {
     $filter['by_version'] = " AND TCV.version = {$args->version} ";
 }
 if ($args->keyword_id) {
     $from['by_keyword_id'] = " JOIN {$tables['testcase_keywords']} KW ON KW.testcase_id = NH_TC.id ";
     $filter['by_keyword_id'] = " AND KW.keyword_id = {$args->keyword_id} ";
 }
 if ($args->name != "") {
     $args->name = $db->prepare_string($args->name);
 function create_tc_from_requirement($mixIdReq, $srs_id, $user_id, $tproject_id = null, $tc_count = null)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $tcase_mgr = new testcase($this->db);
     $tsuite_mgr = new testsuite($this->db);
     $req_cfg = config_get('req_cfg');
     $field_size = config_get('field_size');
     $auto_testsuite_name = $req_cfg->default_testsuite_name;
     $node_descr_type = $this->tree_mgr->get_available_node_types();
     $empty_steps = null;
     $empty_preconditions = '';
     // fix for BUGID 2995
     $labels['tc_created'] = lang_get('tc_created');
     $output = null;
     $reqSet = is_array($mixIdReq) ? $mixIdReq : array($mixIdReq);
     /* contribution BUGID 2996, testcase creation */
     if (is_null($tproject_id) || $tproject_id == 0) {
         $tproject_id = $this->tree_mgr->getTreeRoot($srs_id);
     }
     if ($req_cfg->use_req_spec_as_testsuite_name) {
         $full_path = $this->tree_mgr->get_path($srs_id);
         $addition = " (" . lang_get("testsuite_title_addition") . ")";
         $truncate_limit = $field_size->testsuite_name - strlen($addition);
         // REQ_SPEC_A
         //           |-- REQ_SPEC_A1
         //                          |-- REQ_SPEC_A2
         //                                         |- REQ100
         //                                         |- REQ101
         //
         // We will try to check if a test suite has already been created for
         // top REQ_SPEC_A  (we do search using automatic generated name as search criteria).
         // If not => we need to create all path till leaves (REQ100 and REQ200)
         //
         //
         // First search: we use test project
         $parent_id = $tproject_id;
         $deep_create = false;
         foreach ($full_path as $key => $node) {
             // follow hierarchy of test suites to create
             $tsuiteInfo = null;
             $testsuite_name = substr($node['name'], 0, $truncate_limit) . $addition;
             if (!$deep_create) {
                 // child test suite with this name, already exists on current parent ?
                 // At first a failure we will not check anymore an proceed with deep create
                 $sql = "/* {$debugMsg} */ SELECT id,name FROM {$this->tables['nodes_hierarchy']} NH " . " WHERE name='" . $this->db->prepare_string($testsuite_name) . "' " . " AND node_type_id=" . $node_descr_type['testsuite'] . " AND parent_id = {$parent_id} ";
                 // If returns more that one record use ALWAYS first
                 $tsuiteInfo = $this->db->fetchRowsIntoMap($sql, 'id');
             }
             if (is_null($tsuiteInfo)) {
                 $tsuiteInfo = $tsuite_mgr->create($parent_id, $testsuite_name, $req_cfg->testsuite_details);
                 $output[] = sprintf(lang_get('testsuite_name_created'), $testsuite_name);
                 $deep_create = true;
             } else {
                 $tsuiteInfo = current($tsuiteInfo);
                 $tsuite_id = $tsuiteInfo['id'];
             }
             $tsuite_id = $tsuiteInfo['id'];
             // last value here will be used as parent for test cases
             $parent_id = $tsuite_id;
         }
         $output[] = sprintf(lang_get('created_on_testsuite'), $testsuite_name);
     } else {
         // don't use req_spec as testsuite name
         // Warning:
         // We are not maintaining hierarchy !!!
         $sql = " SELECT id FROM {$this->tables['nodes_hierarchy']} NH " . " WHERE name='" . $this->db->prepare_string($auto_testsuite_name) . "' " . " AND parent_id=" . $testproject_id . " " . " AND node_type_id=" . $node_descr_type['testsuite'];
         $result = $this->db->exec_query($sql);
         if ($this->db->num_rows($result) == 1) {
             $row = $this->db->fetch_array($result);
             $tsuite_id = $row['id'];
             $label = lang_get('created_on_testsuite');
         } else {
             // not found -> create
             tLog('test suite:' . $auto_testsuite_name . ' was not found.');
             $new_tsuite = $tsuite_mgr->create($testproject_id, $auto_testsuite_name, $req_cfg->testsuite_details);
             $tsuite_id = $new_tsuite['id'];
             $label = lang_get('testsuite_name_created');
         }
         $output[] = sprintf($label, $auto_testsuite_name);
     }
     /* end contribution */
     // create TC
     $createOptions = array();
     $createOptions['check_names_for_duplicates'] = config_get('check_names_for_duplicates');
     $createOptions['action_on_duplicate_name'] = config_get('action_on_duplicate_name');
     $testcase_importance_default = config_get('testcase_importance_default');
     // compute test case order
     $testcase_order = config_get('treemenu_default_testcase_order');
     $nt2exclude = array('testplan' => 'exclude_me', 'requirement_spec' => 'exclude_me', 'requirement' => 'exclude_me');
     $siblings = $this->tree_mgr->get_children($tsuite_id, $nt2exclude);
     if (!is_null($siblings)) {
         $dummy = end($siblings);
         $testcase_order = $dummy['node_order'];
     }
     foreach ($reqSet as $reqID) {
         $reqData = $this->get_by_id($reqID, requirement_mgr::LATEST_VERSION);
         $count = !is_null($tc_count) ? $tc_count[$reqID] : 1;
         $reqData = $reqData[0];
         // Generate name with progessive
         $instance = 1;
         $getOptions = array('check_criteria' => 'like', 'access_key' => 'name');
         $itemSet = $tcase_mgr->getDuplicatesByName($reqData['title'], $tsuite_id, $getOptions);
         $nameSet = null;
         if (!is_null($itemSet)) {
             $nameSet = array_flip(array_keys($itemSet));
         }
         for ($idx = 0; $idx < $count; $idx++) {
             $testcase_order++;
             // We have a little problem to work on:
             // suppose you have created:
             // TC [1]
             // TC [2]
             // TC [3]
             // If we delete TC [2]
             // When I got siblings  il will got 2, if I create new progressive using next,
             // it will be 3 => I will get duplicated name.
             //
             // Seems better option can be:
             // Get all siblings names, put on array, create name an check if exists, if true
             // generate a new name.
             // This may be at performance level is better than create name then check on db,
             // because this approach will need more queries to DB
             //
             $tcase_name = $reqData['title'] . " [{$instance}]";
             if (!is_null($nameSet)) {
                 while (isset($nameSet[$tcase_name])) {
                     $instance++;
                     $tcase_name = $reqData['title'] . " [{$instance}]";
                 }
             }
             $nameSet[$tcase_name] = $tcase_name;
             // 20100106 - franciscom - multiple test case steps feature - removed expected_results
             // Julian - BUGID 2995
             $tcase = $tcase_mgr->create($tsuite_id, $tcase_name, $req_cfg->testcase_summary_prefix . $reqData['scope'], $empty_preconditions, $empty_steps, $user_id, null, $testcase_order, testcase::AUTOMATIC_ID, TESTCASE_EXECUTION_TYPE_MANUAL, $testcase_importance_default, $createOptions);
             $tcase_name = $tcase['new_name'] == '' ? $tcase_name : $tcase['new_name'];
             $output[] = sprintf($labels['tc_created'], $tcase_name);
             // create coverage dependency
             if (!$this->assign_to_tcase($reqData['id'], $tcase['id'])) {
                 $output[] = 'Test case: ' . $tcase_name . " was not created";
             }
         }
     }
     return $output;
 }
示例#10
0
 function exportTestSuiteDataToXML($container_id, $tproject_id, $optExport = array())
 {
     static $keywordMgr;
     static $getLastVersionOpt = array('output' => 'minimun');
     static $tcase_mgr;
     if (is_null($keywordMgr)) {
         $keywordMgr = new tlKeyword();
     }
     $xmlTC = null;
     $doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
     if ($doRecursion) {
         $cfXML = null;
         $kwXML = null;
         $tsuiteData = $this->get_by_id($container_id);
         if (isset($optExport['KEYWORDS']) && $optExport['KEYWORDS']) {
             $kwMap = $this->getKeywords($container_id);
             if ($kwMap) {
                 $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
             }
         }
         if (isset($optExport['CFIELDS']) && $optExport['CFIELDS']) {
             $cfMap = (array) $this->get_linked_cfields_at_design($container_id, null, null, $tproject_id);
             if (count($cfMap) > 0) {
                 $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
             }
         }
         $xmlTC = "<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" . "<details><![CDATA[{$tsuiteData['details']}]]> \n{$kwXML}{$cfXML}</details>";
     } else {
         $xmlTC = "<testcases>";
     }
     $test_spec = $this->get_subtree($container_id, self::USE_RECURSIVE_MODE);
     $childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null;
     $tcase_mgr = null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             $nTable = $cNode['node_table'];
             if ($doRecursion && $nTable == 'testsuites') {
                 $xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'], $tproject_id, $optExport);
             } else {
                 if ($nTable == 'testcases') {
                     if (is_null($tcase_mgr)) {
                         $tcase_mgr = new testcase($this->db);
                     }
                     $xmlTC .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'], testcase::LATEST_VERSION, $tproject_id, true, $optExport);
                 }
             }
         }
     }
     $xmlTC .= $doRecursion ? "</testsuite>" : "</testcases>";
     return $xmlTC;
 }
示例#11
0
require_once 'users.inc.php';
require_once 'exttable.class.php';
require_once 'exec.inc.php';
// used for bug string lookup
if (config_get('interface_bugs') != 'NO') {
    require_once TL_ABS_PATH . 'lib' . DIRECTORY_SEPARATOR . 'bugtracking' . DIRECTORY_SEPARATOR . 'int_bugtracking.php';
}
testlinkInitPage($db, true, false, "checkRights");
$templateCfg = templateConfiguration();
$resultsCfg = config_get('results');
$statusCode = $resultsCfg['status_code'];
$args = init_args($statusCode);
$gui = initializeGui($statusCode, $args);
$tplan_mgr = new testplan($db);
$tproject_mgr = new testproject($db);
$tcase_mgr = new testcase($db);
$tplan_info = $tplan_mgr->get_by_id($args->tplan_id);
$tproject_info = $tproject_mgr->get_by_id($args->tproject_id);
$getOpt = array('outputFormat' => 'map');
$gui->platformSet = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt);
$show_platforms = !is_null($gui->platformSet);
if (is_null($gui->platformSet)) {
    $gui->platformSet = array('');
}
$gui->bugInterfaceOn = config_get('bugInterfaceOn');
$bugInterface = null;
if ($gui->bugInterfaceOn) {
    $bugInterface = config_get('bugInterface');
}
$labels = init_labels(array('deleted_user' => null, 'design' => null, 'execution' => null));
$gui->tplan_name = $tplan_info['name'];
 * @author Francisco Mancardi
 *
 * With this page you can launch a set of available methods, to understand
 * and have inside view about return type .
 *
 * @internal revisions
 *
 */
require_once '../../../config.inc.php';
require_once 'common.php';
require_once 'tree.class.php';
// require_once('dBug.php');
testlinkInitPage($db);
echo "<pre> testcase - constructor - testcase(&\$db)";
echo "</pre>";
$tcase_mgr = new testcase($db);
// new dBug($tcase_mgr);
try {
    $fullEID = 'PTJ09-1';
    echo '<br>Testing getInternalID with fullEID<br>';
    $va = $tcase_mgr->getInternalID($fullEID);
    new dBug($va);
} catch (Exception $e) {
    echo 'Message: ' . $e->getMessage();
}
try {
    $EID = 1;
    echo '<br>Testing getInternalID with ONLY NUMERIC EID<br>';
    $va = $tcase_mgr->getInternalID($EID);
    new dBug($va);
} catch (Exception $e) {
示例#13
0
文件: init.php 项目: mendianchun/at
error_reporting(0);
require dirname(__FILE__) . '/../../vendor/autoload.php';
require dirname(__FILE__) . '/../../vendor/predis/predis/src/Autoloader.php';
require dirname(__FILE__) . '/../../class/testcase.php';
require dirname(__FILE__) . '/../../config/testUI/config.php';
require dirname(__FILE__) . '/../../class/db.class.php';
Predis\Autoloader::register();
$redis = new Predis\Client($_config['redis_server']);
//读取case目录的文件,将测试用例写到队列。
$fileArray = scandir($_config['case_dir']);
foreach ($fileArray as $file) {
    if ($file == '.' || $file == '..') {
        continue;
    }
    $count = 0;
    $testcase = new testcase($_config['case_dir'] . $file);
    $case_data = $testcase->getdata();
    //插入队列
    if (is_array($case_data)) {
        foreach ($case_data as $v) {
            //            echo json_encode($v)."\n";
            $redis->rpush($_config['queue_name'], json_encode($v)) . "\n";
            $count++;
        }
    } else {
        $redis->rpush($_config['queue_name'], json_encode($case_data)) . "\n";
        $count = 1;
    }
    if ($count > 0) {
        list($ui, $suffix) = explode(".", $file);
        echo "测试用例  " . $ui . " ... 初始化成功,共" . $count . "个\n";
示例#14
0
/**
 *
 *
 */
function processTestCase(&$dbHandler, $tplEngine, $args, &$gui, $grants, $cfg)
{
    $get_path_info = false;
    $item_mgr = new testcase($dbHandler);
    // has sense only when we work on test case
    $dummy = testcase::getLayout();
    $gui->tableColspan = $dummy->tableToDisplayTestCaseSteps->colspan;
    $gui->viewerArgs['refresh_tree'] = 'no';
    $gui->path_info = null;
    $gui->platforms = null;
    $gui->loadOnCancelURL = '';
    $gui->attachments = null;
    $gui->direct_link = null;
    $gui->steps_results_layout = $cfg['spec']->steps_results_layout;
    $gui->bodyOnUnload = "storeWindowSize('TCEditPopup')";
    if ($args->caller == 'navBar' && !is_null($args->targetTestCase) && strcmp($args->targetTestCase, $args->tcasePrefix) != 0) {
        $args->id = $item_mgr->getInternalID($args->targetTestCase);
        $args->tcversion_id = testcase::ALL_VERSIONS;
        // I've added $args->caller, in order to make clear the logic, because some actions need to be done ONLY
        // when we have arrived to this script because user has requested a search from navBar.
        // Before we have trusted the existence of certain variables (do not think this old kind of approach is good).
        //
        // why strcmp($args->targetTestCase,$args->tcasePrefix) ?
        // because in navBar targetTestCase is initialized with testcase prefix to provide some help to user
        // then if user request search without adding nothing, we will not be able to search.
        // From navBar we want to allow ONLY to search for ONE and ONLY ONE test case ID.
        $gui->viewerArgs['show_title'] = 'no';
        $gui->viewerArgs['display_testproject'] = 1;
        $gui->viewerArgs['display_parent_testsuite'] = 1;
        if (!($get_path_info = $args->id > 0)) {
            $gui->warning_msg = $args->id == 0 ? lang_get('testcase_does_not_exists') : lang_get('prefix_does_not_exists');
        }
    }
    // because we can arrive here from a User Search Request, if args->id == 0 => nothing found
    if ($args->id > 0) {
        if ($get_path_info || $args->show_path) {
            $gui->path_info = $item_mgr->tree_manager->get_full_path_verbose($args->id);
        }
        $platform_mgr = new tlPlatform($dbHandler, $args->tproject_id);
        $gui->platforms = $platform_mgr->getAllAsMap();
        $gui->attachments[$args->id] = getAttachmentInfosFrom($item_mgr, $args->id);
        $gui->direct_link = $item_mgr->buildDirectWebLink($_SESSION['basehref'], $args->id);
        $gui->id = $args->id;
        $identity = new stdClass();
        $identity->id = $args->id;
        $identity->tproject_id = $args->tproject_id;
        $identity->version_id = $args->tcversion_id;
        try {
            $item_mgr->show($tplEngine, $gui, $identity, $grants);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
        exit;
    } else {
        $templateCfg = templateConfiguration();
        // need to initialize search fields
        $xbm = $item_mgr->getTcSearchSkeleton();
        $xbm->warning_msg = lang_get('no_records_found');
        $xbm->pageTitle = lang_get('caption_search_form');
        $xbm->tableSet = null;
        $xbm->doSearch = false;
        $xbm->tproject_id = $args->tproject_id;
        $tplEngine->assign('gui', $xbm);
        $tplEngine->display($templateCfg->template_dir . 'tcSearchResults.tpl');
    }
}
 /**
  *
  *
  * @internal revisions
  * @since 1.9.14
  * allow multiple selection (if advanced mode)
  */
 private function init_filter_workflow_status()
 {
     $key = 'filter_workflow_status';
     if (!$this->tc_mgr) {
         $this->tc_mgr = new testcase($this->db);
     }
     // handle filter reset
     $selection = $this->args->{$key};
     if (!$selection || $this->args->reset_filters) {
         $selection = null;
     } else {
         $this->do_filtering = true;
     }
     $this->filters[$key] = array('items' => array(), 'selected' => $selection);
     // load domain
     // add "any" string to these types at index 0 as default selection
     $this->filters[$key]['items'] = array(0 => $this->option_strings['any']) + $this->tc_mgr->getWorkFlowStatusDomain();
     $this->filters[$key]['size'] = min(count($this->filters[$key]['items']), self::ADVANCED_FILTER_ITEM_QUANTITY);
     $this->active_filters[$key] = $selection;
 }
function saveImportedTCData(&$db, $tcData, $tproject_id, $container_id, $userID, $kwMap, $duplicatedLogic = array('hitCriteria' => 'name', 'actionOnHit' => null))
{
    static $messages;
    static $fieldSizeCfg;
    static $feedbackMsg;
    static $tcase_mgr;
    static $tproject_mgr;
    static $req_spec_mgr;
    static $req_mgr;
    static $safeSizeCfg;
    static $linkedCustomFields;
    static $tprojectHas;
    static $reqSpecSet;
    static $getVersionOpt;
    static $userObj;
    if (!$tcData) {
        return;
    }
    // $tprojectHas = array('customFields' => false, 'reqSpec' => false);
    $hasCustomFieldsInfo = false;
    $hasRequirements = false;
    if (is_null($messages)) {
        $feedbackMsg = array();
        $messages = array();
        $fieldSizeCfg = config_get('field_size');
        $tcase_mgr = new testcase($db);
        $tproject_mgr = new testproject($db);
        $req_spec_mgr = new requirement_spec_mgr($db);
        $req_mgr = new requirement_mgr($db);
        $userObj = new tlUser();
        $k2l = array('already_exists_updated', 'original_name', 'testcase_name_too_long', 'start_warning', 'end_warning', 'testlink_warning', 'hit_with_same_external_ID');
        foreach ($k2l as $k) {
            $messages[$k] = lang_get($k);
        }
        $messages['start_feedback'] = $messages['start_warning'] . "\n" . $messages['testlink_warning'] . "\n";
        $messages['cf_warning'] = lang_get('no_cf_defined_can_not_import');
        $messages['reqspec_warning'] = lang_get('no_reqspec_defined_can_not_import');
        $feedbackMsg['cfield'] = lang_get('cf_value_not_imported_missing_cf_on_testproject');
        $feedbackMsg['tcase'] = lang_get('testcase');
        $feedbackMsg['req'] = lang_get('req_not_in_req_spec_on_tcimport');
        $feedbackMsg['req_spec'] = lang_get('req_spec_ko_on_tcimport');
        // because name can be changed automatically during item creation
        // to avoid name conflict adding a suffix automatically generated,
        // is better to use a max size < max allowed size
        $safeSizeCfg = new stdClass();
        $safeSizeCfg->testcase_name = $fieldSizeCfg->testcase_name * 0.8;
        // Get CF with scope design time and allowed for test cases linked to this test project
        $linkedCustomFields = $tcase_mgr->cfield_mgr->get_linked_cfields_at_design($tproject_id, 1, null, 'testcase', null, 'name');
        $tprojectHas['customFields'] = !is_null($linkedCustomFields);
        $reqSpecSet = $tproject_mgr->getReqSpec($tproject_id, null, array('RSPEC.id', 'NH.name AS title', 'RSPEC.doc_id as rspec_doc_id', 'REQ.req_doc_id'), 'req_doc_id');
        $tprojectHas['reqSpec'] = !is_null($reqSpecSet) && count($reqSpecSet) > 0;
        $getVersionOpt = array('output' => 'minimun');
        $tcasePrefix = $tproject_mgr->getTestCasePrefix($tproject_id);
    }
    $resultMap = array();
    $tc_qty = sizeof($tcData);
    $userIDCache = array();
    for ($idx = 0; $idx < $tc_qty; $idx++) {
        $tc = $tcData[$idx];
        $name = $tc['name'];
        $summary = $tc['summary'];
        $steps = $tc['steps'];
        // I've changed value to use when order has not been provided
        // from testcase:DEFAULT_ORDER to a counter, because with original solution
        // an issue arise with 'save execution and go next'
        // if use has not provided order I think is OK TestLink make any choice.
        $node_order = isset($tc['node_order']) ? intval($tc['node_order']) : $idx + 1;
        $internalid = $tc['internalid'];
        $preconditions = $tc['preconditions'];
        $exec_type = isset($tc['execution_type']) ? $tc['execution_type'] : TESTCASE_EXECUTION_TYPE_MANUAL;
        $importance = isset($tc['importance']) ? $tc['importance'] : MEDIUM;
        $externalid = $tc['externalid'];
        if (intval($externalid) <= 0) {
            $externalid = null;
        }
        $personID = $userID;
        if (!is_null($tc['author_login'])) {
            if (isset($userIDCache[$tc['author_login']])) {
                $personID = $userIDCache[$tc['author_login']];
            } else {
                $userObj->login = $tc['author_login'];
                if ($userObj->readFromDB($db, tlUser::USER_O_SEARCH_BYLOGIN) == tl::OK) {
                    $personID = $userObj->dbID;
                }
                // I will put always a valid userID on this cache,
                // this way if author_login does not exit, and is used multiple times
                // i will do check for existence JUST ONCE.
                $userIDCache[$tc['author_login']] = $personID;
            }
        }
        $name_len = tlStringLen($name);
        if ($name_len > $fieldSizeCfg->testcase_name) {
            // Will put original name inside summary
            $xx = $messages['start_feedback'];
            $xx .= sprintf($messages['testcase_name_too_long'], $name_len, $fieldSizeCfg->testcase_name) . "\n";
            $xx .= $messages['original_name'] . "\n" . $name . "\n" . $messages['end_warning'] . "\n";
            $summary = nl2br($xx) . $summary;
            $name = tlSubStr($name, 0, $safeSizeCfg->testcase_name);
        }
        $kwIDs = null;
        if (isset($tc['keywords']) && $tc['keywords']) {
            $kwIDs = implode(",", buildKeywordList($kwMap, $tc['keywords']));
        }
        $doCreate = true;
        if ($duplicatedLogic['actionOnHit'] == 'update_last_version') {
            switch ($duplicatedLogic['hitCriteria']) {
                case 'name':
                    $info = $tcase_mgr->getDuplicatesByName($name, $container_id);
                    break;
                case 'internalID':
                    $dummy = $tcase_mgr->tree_manager->get_node_hierarchy_info($internalid, $container_id);
                    if (!is_null($dummy)) {
                        $info = null;
                        $info[$internalid] = $dummy;
                    }
                    break;
                case 'externalID':
                    $info = $tcase_mgr->get_by_external($externalid, $container_id);
                    break;
            }
            if (!is_null($info)) {
                $tcase_qty = count($info);
                switch ($tcase_qty) {
                    case 1:
                        $doCreate = false;
                        $tcase_id = key($info);
                        $last_version = $tcase_mgr->get_last_version_info($tcase_id, $getVersionOpt);
                        $tcversion_id = $last_version['id'];
                        $ret = $tcase_mgr->update($tcase_id, $tcversion_id, $name, $summary, $preconditions, $steps, $personID, $kwIDs, $node_order, $exec_type, $importance);
                        $ret['id'] = $tcase_id;
                        $ret['tcversion_id'] = $tcversion_id;
                        $resultMap[] = array($name, $messages['already_exists_updated']);
                        break;
                    case 0:
                        $doCreate = true;
                        break;
                    default:
                        $doCreate = false;
                        break;
                }
            }
        }
        if ($doCreate) {
            // Want to block creation of with existent EXTERNAL ID, if containers ARE DIFFERENT.
            $item_id = intval($tcase_mgr->getInternalID($externalid, array('tproject_id' => $tproject_id)));
            if ($item_id > 0) {
                // who is his parent ?
                $owner = $tcase_mgr->getTestSuite($item_id);
                if ($owner != $container_id) {
                    // Get full path of existent Test Cases
                    $stain = $tcase_mgr->tree_manager->get_path($item_id, null, 'name');
                    $n = count($stain);
                    $stain[$n - 1] = $tcasePrefix . config_get('testcase_cfg')->glue_character . $externalid . ':' . $stain[$n - 1];
                    $stain = implode('/', $stain);
                    $resultMap[] = array($name, $messages['hit_with_same_external_ID'] . $stain);
                    $doCreate = false;
                }
            }
        }
        if ($doCreate) {
            $createOptions = array('check_duplicate_name' => testcase::CHECK_DUPLICATE_NAME, 'action_on_duplicate_name' => $duplicatedLogic['actionOnHit'], 'external_id' => $externalid);
            if ($ret = $tcase_mgr->create($container_id, $name, $summary, $preconditions, $steps, $personID, $kwIDs, $node_order, testcase::AUTOMATIC_ID, $exec_type, $importance, $createOptions)) {
                $resultMap[] = array($name, $ret['msg']);
            }
        }
    }
    return $resultMap;
}
* 
* 	@version 	$Id: gettestcasesummary.php,v 1.4 2010/12/15 21:47:59 mx-julian Exp $
* 	@author 	Francisco Mancardi
* 
*   Used on Add/Remove test case to test plan feature, to display summary via ExtJS tooltip
*
*	@internal Revisions:
*	20091109 - franciscom - BUGID  0002937: add/remove test case hover over test case 
*                                           tooltip replacement with summary 
*/
require_once '../../config.inc.php';
require_once 'common.php';
testlinkInitPage($db);
// BUGID 4066 - take care of proper escaping when magic_quotes_gpc is enabled
$_REQUEST = strings_stripSlashes($_REQUEST);
$tcase_mgr = new testcase($db);
$tcase_id = isset($_REQUEST['tcase_id']) ? $_REQUEST['tcase_id'] : null;
$tcversion_id = isset($_REQUEST['tcversion_id']) ? $_REQUEST['tcversion_id'] : 0;
$info = '';
if (!is_null($tcase_id)) {
    if ($tcversion_id > 0) {
        $tcase = $tcase_mgr->get_by_id($tcase_id, $tcversion_id);
        if (!is_null($tcase)) {
            $tcase = $tcase[0];
        }
    } else {
        $tcase = $tcase_mgr->get_last_version_info($tcase_id);
    }
    $info = $tcase['summary'];
    // <p> and </p> tag at the beginning and the end of summary cause visualization
    // errors -> remove them and add <br> to get a similar effect
示例#18
0
function setUpForBulkExec($guiObj)
{
    $guiObj->execStatusValues = testcase::createExecutionResultsMenu();
    if (isset($guiObj->execStatusValues[$guiObj->cfg->tc_status['all']])) {
        unset($guiObj->execStatusValues[$guiObj->cfg->tc_status['all']]);
    }
    $of = web_editor("bulk_exec_notes", $_SESSION['basehref'], $guiObj->cfg->editorCfg);
    $of->Value = getItemTemplateContents('execution_template', $of->InstanceName, null);
    // Magic numbers that can be determined by trial and error
    $guiObj->bulk_exec_notes_editor = $of->CreateHTML(10, 60);
    unset($of);
}
 /**
  * 
  *
  */
 private function exportTestSuiteDataToXML($container, $tproject_id, $tplan_id, $platform_id)
 {
     static $keywordMgr;
     static $getLastVersionOpt = array('output' => 'minimun');
     static $tcaseMgr;
     static $tsuiteMgr;
     static $tcaseExportOptions;
     static $linkedItems;
     if (is_null($keywordMgr)) {
         $tcaseExportOptions = array('CFIELDS' => true, 'KEYWORDS' => true, 'EXEC_ORDER' => 0);
         $keywordMgr = new tlKeyword();
         $tsuiteMgr = new testsuite($this->db);
         $linkedItems = $this->getLinkedItems($tplan_id);
     }
     $xmlTC = null;
     $cfXML = null;
     $kwXML = null;
     if (isset($container['id'])) {
         $kwMap = $tsuiteMgr->getKeywords($container['id']);
         if ($kwMap) {
             $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
         }
         $cfMap = (array) $tsuiteMgr->get_linked_cfields_at_design($container['id'], null, null, $tproject_id);
         if (count($cfMap) > 0) {
             $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
         }
         $tsuiteData = $tsuiteMgr->get_by_id($container['id']);
         $xmlTC = "\n\t<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n\t\t<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>" . "\n\t\t<details><![CDATA[{$tsuiteData['details']}]]>" . "\n\t\t{$kwXML}{$cfXML}</details>";
     }
     $childNodes = isset($container['childNodes']) ? $container['childNodes'] : null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             switch ($cNode['node_table']) {
                 case 'testsuites':
                     $xmlTC .= $this->exportTestSuiteDataToXML($cNode, $tproject_id, $tplan_id, $platform_id);
                     break;
                 case 'testcases':
                     if (is_null($tcaseMgr)) {
                         $tcaseMgr = new testcase($this->db);
                     }
                     // testcase::LATEST_VERSION,
                     $tcaseExportOptions['EXEC_ORDER'] = $linkedItems[$cNode['id']][$platform_id]['node_order'];
                     $xmlTC .= $tcaseMgr->exportTestCaseDataToXML($cNode['id'], $cNode['tcversion_id'], $tproject_id, testcase::NOXMLHEADER, $tcaseExportOptions);
                     break;
             }
         }
     }
     if (isset($container['id'])) {
         $xmlTC .= "</testsuite>";
     }
     return $xmlTC;
 }
示例#20
0
/**
 * process_testcase
 *
 */
function process_testcase(&$dbHandler, $externalID, $tprojectID, $tprojectPrefix, $version)
{
    $ret = array();
    $ret['url'] = null;
    $ret['msg'] = sprintf(lang_get('testcase_not_found'), $externalID, $tprojectPrefix);
    $tcase_mgr = new testcase($dbHandler);
    $tcaseID = $tcase_mgr->getInternalID($externalID);
    if ($tcaseID > 0) {
        $ret['url'] = "lib/testcases/archiveData.php?edit=testcase&id={$tcaseID}";
        $cookie = buildCookie($dbHandler, $tcaseID, $tprojectID, 'ys-tproject_');
        setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/');
    }
    return $ret;
}
示例#21
0
 function exportTestSuiteDataToXML($container_id, $tproject_id, $optExport = array())
 {
     static $keywordMgr;
     if (is_null($keywordMgr)) {
         $keywordMgr = new tlKeyword();
     }
     // echo __FUNCTION__ . '<br>';
     $xmlTC = null;
     $doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
     if ($doRecursion) {
         $cfXML = null;
         $kwXML = null;
         $tsuiteData = $this->get_by_id($container_id);
         if (@$optExport['KEYWORDS']) {
             $kwMap = $this->getKeywords($container_id);
             if ($kwMap) {
                 $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
             }
         }
         if ($optExport['CFIELDS']) {
             // 20090106 - franciscom - custom fields
             $cfMap = $this->get_linked_cfields_at_design($container_id, null, null, $tproject_id);
             if (!is_null($cfMap) && count($cfMap) > 0) {
                 $cfRootElem = "<custom_fields>{{XMLCODE}}</custom_fields>";
                 $cfElemTemplate = "\t" . '<custom_field><name><![CDATA[' . "\n||NAME||\n]]>" . "</name>" . '<value><![CDATA[' . "\n||VALUE||\n]]>" . '</value></custom_field>' . "\n";
                 $cfDecode = array("||NAME||" => "name", "||VALUE||" => "value");
                 $cfXML = exportDataToXML($cfMap, $cfRootElem, $cfElemTemplate, $cfDecode, true);
             }
         }
         $xmlTC = "<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" . "<details><![CDATA[{$tsuiteData['details']}]]> \n{$kwXML}{$cfXML}</details>";
     } else {
         $xmlTC = "<testcases>";
     }
     $test_spec = $this->get_subtree($container_id, self::USE_RECURSIVE_MODE);
     $childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null;
     $tcase_mgr = null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             $nTable = $cNode['node_table'];
             if ($doRecursion && $nTable == 'testsuites') {
                 $xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'], $tproject_id, $optExport);
             } else {
                 if ($nTable == 'testcases') {
                     if (is_null($tcase_mgr)) {
                         $tcase_mgr = new testcase($this->db);
                     }
                     $xmlTC .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'], testcase::LATEST_VERSION, $tproject_id, true, $optExport);
                 }
             }
         }
     }
     $xmlTC .= $doRecursion ? "</testsuite>" : "</testcases>";
     return $xmlTC;
 }
示例#22
0
/**
 * processTestCase
 *
 */
function processTestCase(&$dbHandler, &$argsObj, &$guiObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $guiObj->arrReqSpec = $tproject_mgr->genComboReqSpec($argsObj->tproject_id, 'dotted', "&nbsp;");
    $SRS_qty = count($guiObj->arrReqSpec);
    if ($SRS_qty > 0) {
        $tc_mgr = new testcase($dbHandler);
        $arrTc = $tc_mgr->get_by_id($argsObj->id);
        if ($arrTc) {
            $guiObj->tcTitle = $arrTc[0]['name'];
            // get first ReqSpec if not defined
            if (is_null($argsObj->idReqSpec)) {
                reset($guiObj->arrReqSpec);
                $argsObj->idReqSpec = key($guiObj->arrReqSpec);
            }
            if ($argsObj->idReqSpec) {
                $req_spec_mgr = new requirement_spec_mgr($dbHandler);
                $guiObj->arrAssignedReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec, 'assigned', $argsObj->id);
                if (!is_null($guiObj->arrAssignedReq)) {
                    $xc = $req_spec_mgr->getAssignedCoverage($argsObj->idReqSpec);
                    $l2d = count($guiObj->arrAssignedReq);
                    for ($xdx = 0; $xdx < $l2d; $xdx++) {
                        $guiObj->arrAssignedReq[$xdx]['coverageAuthor'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['login'];
                        $guiObj->arrAssignedReq[$xdx]['coverageTS'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['creation_ts'];
                    }
                }
                $guiObj->arrAllReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec);
                $guiObj->arrUnassignedReq = array_diff_byId($guiObj->arrAllReq, $guiObj->arrAssignedReq);
            }
        }
    }
    return $guiObj;
}
示例#23
0
 private function copy_linked_tcversions($id, $new_tplan_id, $user_id = -1, $options = null, $mappings = null, $build_id_mapping)
 {
     $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
     $my['options']['tcversion_type'] = null;
     $my['options']['copy_assigned_to'] = 0;
     $my['options'] = array_merge($my['options'], (array) $options);
     $now_ts = $this->db->db_now();
     $sql = "/* {$debugMsg} */ ";
     if ($my['options']['copy_assigned_to']) {
         // BUGID 3846
         $sql .= " SELECT TPTCV.*, COALESCE(UA.user_id,-1) AS tester, " . " COALESCE(UA.build_id,0) as assigned_build " . " FROM {$this->tables['testplan_tcversions']} TPTCV " . " LEFT OUTER JOIN {$this->tables['user_assignments']} UA ON " . " UA.feature_id = TPTCV.id " . " WHERE testplan_id={$id} ";
     } else {
         $sql .= " SELECT TPTCV.* FROM {$this->tables['testplan_tcversions']} TPTCV" . " WHERE testplan_id={$id} ";
     }
     $rs = $this->db->get_recordset($sql);
     if (!is_null($rs)) {
         $tcase_mgr = new testcase($this->db);
         $doMappings = !is_null($mappings);
         // BUGID 3846
         $already_linked_versions = array();
         foreach ($rs as $elem) {
             $tcversion_id = $elem['tcversion_id'];
             // Seems useless - 20100204
             $feature_id = $elem['id'];
             if (!is_null($my['options']['tcversion_type'])) {
                 $sql = "/* {$debugMsg} */ SELECT * FROM {$this->tables['nodes_hierarchy']} WHERE id={$tcversion_id} ";
                 $rs2 = $this->db->get_recordset($sql);
                 $last_version_info = $tcase_mgr->get_last_version_info($rs2[0]['parent_id']);
                 $tcversion_id = $last_version_info ? $last_version_info['id'] : $tcversion_id;
             }
             // mapping need to be done with:
             // platforms
             // test case versions
             $platform_id = $elem['platform_id'];
             if ($doMappings) {
                 if (isset($mappings['platforms'][$platform_id])) {
                     $platform_id = $mappings['platforms'][$platform_id];
                 }
                 if (isset($mappings['test_spec'][$tcversion_id])) {
                     $tcversion_id = $mappings['test_spec'][$tcversion_id];
                 }
             }
             $sql = "/* {$debugMsg} */ " . " INSERT INTO {$this->tables['testplan_tcversions']} " . " (testplan_id,tcversion_id,platform_id,node_order,urgency) " . " VALUES({$new_tplan_id},{$tcversion_id},{$platform_id}," . " {$elem['node_order']},{$elem['urgency']})";
             //echo "<br>debug - <b><i>" . __FUNCTION__ . "</i></b><br><b>" . $sql . "</b><br>";
             // BUGID 3846
             if (!in_array($tcversion_id, $already_linked_versions)) {
                 $this->db->exec_query($sql);
                 $new_feature_id = $this->db->insert_id($this->tables['testplan_tcversions']);
                 $already_linked_versions[] = $tcversion_id;
             }
             if ($my['options']['copy_assigned_to'] && $elem['tester'] > 0) {
                 $features_map = array();
                 $feature_id = $new_feature_id;
                 $features_map[$feature_id]['user_id'] = $elem['tester'];
                 // BUGID 3846
                 $features_map[$feature_id]['build_id'] = $build_id_mapping[$elem['assigned_build']];
                 $features_map[$feature_id]['type'] = $this->assignment_types['testcase_execution']['id'];
                 $features_map[$feature_id]['status'] = $this->assignment_status['open']['id'];
                 $features_map[$feature_id]['creation_ts'] = $now_ts;
                 $features_map[$feature_id]['assigner_id'] = $user_id;
                 if ($features_map[$feature_id]['build_id'] != 0) {
                     $this->assignment_mgr->assign($features_map);
                 }
             }
         }
     }
 }
示例#24
0
 /**
 * get test case specification using external ir internal id
 * 
 * @param struct $args
 * @param string $args["devKey"]
 * @param int $args["testcaseid"]: optional, if does not is present           
 *                                 testcaseexternalid must be present
 *
 * @param int $args["testcaseexternalid"]: optional, if does not is present           
 *                                         testcaseid must be present
 * @param int $args["version"]: optional, if does not is present max version number will be
 *                                        retuned
 *
 * @return mixed $resultInfo
 */
 public function getTestCase($args)
 {
     $msg_prefix = "(" . __FUNCTION__ . ") - ";
     $status_ok = true;
     $this->_setArgs($args);
     $checkFunctions = array('authenticate', 'checkTestCaseIdentity');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix) && $this->userHasRight("mgt_view_tc");
     $version_id = testcase::LATEST_VERSION;
     $version_number = -1;
     if ($status_ok) {
         // check optional arguments
         if ($this->_isParamPresent(self::$versionNumberParamName)) {
             if ($status_ok = $this->checkTestCaseVersionNumber()) {
                 $version_id = null;
                 $version_number = $this->args[self::$versionNumberParamName];
             }
         }
     }
     if ($status_ok) {
         $testCaseMgr = new testcase($this->dbObj);
         $id = $this->args[self::$testCaseIDParamName];
         $result = $testCaseMgr->get_by_id($id, $version_id, 'ALL', 'ALL', $version_number);
         if (0 == sizeof($result)) {
             $status_ok = false;
             $this->errors[] = new IXR_ERROR(NO_TESTCASE_FOUND, $msg_prefix . NO_TESTCASE_FOUND_STR);
             return $this->errors;
         }
     }
     return $status_ok ? $result : $this->errors;
 }
示例#25
0
 * @copyright   2007-2015, TestLink community 
 * @link        http://www.testlink.org/
 *
 *
 * @internal revisions
 * @since 1.9.15
 **/
require_once "../../config.inc.php";
require_once "common.php";
require_once 'exttable.class.php';
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$smarty = new TLSmarty();
$tpl = 'tcSearchResults.tpl';
$tproject_mgr = new testproject($db);
$tcase_mgr = new testcase($db);
$tcase_cfg = config_get('testcase_cfg');
$charset = config_get('charset');
$filter = null;
list($args, $filter) = init_args($tproject_mgr);
$ga = initializeGui($args, $tproject_mgr);
$gx = $tcase_mgr->getTcSearchSkeleton($args);
$gui = (object) array_merge((array) $ga, (array) $gx);
initSearch($gui, $args, $tproject_mgr);
$map = null;
if ($args->tprojectID && $args->doAction == 'doSearch') {
    $tables = tlObjectWithDB::getDBTables(array('cfield_design_values', 'nodes_hierarchy', 'requirements', 'req_coverage', 'tcsteps', 'testcase_keywords', 'tcversions', 'users'));
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($args->tprojectID);
    $gui->tcasePrefix .= $tcase_cfg->glue_character;
    $from = array('by_keyword_id' => ' ', 'by_custom_field' => ' ', 'by_requirement_doc_id' => '', 'users' => '');
    $tcaseID = null;
示例#26
0
/**
 * 
 *
 */
function tcaseSetAsXML(&$dbHandler, $contextSet)
{
    $tcaseMgr = new testcase($dbHandler);
    $tcversionSet = explode(',', $contextSet->tcversionSet);
    $xmlTC = "<testcases>\n\t";
    foreach ($tcversionSet as $tcversion_id) {
        $xmlTC .= $tcaseMgr->exportTestCaseDataToXML(0, $tcversion_id, $contextSet->tproject_id, true);
    }
    $xmlTC .= "</testcases>\n\t";
    return $xmlTC;
}
示例#27
0
 * @author 		Amit Khullar - amkhullar@gmail.com
 * @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);
示例#28
0
require_once "../../config.inc.php";
require_once "common.php";
require_once "exttable.class.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$smarty = new TLSmarty();
$imgSet = $smarty->getImages();
$args = init_args($db);
$gui = initializeGui($db, $args);
$statusGui = getStatusGuiCfg();
// Get all test cases assigned to user without filtering by execution status
$options = new stdClass();
$options->mode = 'full_path';
$filters = initFilters($args);
$tplan_param = $args->tplan_id ? array($args->tplan_id) : testcase::ALL_TESTPLANS;
$tcase_mgr = new testcase($db);
$gui->resultSet = $tcase_mgr->get_assigned_to_user($args->user_id, $args->tproject_id, $tplan_param, $options, $filters);
$doIt = !is_null($gui->resultSet);
if ($doIt) {
    $tables = tlObjectWithDB::getDBTables(array('nodes_hierarchy'));
    $tplanSet = array_keys($gui->resultSet);
    $sql = "SELECT name,id FROM {$tables['nodes_hierarchy']} " . "WHERE id IN (" . implode(',', $tplanSet) . ")";
    $gui->tplanNames = $db->fetchRowsIntoMap($sql, 'id');
    $optColumns = array('user' => $args->show_user_column, 'priority' => $args->priority_enabled);
    $whoiam = $args->show_all_users ? 'tcAssignedToUser' : 'tcAssignedToMe';
    foreach ($gui->resultSet as $tplan_id => $tcase_set) {
        list($columns, $sortByColumn, $show_platforms) = getColumnsDefinition($db, $tplan_id, $optColumns);
        $rows = array();
        foreach ($tcase_set as $tcase_platform) {
            foreach ($tcase_platform as $tcase) {
                $current_row = array();
function migrate_tc_specs(&$source_db, &$target_db, &$tmp_table_name, &$users, &$migrator)
{
    $first_version = 1;
    $tc_mgr = new testcase($target_db);
    $map_tc_tcversion = array();
    $admin_id = 1;
    $items_processed = 0;
    // how many records are we going to tackle at a time
    // with basic benchmarking roughly 500 seemed to be slightly faster
    $step_amt = 500;
    print_msg("<b><center>Migrating Test Cases - Part I - " . date("H:i:s") . " -</center></b><br>");
    $tc_count = $migrator->get_tmp_table_count();
    // Make sure we have enough memory to do what we are about to do
    check_memory($tc_count);
    // testcase nodes have to be done separately from tcversions because the version
    // inserts a new node
    while ($items_processed < $tc_count) {
        $query = "SELECT * FROM {$tmp_table_name} ORDER BY id LIMIT {$items_processed},{$step_amt}";
        $items = $source_db->fetchRowsIntoMap($query, 'id');
        foreach ($items as $item_id => $idata) {
            // 20061208 - franciscom -
            // added abs()
            // added htmlentities()
            print_msg("TCID:{$item_id} - " . htmlentities($idata['title']) . "<br>");
            $status = $tc_mgr->create_tcase_only(0, $idata['title'], abs($idata['TCorder']), $item_id);
            ++$items_processed;
            if ($items_processed % FEEDBACK_STEP == 0) {
                print_msg('<br><span class="processed">Part I - Processed: ' . $items_processed . " - " . date("H:i:s") . "</span><br>", "FULL_FEEDBACK");
            }
        }
        print_msg("<br><span class='processed'>Going to process another {$step_amt} items</span>", "FULL_FEEDBACK");
    }
    print_msg("Finished Part I -" . date("H:i:s"));
    //---------------------------------------------------------------------------
    // now loop through again and do the versions... this is highly inefficient
    // to loop through the dataset another time but it works without big changes
    //---------------------------------------------------------------------------
    print_msg("<br> <b><center>Migrating Test Cases - Part II - " . date("H:i:s") . " -</center></b><br>");
    $items_processed = 0;
    while ($items_processed < $tc_count) {
        $query = "SELECT * FROM {$tmp_table_name} ORDER BY id LIMIT {$items_processed},{$step_amt}";
        $items = $source_db->fetchRowsIntoMap($query, 'id');
        foreach ($items as $item_id => $idata) {
            // Now create the TC version
            $author_id = intval(isset($users[$idata['author']]) ? $users[$idata['author']]['id'] : $admin_id);
            $x = $tc_mgr->create_tcversion($item_id, $first_version, $idata['summary'], $idata['steps'], $idata['exresult'], $author_id);
            $sql = "UPDATE tcversions SET creation_ts='" . $idata['create_date'] . "'";
            // update reviewer & review date
            $reviewer_id = intval(isset($users[$idata['reviewer']]) ? $users[$idata['reviewer']]['id'] : -1);
            if ($reviewer_id > 0) {
                $sql .= ",updater_id={$reviewer_id}" . ",modification_ts='" . $idata['modified_date'] . "'";
            }
            // 20070119 - franciscom - very big bug - missing where clause
            $sql .= " WHERE tcversions.id={$x['id']} ";
            //echo "<br>update query is $sql";
            $target_db->exec_query($sql);
            $map_tc_tcversion[$item_id] = $x['id'];
            // 20061208 - franciscom
            print_msg("TCID:{$item_id} - " . htmlentities($idata['title']) . " - TCVERSION_ID:{$x['id']}<br>", "FULL_FEEDBACK");
            ++$items_processed;
            if ($items_processed % FEEDBACK_STEP == 0) {
                print_msg('<br><span class="processed">Part II - Processed: ' . $items_processed . " - " . date("H:i:s") . "</span><br><br>");
            }
        }
        print_msg("<br><span class='processed'>Going to process another {$step_amt} items</span>", "FULL_FEEDBACK");
    }
    print_msg("Test Case Specifications MIGRATION ENDED ::: " . date("H:i:s") . "<br>");
    return $map_tc_tcversion;
}
示例#30
0
 /**
 * get test case specification using external ir internal id
 * 
 * @param struct $args
 * @param string $args["devKey"]
 * @param int $args["testcaseid"]: optional, if does not is present           
 *                                 testcaseexternalid must be present
 *
 * @param int $args["testcaseexternalid"]: optional, if does not is present           
 *                                         testcaseid must be present
 * @param int $args["version"]: optional, if does not is present max version number will be
 *                                        retuned
 *
 * @return mixed $resultInfo
 */
 public function getTestCase($args)
 {
     $msg_prefix = "(" . __FUNCTION__ . ") - ";
     $status_ok = true;
     $this->_setArgs($args);
     $checkFunctions = array('authenticate', 'checkTestCaseIdentity');
     $status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
     // &&
     //             $this->userHasRight("mgt_view_tc",self::CHECK_PUBLIC_PRIVATE_ATTR);
     $version_id = testcase::LATEST_VERSION;
     $version_number = -1;
     if ($status_ok) {
         // check optional arguments
         if ($this->_isParamPresent(self::$versionNumberParamName)) {
             if ($status_ok = $this->checkTestCaseVersionNumber()) {
                 $version_id = null;
                 $version_number = $this->args[self::$versionNumberParamName];
             }
         }
     }
     if ($status_ok) {
         $testCaseMgr = new testcase($this->dbObj);
         $id = $this->args[self::$testCaseIDParamName];
         // $result = $testCaseMgr->get_by_id($id,$version_id,'ALL','ALL',$version_number);
         $filters = array('active_status' => 'ALL', 'open_status' => 'ALL', 'version_number' => $version_number);
         $result = $testCaseMgr->get_by_id($id, $version_id, $filters);
         // return $result;
         if (0 == sizeof($result)) {
             $status_ok = false;
             $this->errors[] = new IXR_ERROR(NO_TESTCASE_FOUND, $msg_prefix . NO_TESTCASE_FOUND_STR);
             return $this->errors;
         } else {
             if (isset($this->args[self::$testCaseExternalIDParamName])) {
                 $result[0]['full_tc_external_id'] = $this->args[self::$testCaseExternalIDParamName];
             } else {
                 $dummy = $this->tcaseMgr->getPrefix($id);
                 $result[0]['full_tc_external_id'] = $dummy[0] . config_get('testcase_cfg')->glue_character . $result[0]['tc_external_id'];
             }
         }
     }
     if ($status_ok) {
         // before returning info need to understand if test case belongs to a test project
         // accessible to user requesting info
         // return $result[0]['id'];
         $this->args[self::$testProjectIDParamName] = $this->tcaseMgr->get_testproject($result[0]['id']);
         $status_ok = $this->userHasRight("mgt_view_tc", self::CHECK_PUBLIC_PRIVATE_ATTR);
     }
     return $status_ok ? $result : $this->errors;
 }