function init_args(&$tcaseMgr)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    new dBug($_REQUEST);
    $args = new stdClass();
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : null;
    switch ($args->doAction) {
        case 'apply':
            break;
        default:
            $args->doAction = 'init';
            break;
    }
    $args->tcase_id = isset($_REQUEST['tcase_id']) ? intval($_REQUEST['tcase_id']) : 0;
    $args->goback_url = isset($_REQUEST['goback_url']) ? $_REQUEST['goback_url'] : null;
    $args->uchoice = array();
    $k2s = array('importance', 'status', 'execution_type');
    foreach ($k2s as $tg) {
        $args->uchoice[$tg] = intval(isset($_REQUEST[$tg]) ? $_REQUEST[$tg] : -1);
    }
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $args->tcStatusCfg['status_code'] = $dummy['cfg'];
    $args->tcStatusCfg['code_label'] = $dummy['lbl'];
    $args->domainTCExecType = $tcaseMgr->get_execution_types();
    $dummy = config_get('importance');
    $args->domainTCImportance = $dummy['code_label'];
    return $args;
}
function initializeGui(&$dbHandler, &$argsObj)
{
    $tproject_mgr = new testproject($dbHandler);
    $gui = new stdClass();
    $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tprojectID) . config_get('testcase_cfg')->glue_character;
    $gui->mainCaption = lang_get('testproject') . " " . $argsObj->tprojectName;
    $gui->importance = config_get('testcase_importance_default');
    $gui->creation_date_from = null;
    $gui->creation_date_to = null;
    $gui->modification_date_from = null;
    $gui->modification_date_to = null;
    $gui->search_important_notice = sprintf(lang_get('search_important_notice'), $argsObj->tprojectName);
    $gui->design_cf = $tproject_mgr->cfield_mgr->get_linked_cfields_at_design($argsObj->tprojectID, cfield_mgr::ENABLED, null, 'testcase');
    $gui->keywords = $tproject_mgr->getKeywords($argsObj->tprojectID);
    $gui->filter_by['design_scope_custom_fields'] = !is_null($gui->design_cf);
    $gui->filter_by['keyword'] = !is_null($gui->keywords);
    $reqSpecSet = $tproject_mgr->genComboReqSpec($argsObj->tprojectID);
    $gui->filter_by['requirement_doc_id'] = !is_null($reqSpecSet);
    $gui->option_importance = array(0 => '', HIGH => lang_get('high_importance'), MEDIUM => lang_get('medium_importance'), LOW => lang_get('low_importance'));
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $gui->domainTCStatus = array(0 => '') + $dummy['lbl'];
    return $gui;
}
Exemplo n.º 3
0
 /**
  *
  */
 function getWorkFlowStatusDomain()
 {
     $dummy = getConfigAndLabels('testCaseStatus', 'code');
     return $dummy['lbl'];
 }
Exemplo n.º 4
0
function init_args(&$dbHandler, &$cfgObj, &$tprojectMgr)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $args->basehref = $_SESSION['basehref'];
    $args->user_id = $_SESSION['userID'];
    $args->tproject_id = intval($_REQUEST['tproject_id']);
    $args->user = $_SESSION['currentUser'];
    $args->userGrants = new stdClass();
    $args->userGrants->mgt_modify_tc = $args->user->hasRight($dbHandler, 'mgt_modify_tc', $args->tproject_id);
    $args->userGrants->mgt_view_req = $args->user->hasRight($dbHandler, "mgt_view_req", $args->tproject_id);
    $args->userGrants->testplan_planning = $args->user->hasRight($dbHandler, "testplan_planning", $args->tproject_id);
    $args->exec_type = isset($_REQUEST['exec_type']) ? $_REQUEST['exec_type'] : TESTCASE_EXECUTION_TYPE_MANUAL;
    $args->importance = isset($_REQUEST['importance']) ? $_REQUEST['importance'] : config_get('testcase_importance_default');
    $args->name = isset($_REQUEST['testcase_name']) ? $_REQUEST['testcase_name'] : null;
    $k2null = array('summary', 'preconditions', 'steps', 'expected_results', 'step_set', 'tcaseSteps', 'goback_url');
    foreach ($k2null as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? $_REQUEST[$key] : null;
    }
    $id2get = array('tcase_id' => 'testcase_id', 'tcversion_id' => 'tcversion_id', 'new_container_id' => 'new_container', 'old_container_id' => 'old_container', 'has_been_executed' => 'has_been_executed', 'step_number' => 'step_number', 'step_id' => 'step_id');
    foreach ($id2get as $prop => $input) {
        $args->{$prop} = isset($_REQUEST[$input]) ? intval($_REQUEST[$input]) : 0;
    }
    $id2get = array('tsuiteID' => array('tsuiteID', 'testsuite_id'));
    foreach ($id2get as $prop => $inputSet) {
        $args->{$prop} = 0;
        foreach ($inputSet as $input) {
            if (isset($_REQUEST[$input])) {
                $args->{$prop} = intval($_REQUEST[$input]);
                break;
            }
        }
    }
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $args->tcStatusCfg['status_code'] = $dummy['cfg'];
    $args->tcStatusCfg['code_label'] = $dummy['lbl'];
    $args->tc_status = isset($_REQUEST['tc_status']) ? intval($_REQUEST['tc_status']) : $args->tcStatusCfg['status_code']['draft'];
    $dk = 'estimated_execution_duration';
    $args->{$dk} = trim(isset($_REQUEST[$dk]) ? $_REQUEST[$dk] : '');
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : '';
    $key2loop = array('edit_tc' => 'edit', 'delete_tc' => 'delete', 'do_delete' => 'doDelete', 'create_tc' => 'create', 'do_create' => 'doCreate');
    foreach ($key2loop as $key => $action) {
        if (isset($_REQUEST[$key])) {
            $args->doAction = $action;
            break;
        }
    }
    $key2loop = array('move_copy_tc', 'delete_tc_version', 'do_move', 'do_copy', 'do_create_new_version', 'do_delete_tc_version', 'stay_here');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? 1 : 0;
    }
    $args->do_activate_this = isset($_REQUEST['activate_this_tcversion']) ? 1 : 0;
    $args->do_deactivate_this = isset($_REQUEST['deactivate_this_tcversion']) ? 1 : 0;
    $args->target_position = isset($_REQUEST['target_position']) ? $_REQUEST['target_position'] : 'bottom';
    $key2loop = array("keyword_assignments", "requirement_assignments");
    foreach ($key2loop as $key) {
        $args->copy[$key] = isset($_REQUEST[$key]) ? true : false;
    }
    $args->show_mode = isset($_REQUEST['show_mode']) && $_REQUEST['show_mode'] != '' ? $_REQUEST['show_mode'] : null;
    $dummy = $tprojectMgr->get_by_id($args->tproject_id);
    $args->opt_requirements = $dummy['opt']->requirementsEnabled;
    $args->requirementsEnabled = $dummy['opt']->requirementsEnabled;
    $args->automationEnabled = $dummy['opt']->automationEnabled;
    $args->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
    // TABBED BROWSING
    $args->refreshTree = testproject::getUserChoice($args->tproject_id, array('tcaseTreeRefreshOnAction', 'edit_mode'));
    $action2check = array("editStep" => true, "createStep" => true, "doCreateStep" => true, "doUpdateStep" => true, "doInsertStep" => true);
    if (isset($action2check[$args->doAction])) {
        $cfgObj->webEditorCfg = getWebEditorCfg('steps_design');
    }
    $args->assigned_keyword_list = isset($_REQUEST['assigned_keyword_list']) ? $_REQUEST['assigned_keyword_list'] : "";
    return $args;
}
Exemplo n.º 5
0
function moveTestCasesViewer(&$dbHandler, &$smartyObj, &$tprojectMgr, &$treeMgr, $argsObj, $feedback = '')
{
    $tables = $tprojectMgr->getDBTables(array('nodes_hierarchy', 'node_types', 'tcversions'));
    $testcase_cfg = config_get('testcase_cfg');
    $glue = $testcase_cfg->glue_character;
    $containerID = isset($argsObj->testsuiteID) ? $argsObj->testsuiteID : $argsObj->objectID;
    $containerName = $argsObj->tsuite_name;
    if (is_null($containerName)) {
        $dummy = $treeMgr->get_node_hierarchy_info($argsObj->objectID);
        $containerName = $dummy['name'];
    }
    // 20081225 - franciscom have discovered that exclude selected testsuite branch is not good
    //            when you want to move lots of testcases from one testsuite to it's children
    //            testsuites. (in this situation tree drag & drop is not ergonomic).
    $testsuites = $tprojectMgr->gen_combo_test_suites($argsObj->tprojectID);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tprojectID) . $glue;
    // 20081225 - franciscom
    // While testing with PostGres have found this behaivour:
    // No matter is UPPER CASE has used on field aliases, keys on hash returned by
    // ADODB are lower case.
    // Accessing this keys on Smarty template using UPPER CASE fails.
    // Solution: have changed case on Smarty to lower case.
    //
    // $sql = "SELECT NHA.id AS tcid, NHA.name AS tcname, NHA.node_order AS tcorder," .
    //        " MAX(TCV.version) AS tclastversion, TCV.tc_external_id AS tcexternalid" .
    //        " FROM {$tables['nodes_hierarchy']} NHA, {$tables['nodes_hierarchy']}  NHB, " .
    //        " {$tables['node_types']} NT, {$tables['tcversions']}  TCV " .
    //        " WHERE NHB.parent_id=NHA.id " .
    //        " AND TCV.id=NHB.id AND NHA.node_type_id = NT.id AND NT.description='testcase'" .
    //        " AND NHA.parent_id={$containerID} " .
    //        " GROUP BY NHA.id,NHA.name,NHA.node_order,TCV.tc_external_id ";
    // $orderClause = " ORDER BY TCORDER,TCNAME";
    // $sql .= $orderClause;
    // $children = $dbHandler->get_recordset($sql);
    $sqlA = " SELECT MAX(TCV.version) AS lvnum, NHTC.node_order, NHTC.name, NHTC.id, TCV.tc_external_id AS tcexternalid" . " FROM {$tables['nodes_hierarchy']} NHTC " . " JOIN {$tables['nodes_hierarchy']} NHTCV ON NHTCV.parent_id = NHTC.id " . " JOIN {$tables['tcversions']} TCV ON TCV.id = NHTCV.id " . " JOIN {$tables['node_types']} NT ON NT.id = NHTC.node_type_id AND NT.description='testcase'" . " WHERE NHTC.parent_id = " . intval($containerID);
    if (!is_null($argsObj->testCaseSet)) {
        $sqlA .= " AND NHTC.id IN (" . implode(',', $argsObj->testCaseSet) . ")";
    }
    $sqlA .= " GROUP BY NHTC.id,TCV.tc_external_id,NHTC.name,NHTC.node_order ";
    $sqlB = " SELECT SQLA.id AS tcid, SQLA.name AS tcname,SQLA.node_order AS tcorder, SQLA.tcexternalid," . " MTCV.summary,MTCV.status,MTCV.importance,MTCV.id AS tcversion_id FROM ({$sqlA}) SQLA " . " JOIN {$tables['nodes_hierarchy']} MNHTCV ON MNHTCV.parent_id = SQLA.id " . " JOIN {$tables['tcversions']} MTCV ON MTCV.id = MNHTCV.id AND MTCV.version = SQLA.lvnum";
    $orderClause = " ORDER BY TCORDER,TCNAME";
    $children = $dbHandler->get_recordset($sqlB . $orderClause);
    // check if operation can be done
    $user_feedback = $feedback;
    if (!is_null($children) && sizeof($children) > 0 && sizeof($testsuites)) {
        $op_ok = true;
    } else {
        $children = null;
        $op_ok = false;
        $user_feedback = lang_get('no_testcases_available_or_tsuite');
    }
    $gui = new stdClass();
    $gui->treeFormToken = $gui->form_token = $argsObj->treeFormToken;
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $gui->domainTCStatus = array(-1 => '') + $dummy['lbl'];
    $gui->domainTCImportance = array(-1 => '', HIGH => lang_get('high_importance'), MEDIUM => lang_get('medium_importance'), LOW => lang_get('low_importance'));
    $gui->testCasesTableView = 0;
    if ($argsObj->action == 'testcases_table_view' || $argsObj->action == 'doBulkSet') {
        $gui->testCasesTableView = 1;
    }
    $smartyObj->assign('gui', $gui);
    $smartyObj->assign('op_ok', $op_ok);
    $smartyObj->assign('user_feedback', $user_feedback);
    $smartyObj->assign('tcprefix', $tcasePrefix);
    $smartyObj->assign('testcases', $children);
    $smartyObj->assign('old_containerID', $argsObj->tprojectID);
    //<<<<-- check if is needed
    $smartyObj->assign('containers', $testsuites);
    $smartyObj->assign('objectID', $containerID);
    $smartyObj->assign('object_name', $containerName);
    $smartyObj->assign('top_checked', 'checked=checked');
    $smartyObj->assign('bottom_checked', '');
}
Exemplo n.º 6
0
function init_args(&$cfgObj, $otName, &$tcaseMgr)
{
    $tc_importance_default = config_get('testcase_importance_default');
    $args = new stdClass();
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $rightlist_html_name = $otName . "_newRight";
    $args->assigned_keywords_list = isset($_REQUEST[$rightlist_html_name]) ? $_REQUEST[$rightlist_html_name] : "";
    $args->container_id = isset($_REQUEST['containerID']) ? intval($_REQUEST['containerID']) : 0;
    $args->file_id = isset($_REQUEST['file_id']) ? intval($_REQUEST['file_id']) : 0;
    $args->tcase_id = isset($_REQUEST['testcase_id']) ? intval($_REQUEST['testcase_id']) : 0;
    if ($args->tcase_id == 0) {
        $args->tcase_id = isset($_REQUEST['tcase_id']) ? intval($_REQUEST['tcase_id']) : 0;
    }
    if ($args->tcase_id == 0) {
        $args->tcase_id = intval(isset($_REQUEST['relation_source_tcase_id']) ? $_REQUEST['relation_source_tcase_id'] : 0);
    }
    echo '<xmp>';
    echo $_REQUEST['summary'];
    echo '</xmp>';
    $args->tcversion_id = isset($_REQUEST['tcversion_id']) ? intval($_REQUEST['tcversion_id']) : 0;
    $args->name = isset($_REQUEST['testcase_name']) ? $_REQUEST['testcase_name'] : null;
    // Normally Rich Web Editors
    $args->summary = isset($_REQUEST['summary']) ? $_REQUEST['summary'] : null;
    $args->preconditions = isset($_REQUEST['preconditions']) ? $_REQUEST['preconditions'] : null;
    $args->steps = isset($_REQUEST['steps']) ? $_REQUEST['steps'] : null;
    $args->expected_results = isset($_REQUEST['expected_results']) ? $_REQUEST['expected_results'] : null;
    $args->new_container_id = isset($_REQUEST['new_container']) ? intval($_REQUEST['new_container']) : 0;
    $args->old_container_id = isset($_REQUEST['old_container']) ? intval($_REQUEST['old_container']) : 0;
    $args->has_been_executed = isset($_REQUEST['has_been_executed']) ? intval($_REQUEST['has_been_executed']) : 0;
    $args->exec_type = isset($_REQUEST['exec_type']) ? $_REQUEST['exec_type'] : TESTCASE_EXECUTION_TYPE_MANUAL;
    $args->importance = isset($_REQUEST['importance']) ? $_REQUEST['importance'] : $tc_importance_default;
    $args->status = isset($_REQUEST['status']) ? $_REQUEST['status'] : 1;
    // sorry for the magic
    $args->estimatedExecDuration = isset($_REQUEST['estimated_execution_duration']) ? $_REQUEST['estimated_execution_duration'] : null;
    $args->doAction = isset($_REQUEST['doAction']) ? $_REQUEST['doAction'] : '';
    $key2loop = array('edit_tc' => 'edit', 'delete_tc' => 'delete', 'do_delete' => 'doDelete', 'create_tc' => 'create', 'do_create' => 'doCreate');
    foreach ($key2loop as $key => $action) {
        if (isset($_REQUEST[$key])) {
            $args->doAction = $action;
            break;
        }
    }
    $key2loop = array('move_copy_tc', 'delete_tc_version', 'do_move', 'do_copy', 'do_copy_ghost_zone', 'do_create_new_version', 'do_delete_tc_version');
    foreach ($key2loop as $key) {
        $args->{$key} = isset($_REQUEST[$key]) ? 1 : 0;
    }
    $args->do_activate_this = isset($_REQUEST['activate_this_tcversion']) ? 1 : 0;
    $args->do_deactivate_this = isset($_REQUEST['deactivate_this_tcversion']) ? 1 : 0;
    $args->target_position = isset($_REQUEST['target_position']) ? $_REQUEST['target_position'] : 'bottom';
    $key2loop = array("keyword_assignments", "requirement_assignments");
    foreach ($key2loop as $key) {
        $args->copy[$key] = isset($_REQUEST[$key]) ? true : false;
    }
    $args->show_mode = isset($_REQUEST['show_mode']) && $_REQUEST['show_mode'] != '' ? $_REQUEST['show_mode'] : null;
    // Multiple Test Case Steps Feature
    $args->step_number = isset($_REQUEST['step_number']) ? intval($_REQUEST['step_number']) : 0;
    $args->step_id = isset($_REQUEST['step_id']) ? intval($_REQUEST['step_id']) : 0;
    $args->step_set = isset($_REQUEST['step_set']) ? $_REQUEST['step_set'] : null;
    $args->tcaseSteps = isset($_REQUEST['tcaseSteps']) ? $_REQUEST['tcaseSteps'] : null;
    // from session
    $args->testproject_id = $args->tproject_id = intval($_SESSION['testprojectID']);
    $args->user_id = intval($_SESSION['userID']);
    $args->refreshTree = isset($_SESSION['setting_refresh_tree_on_action']) ? intval($_SESSION['setting_refresh_tree_on_action']) : 0;
    $args->opt_requirements = null;
    if (isset($_SESSION['testprojectOptions'])) {
        $args->opt_requirements = $_SESSION['testprojectOptions']->requirementsEnabled;
        $args->requirementsEnabled = $_SESSION['testprojectOptions']->requirementsEnabled;
    }
    $args->basehref = $_SESSION['basehref'];
    $args->goback_url = isset($_REQUEST['goback_url']) ? $_REQUEST['goback_url'] : null;
    // Specialized webEditorConfiguration
    $action2check = array("editStep" => true, "createStep" => true, "doCreateStep" => true, "doUpdateStep" => true, "doInsertStep" => true, "doCopyStep" => true, "doUpdateStepAndInsert" => true);
    if (isset($action2check[$args->doAction])) {
        $cfgObj->webEditorCfg = getWebEditorCfg('steps_design');
    }
    $args->stay_here = isset($_REQUEST['stay_here']) ? 1 : 0;
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $args->tcStatusCfg['status_code'] = $dummy['cfg'];
    $args->tcStatusCfg['code_label'] = $dummy['lbl'];
    $args->tc_status = isset($_REQUEST['tc_status']) ? intval($_REQUEST['tc_status']) : $args->tcStatusCfg['status_code']['draft'];
    $dk = 'estimated_execution_duration';
    $args->{$dk} = trim(isset($_REQUEST[$dk]) ? $_REQUEST[$dk] : '');
    $args->fileTitle = isset($_REQUEST['fileTitle']) ? $_REQUEST['fileTitle'] : "";
    $args->relation_type = isset($_REQUEST['relation_type']) ? $_REQUEST['relation_type'] : null;
    $args->relation_id = intval(isset($_REQUEST['relation_id']) ? $_REQUEST['relation_id'] : 0);
    $args->relation_destination_tcase = isset($_REQUEST['relation_destination_tcase']) ? $_REQUEST['relation_destination_tcase'] : null;
    $args->relation_destination_tcase = str_replace(' ', '', $args->relation_destination_tcase);
    $getOpt = array('tproject_id' => null, 'output' => 'map');
    if (is_numeric($args->relation_destination_tcase)) {
        $getOpt['tproject_id'] = $args->tproject_id;
    }
    $args->dummy = $tcaseMgr->getInternalID($args->relation_destination_tcase, $getOpt);
    $args->destination_tcase_id = $args->dummy['id'];
    $args->keyword_id = isset($_GET['keyword_id']) ? intval($_GET['keyword_id']) : 0;
    $args->tplan_id = isset($_REQUEST['tplan_id']) ? intval($_REQUEST['tplan_id']) : 0;
    $args->platform_id = isset($_REQUEST['platform_id']) ? intval($_REQUEST['platform_id']) : 0;
    // need to check if user has access rights to test project is project is private.
    $args->user = $_SESSION['currentUser'];
    return $args;
}
 /**
  *
  */
 function getTcSearchSkeleton($userInput = null)
 {
     $sk = new stdClass();
     $sk->creation_date_from = null;
     $sk->creation_date_to = null;
     $sk->modification_date_from = null;
     $sk->modification_date_to = null;
     $sk->search_important_notice = '';
     $sk->design_cf = '';
     $sk->keywords = '';
     $sk->filter_by['design_scope_custom_fields'] = false;
     $sk->filter_by['keyword'] = false;
     $sk->filter_by['requirement_doc_id'] = false;
     $sk->option_importance = array(0 => '', HIGH => lang_get('high_importance'), MEDIUM => lang_get('medium_importance'), LOW => lang_get('low_importance'));
     $dummy = getConfigAndLabels('testCaseStatus', 'code');
     $sk->domainTCStatus = array(0 => '') + $dummy['lbl'];
     $sk->importance = null;
     $sk->status = null;
     $sk->tcversion = null;
     $sk->tcasePrefix = '';
     $sk->targetTestCase = '';
     $txtin = array("created_by", "edited_by", "jolly");
     $jollyKilled = array("summary", "steps", "expected_results", "preconditions", "name");
     $txtin = array_merge($txtin, $jollyKilled);
     foreach ($txtin as $key) {
         $sk->{$key} = !is_null($userInput) ? $userInput->{$key} : '';
     }
     if (!is_null($userInput) && $userInput->jolly != '') {
         foreach ($jollyKilled as $key) {
             $sk->{$key} = '';
         }
     }
     return $sk;
 }
Exemplo n.º 8
0
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 $tcStatusConfig;
    if (!$tcData) {
        return;
    }
    // $tprojectHas = array('customFields' => false, 'reqSpec' => false);
    $hasCustomFieldsInfo = false;
    $hasRequirements = false;
    // init static data
    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);
        $messages['cf_warning'] = lang_get('no_cf_defined_can_not_import');
        $messages['reqspec_warning'] = lang_get('no_reqspec_defined_can_not_import');
        $messages['already_exists_updated'] = lang_get('already_exists_updated');
        $messages['original_name'] = lang_get('original_name');
        $messages['testcase_name_too_long'] = lang_get('testcase_name_too_long');
        $messages['start_warning'] = lang_get('start_warning');
        $messages['end_warning'] = lang_get('end_warning');
        $messages['testlink_warning'] = lang_get('testlink_warning');
        $messages['start_feedback'] = $messages['start_warning'] . "\n" . $messages['testlink_warning'] . "\n";
        $messages['create_new_version'] = lang_get('create_new_version');
        $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
        // $customFields=$tproject_mgr->get_linked_custom_fields($tproject_id,'testcase','name');
        // function get_linked_cfields_at_design($tproject_id,$enabled,$filters=null,
        //                                       $node_type=null,$node_id=null,$access_key='id')
        //
        $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');
        $tcStatusConfig = getConfigAndLabels('testCaseStatus');
    }
    $resultMap = array();
    $tc_qty = sizeof($tcData);
    // new dBug($tcData);
    //$xx=$tcase_mgr->getDuplicatesByExternalID(1,$container_id);
    //new dBug($xx);
    //die();
    //
    for ($idx = 0; $idx < $tc_qty; $idx++) {
        $tc = $tcData[$idx];
        $name = $tc['name'];
        $summary = $tc['summary'];
        $steps = $tc['steps'];
        $externalid = $tc['externalid'];
        $internalid = $tc['internalid'];
        $preconditions = $tc['preconditions'];
        $node_order = isset($tc['node_order']) ? intval($tc['node_order']) : testcase::DEFAULT_ORDER;
        $exec_type = isset($tc['execution_type']) ? $tc['execution_type'] : TESTCASE_EXECUTION_TYPE_MANUAL;
        $importance = isset($tc['importance']) ? $tc['importance'] : MEDIUM;
        $status = isset($tc['status']) ? $tc['status'] : null;
        // $tcStatusConfig['cfg']['draft'];
        $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']));
        }
        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[$internalid] = $dummy;
                }
                break;
            case 'externalID':
                $info = $tcase_mgr->get_by_external($externalid, $container_id);
                break;
        }
        $doCreate = true;
        $doAnalisys = !is_null($info);
        $tcase_qty = $doAnalisys ? count($info) : 0;
        if ($doAnalisys) {
            $tcase_id = key($info);
            switch ($duplicatedLogic['actionOnHit']) {
                case 'update_last_version':
                    switch ($tcase_qty) {
                        case 1:
                            $doCreate = false;
                            $last_version = $tcase_mgr->get_last_version_info($tcase_id, $getVersionOpt);
                            $tcversion_id = $last_version['id'];
                            // 20110604 - franciscom
                            // missing optional argument $status
                            $ret = $tcase_mgr->update($tcase_id, $tcversion_id, $name, $summary, $preconditions, $steps, $userID, $kwIDs, $node_order, $exec_type, $importance, $status);
                            $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;
                    }
                    break;
                case 'create_new_version':
                    switch ($tcase_qty) {
                        case 1:
                            $doCreate = false;
                            $tcase_id = key($info);
                            $ret = $tcase_mgr->create_new_version($tcase_id, $userID);
                            $tcversion_id = $ret['id'];
                            $msg = sprintf($messages['create_new_version'], $ret['version']);
                            $ret = $tcase_mgr->update($tcase_id, $tcversion_id, $name, $summary, $preconditions, $steps, $userID, $kwIDs, $node_order, $exec_type, $importance, $status);
                            $ret['id'] = $tcase_id;
                            $ret['tcversion_id'] = $tcversion_id;
                            $resultMap[] = array($name, $msg);
                            break;
                        case 0:
                            $doCreate = true;
                            break;
                        default:
                            $doCreate = false;
                            break;
                    }
                    break;
                case 'generate_new':
                    // trick
                    // create() will create a new test case with new name/title when
                    // we ask it:
                    //  'check_duplicate_name' => testcase::CHECK_DUPLICATE_NAME,
                    // we will IGNORE name provided on XML when
                    if ($duplicatedLogic['hitCriteria'] != name) {
                        $name = $info[$tcase_id]['name'];
                    }
                    break;
            }
            // switch
        }
        // if doAnalisys
        if ($doCreate) {
            $createOptions = array('check_duplicate_name' => testcase::CHECK_DUPLICATE_NAME, 'action_on_duplicate_name' => $duplicatedLogic['actionOnHit']);
            if ($ret = $tcase_mgr->create($container_id, $name, $summary, $preconditions, $steps, $userID, $kwIDs, $node_order, testcase::AUTOMATIC_ID, $exec_type, $importance, $status, $createOptions)) {
                $resultMap[] = array($name, $ret['msg']);
            }
        }
        // Custom Fields Management
        // Check if CF with this name and that can be used on Test Cases is defined in current Test Project.
        // If Check fails => give message to user.
        // Else Import CF data
        //
        $hasCustomFieldsInfo = isset($tc['customfields']) && !is_null($tc['customfields']);
        if ($hasCustomFieldsInfo) {
            if ($tprojectHas['customFields']) {
                $msg = processCustomFields($tcase_mgr, $name, $ret['id'], $ret['tcversion_id'], $tc['customfields'], $linkedCustomFields, $feedbackMsg);
                if (!is_null($msg)) {
                    $resultMap = array_merge($resultMap, $msg);
                }
            } else {
                // Can not import Custom Fields Values, give feedback
                $msg[] = array($name, $messages['cf_warning']);
                $resultMap = array_merge($resultMap, $msg);
            }
        }
        // Requirements Management
        // Check if Requirement ...
        // If Check fails => give message to user.
        // Else Import
        //
        $hasRequirements = isset($tc['requirements']) && !is_null($tc['requirements']);
        if ($hasRequirements) {
            if ($tprojectHas['reqSpec']) {
                $msg = processRequirements($db, $req_mgr, $name, $ret['id'], $tc['requirements'], $reqSpecSet, $feedbackMsg);
                if (!is_null($msg)) {
                    $resultMap = array_merge($resultMap, $msg);
                }
            } else {
                $msg[] = array($name, $messages['reqspec_warning']);
                $resultMap = array_merge($resultMap, $msg);
            }
        }
    }
    return $resultMap;
}
Exemplo n.º 9
0
 private function initShowGui($guiObj, $grantsObj)
 {
     $goo = is_null($guiObj) ? new stdClass() : $guiObj;
     $goo->execution_types = $this->execution_types;
     $goo->view_req_rights = $grantsObj->mgt_view_req;
     $goo->parentTestSuiteName = '';
     $goo->tprojectName = '';
     $goo->submitCode = "";
     $goo->dialogName = '';
     $goo->bodyOnLoad = "";
     $goo->bodyOnUnload = "storeWindowSize('TCEditPopup')";
     $goo->tableColspan = 5;
     // sorry magic related to table to display steps
     $goo->opt_requirements = false;
     $goo->tc_current_version = array();
     $goo->status_quo = array();
     $goo->keywords_map = array();
     $goo->arrReqs = array();
     $goo->cf_current_version = null;
     $goo->cf_other_versions = null;
     $goo->linked_versions = null;
     $goo->platforms = null;
     $goo->tcase_cfg = $this->cfg->testcase;
     $viewer_defaults = array('title' => lang_get('title_test_case'), 'show_title' => 'no', 'action' => '', 'msg_result' => '', 'user_feedback' => '', 'refreshTree' => 1, 'disable_edit' => 0, 'display_testproject' => 0, 'display_parent_testsuite' => 0, 'hilite_testcase_name' => 0, 'show_match_count' => 0);
     $viewer_defaults = array_merge($viewer_defaults, (array) $guiObj->viewerArgs);
     $goo->display_testproject = $viewer_defaults['display_testproject'];
     $goo->display_parent_testsuite = $viewer_defaults['display_parent_testsuite'];
     $goo->show_title = $viewer_defaults['show_title'];
     $goo->hilite_testcase_name = $viewer_defaults['hilite_testcase_name'];
     $goo->action = $viewer_defaults['action'];
     $goo->user_feedback = $viewer_defaults['user_feedback'];
     $goo->pageTitle = $viewer_defaults['title'];
     $goo->display_testcase_path = !is_null($goo->path_info);
     $goo->show_match_count = $viewer_defaults['show_match_count'];
     if ($goo->show_match_count && $goo->display_testcase_path) {
         $goo->pageTitle .= '-' . lang_get('match_count') . ':' . ($goo->match_count = count($goo->path_info));
     }
     $goo->refreshTree = isset($goo->refreshTree) ? $goo->refreshTree : $viewer_defaults['refreshTree'];
     $goo->sqlResult = $viewer_defaults['msg_result'];
     // fine grain control of operations
     if ($viewer_defaults['disable_edit'] == 1 || $grantsObj->mgt_modify_tc == false) {
         $goo->show_mode = 'editDisabled';
     } else {
         if (!is_null($goo->show_mode) && $goo->show_mode == 'editOnExec') {
             // refers to two javascript functions present in testlink_library.js
             // and logic used to refresh both frames when user call this
             // method to edit a test case while executing it.
             $goo->dialogName = 'tcview_dialog';
             $goo->bodyOnLoad = "dialog_onLoad({$gui->dialogName})";
             $goo->bodyOnUnload = "dialog_onUnload({$gui->dialogName})";
             $goo->submitCode = "return dialog_onSubmit({$gui->dialogName})";
         }
     }
     $dummy = getConfigAndLabels('testCaseStatus', 'code');
     $goo->domainTCStatus = $dummy['lbl'];
     $goo->can_do = $this->getShowViewerActions($goo->show_mode);
     return $goo;
 }
Exemplo n.º 10
0
/**
 * 
 *
 */
function initializeGui(&$argsObj, &$tprojectMgr)
{
    $gui = new stdClass();
    $gui->pageTitle = lang_get('caption_search_form');
    $gui->warning_msg = '';
    $gui->path_info = null;
    $gui->resultSet = null;
    $gui->tableSet = null;
    $gui->bodyOnLoad = null;
    $gui->bodyOnUnload = null;
    $gui->refresh_tree = false;
    $gui->hilite_testcase_name = false;
    $gui->show_match_count = false;
    $gui->row_qty = 0;
    $gui->doSearch = $argsObj->doAction == 'doSearch';
    $gui->tproject_id = intval($argsObj->tprojectID);
    // ----------------------------------------------------
    $gui->mainCaption = lang_get('testproject') . " " . $argsObj->tprojectName;
    $gui->creation_date_from = null;
    $gui->creation_date_to = null;
    $gui->modification_date_from = null;
    $gui->modification_date_to = null;
    $gui->search_important_notice = sprintf(lang_get('search_important_notice'), $argsObj->tprojectName);
    $gui->design_cf = $tprojectMgr->cfield_mgr->get_linked_cfields_at_design($argsObj->tprojectID, cfield_mgr::ENABLED, null, 'testcase');
    $gui->keywords = $tprojectMgr->getKeywords($argsObj->tprojectID);
    $gui->filter_by['design_scope_custom_fields'] = !is_null($gui->design_cf);
    $gui->filter_by['keyword'] = !is_null($gui->keywords);
    $reqSpecSet = $tprojectMgr->genComboReqSpec($argsObj->tprojectID);
    $gui->filter_by['requirement_doc_id'] = !is_null($reqSpecSet);
    $gui->option_importance = array(0 => '', HIGH => lang_get('high_importance'), MEDIUM => lang_get('medium_importance'), LOW => lang_get('low_importance'));
    $dummy = getConfigAndLabels('testCaseStatus', 'code');
    $gui->domainTCStatus = array(0 => '') + $dummy['lbl'];
    // need to set values that where used on latest search (if any was done)
    // $gui->importance = config_get('testcase_importance_default');
    $gui->importance = intval($argsObj->importance);
    $gui->status = intval($argsObj->status);
    $gui->tcversion = is_null($argsObj->version) || $argsObj->version == '' ? '' : intval($argsObj->version);
    $gui->tcasePrefix = $tprojectMgr->getTestCasePrefix($argsObj->tprojectID) . config_get('testcase_cfg')->glue_character;
    $gui->targetTestCase = is_null($argsObj->targetTestCase) || $argsObj->targetTestCase == '' ? $gui->tcasePrefix : $argsObj->targetTestCase;
    $txtin = array("created_by", "edited_by", "jolly");
    $jollyKilled = array("summary", "steps", "expected_results", "preconditions", "name");
    $txtin = array_merge($txtin, $jollyKilled);
    foreach ($txtin as $key) {
        $gui->{$key} = $argsObj->{$key};
    }
    if ($argsObj->jolly != '') {
        foreach ($jollyKilled as $key) {
            $gui->{$key} = '';
        }
    }
    return $gui;
}
 /**
  * 
  *
  */
 function create(&$argsObj, $oWebEditorKeys, $userInput)
 {
     $guiObj = $this->initGuiBean($argsObj);
     $guiObj->initWebEditorFromTemplate = true;
     $info = $this->tcaseMgr->tree_manager->get_node_hierarchy_info($guiObj->tsuiteID);
     $guiObj->tsuite = array('name' => $info['name']);
     $guiObj->main_descr = lang_get('testsuite') . $this->sep_1 . $info['name'] . $this->sep_2 . lang_get('title_new_tc');
     $tcStatusConfig = getConfigAndLabels('testCaseStatus');
     $guiObj->tc = array('id' => 0, 'name' => '', 'importance' => config_get('testcase_importance_default'), 'execution_type' => testcase::EXECUTION_TYPE_MANUAL, 'estimated_execution_duration' => '', 'status' => $tcStatusConfig['cfg']['draft']);
     list($guiObj->optionTransfer, $guiObj->optionTransferJSObject) = $this->initKeywordGuiControl($argsObj, $userInput);
     $cfPlaces = $this->tcaseMgr->buildCFLocationMap();
     foreach ($cfPlaces as $locationKey => $locationFilter) {
         // custom fields do not lose entered values on errors
         $guiObj->cf[$locationKey] = $this->tcaseMgr->html_table_of_custom_field_inputs(null, null, 'design', '', null, null, $argsObj->tproject_id, $locationFilter, $_REQUEST);
     }
     $templateCfg = templateConfiguration('tcNew');
     $guiObj->template = $templateCfg->default_template;
     new dBug($guiObj);
     return $guiObj;
 }