/** * * */ function initialize_gui(&$dbHandler, $argsObj) { $tproject_mgr = new testproject($dbHandler); $req_mgr = new requirement_mgr($dbHandler); $commandMgr = new reqCommands($db); $gui = $commandMgr->initGuiBean(); $gui->req_cfg = config_get('req_cfg'); $gui->tproject_name = $argsObj->tproject_name; $gui->grants = new stdClass(); $gui->grants->req_mgmt = has_rights($db, "mgt_modify_req"); $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id); $gui->glueChar = config_get('testcase_cfg')->glue_character; $gui->pieceSep = config_get('gui_title_separator_1'); $gui->req_id = $argsObj->req_id; $gui->req_versions = $req_mgr->get_by_id($gui->req_id); $gui->req = current($gui->req_versions); $gui->req_coverage = $req_mgr->get_coverage($gui->req_id); // This seems weird but is done to adapt template than can display multiple // requirements. This logic has been borrowed from test case versions management $gui->current_version[0] = array($gui->req); // BUGID 2877 - Custom Fields linked to Requirement Versions $gui->cfields_current_version[0] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $gui->req['version_id'], $argsObj->tproject_id); // Now CF for other Versions $gui->other_versions[0] = null; $gui->cfields_other_versions[] = null; if (count($gui->req_versions) > 1) { $gui->other_versions[0] = array_slice($gui->req_versions, 1); $loop2do = count($gui->other_versions[0]); for ($qdx = 0; $qdx < $loop2do; $qdx++) { $target_version = $gui->other_versions[0][$qdx]['version_id']; $gui->cfields_other_versions[0][$qdx] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $target_version, $argsObj->tproject_id); } } $gui->show_title = false; $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->req['title']; $gui->showReqSpecTitle = $argsObj->showReqSpecTitle; if ($gui->showReqSpecTitle) { $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->req['req_spec_title']; } // BUGID 2877 - Custom Fields linked to Requirement Versions // $gui->cfields = array(); // $gui->cfields[] = $req_mgr->html_table_of_custom_field_values($gui->req_id,$argsObj->tproject_id); $gui->attachments[$gui->req_id] = getAttachmentInfosFrom($req_mgr, $gui->req_id); $gui->attachmentTableName = $req_mgr->getAttachmentTableName(); $gui->reqStatus = init_labels($gui->req_cfg->status_labels); $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels); // added req relations for BUGID 1748 $gui->req_relations = FALSE; $gui->req_relation_select = FALSE; $gui->testproject_select = FALSE; $gui->req_add_result_msg = isset($argsObj->relation_add_result_msg) ? $argsObj->relation_add_result_msg : ""; if ($gui->req_cfg->relations->enable) { $gui->req_relations = $req_mgr->get_relations($gui->req_id); $gui->req_relation_select = $req_mgr->init_relation_type_select(); if ($gui->req_cfg->relations->interproject_linking) { $gui->testproject_select = initTestprojectSelect($db, $argsObj, $tproject_mgr); } } return $gui; }
/** * * */ function initialize_gui(&$dbHandler, $argsObj) { $tproject_mgr = new testproject($dbHandler); $req_mgr = new requirement_mgr($dbHandler); $commandMgr = new reqCommands($dbHandler); $gui = $commandMgr->initGuiBean(); $gui->req_cfg = config_get('req_cfg'); $gui->tproject_name = $argsObj->tproject_name; $gui->grants = new stdClass(); $gui->grants->req_mgmt = has_rights($dbHandler, "mgt_modify_req"); $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id); $gui->glueChar = config_get('testcase_cfg')->glue_character; $gui->pieceSep = config_get('gui_title_separator_1'); $gui->item_id = $argsObj->item_id; // identify item is version or revision ? $node_type_id = $req_mgr->tree_mgr->get_available_node_types(); $node_id_type = array_flip($node_type_id); $item = $req_mgr->tree_mgr->get_node_hierarchy_info($gui->item_id); // TICKET 4702 // target_is is db id of item, item['id'] is the REQ ID. // for several logics we need to DB id (target_id) $info = null; switch ($node_id_type[$item['node_type_id']]) { case 'requirement_version': $info = $req_mgr->get_version($gui->item_id); $info['revision_id'] = -1; $info['target_id'] = $info['version_id']; break; case 'requirement_revision': $info = $req_mgr->get_revision($gui->item_id); $info['target_id'] = $info['revision_id']; break; } $gui->item = $info; $gui->cfields = $req_mgr->html_table_of_custom_field_values(null, $gui->item_id, $argsObj->tproject_id); $gui->show_title = false; $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->item['title']; $gui->showReqSpecTitle = $argsObj->showReqSpecTitle; if ($gui->showReqSpecTitle) { $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->item['req_spec_title']; } $gui->reqStatus = init_labels($gui->req_cfg->status_labels); $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels); return $gui; }
* * Compares selected requirements versions with each other. * * @internal Revisions: * 20100831 - Julian - added requirement title to page heading */ require_once "../../config.inc.php"; require_once "common.php"; require '../../third_party/diff/diff.php'; $templateCfg = templateConfiguration(); testlinkInitPage($db); $smarty = new TLSmarty(); $differ = new diff(); $args = init_args(); $gui = new stdClass(); $reqMgr = new requirement_mgr($db); $reqSet = $reqMgr->get_by_id($args->req_id); $gui->req_versions = $reqSet; $gui->req_id = $args->req_id; $gui->compare_selected_versions = $args->compare_selected_versions; $gui->context = $args->context; $gui->version_short = lang_get('version_short'); $labels = array(); $labels["num_changes"] = lang_get("num_changes"); $labels["no_changes"] = lang_get("no_changes"); //if already two versions are selected, display diff //else display template with versions to select if ($args->compare_selected_versions) { $diff_array = array("scope" => array()); foreach ($reqSet as $req) { if ($req['version'] == $args->version_left) {
/** * * */ function initialize_gui(&$dbHandler, $argsObj, &$tproject_mgr) { $req_mgr = new requirement_mgr($dbHandler); $commandMgr = new reqCommands($dbHandler); $gui = $commandMgr->initGuiBean(); $gui->req_cfg = config_get('req_cfg'); $gui->glueChar = config_get('testcase_cfg')->glue_character; $gui->pieceSep = config_get('gui_title_separator_1'); $gui->refreshTree = $argsObj->refreshTree; $gui->tproject_name = $argsObj->tproject_name; $gui->req_id = $argsObj->req_id; /* if wanted, show only the given version */ $gui->version_option = $argsObj->req_version_id ? $argsObj->req_version_id : requirement_mgr::ALL_VERSIONS; $gui->req_versions = $req_mgr->get_by_id($gui->req_id, $gui->version_option, 1, array('renderImageInline' => true)); $gui->reqHasBeenDeleted = false; if (is_null($gui->req_versions)) { // this means that requirement does not exist anymore. // We have to give just that info to user $gui->reqHasBeenDeleted = true; $gui->main_descr = lang_get('req_does_not_exist'); unset($gui->show_match_count); return $gui; // >>>----> Bye! } $tproject_id = $req_mgr->getTestProjectID($argsObj->requirement_id); $target_id = $argsObj->tproject_id; if ($isAlien = $tproject_id != $argsObj->tproject_id) { $target_id = $tproject_id; } $gui->grants = new stdClass(); $gui->grants->req_mgmt = $argsObj->user->hasRight($dbHandler, "mgt_modify_req", $target_id); $gui->grants->unfreeze_req = $argsObj->user->hasRight($dbHandler, "mgt_unfreeze_req", $target_id); $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id); $gui->req = current($gui->req_versions); $gui->req_coverage = $req_mgr->get_coverage($gui->req_id); $gui->direct_link = $_SESSION['basehref'] . 'linkto.php?tprojectPrefix=' . urlencode($gui->tcasePrefix) . '&item=req&id=' . urlencode($gui->req['req_doc_id']); $gui->fileUploadURL = $_SESSION['basehref'] . $req_mgr->getFileUploadRelativeURL($gui->req_id, $argsObj); $gui->delAttachmentURL = $_SESSION['basehref'] . $req_mgr->getDeleteAttachmentRelativeURL($gui->req_id); $gui->fileUploadMsg = ''; $gui->import_limit = TL_REPOSITORY_MAXFILESIZE; $gui->log_target = null; $loop2do = count($gui->req_versions); for ($rqx = 0; $rqx < $loop2do; $rqx++) { $gui->log_target[] = $gui->req_versions[$rqx]['revision_id'] > 0 ? $gui->req_versions[$rqx]['revision_id'] : $gui->req_versions[$rqx]['version_id']; } $gui->req_has_history = count($req_mgr->get_history($gui->req_id, array('output' => 'array'))) > 1; // This seems weird but is done to adapt template than can display multiple // requirements. This logic has been borrowed from test case versions management $gui->current_version[0] = array($gui->req); $gui->cfields_current_version[0] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $gui->req['version_id'], $argsObj->tproject_id); // Now CF for other Versions $gui->other_versions[0] = null; $gui->cfields_other_versions[] = null; if (count($gui->req_versions) > 1) { $gui->other_versions[0] = array_slice($gui->req_versions, 1); $loop2do = count($gui->other_versions[0]); for ($qdx = 0; $qdx < $loop2do; $qdx++) { $target_version = $gui->other_versions[0][$qdx]['version_id']; $gui->cfields_other_versions[0][$qdx] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $target_version, $argsObj->tproject_id); } } $gui->show_title = false; $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->req['title']; $gui->showReqSpecTitle = $argsObj->showReqSpecTitle; if ($gui->showReqSpecTitle) { $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->req['req_spec_title']; } $gui->attachments[$gui->req_id] = getAttachmentInfosFrom($req_mgr, $gui->req_id); $gui->attachmentTableName = $req_mgr->getAttachmentTableName(); $gui->reqStatus = init_labels($gui->req_cfg->status_labels); $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels); $gui->req_relations = FALSE; $gui->req_relation_select = FALSE; $gui->testproject_select = FALSE; $gui->req_add_result_msg = isset($argsObj->relation_add_result_msg) ? $argsObj->relation_add_result_msg : ""; if ($gui->req_cfg->relations->enable) { $gui->req_relations = $req_mgr->get_relations($gui->req_id); $gui->req_relations['rw'] = !$isAlien; $gui->req_relation_select = $req_mgr->init_relation_type_select(); if ($gui->req_cfg->relations->interproject_linking) { $gui->testproject_select = initTestprojectSelect($argsObj->userID, $argsObj->tproject_id, $tproject_mgr); } } $gui->user_feedback = $argsObj->user_feedback; return $gui; }
function copy_to($id, $parent_id, $tproject_id, $user_id, $options = null) { $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; $op = array('status_ok' => 1, 'msg' => 'ok', 'id' => -1, 'mappings' => null); $my['options'] = array('copy_also' => null); $my['options'] = array_merge($my['options'], (array) $options); $field_size = config_get('field_size'); $item_info = $this->get_by_id($id); $target_doc = $this->generateDocID($id, $tproject_id); $new_item = $this->create($tproject_id, $parent_id, $target_doc, $item_info['title'], $item_info['scope'], $item_info['total_req'], $item_info['author_id'], $item_info['type'], $item_info['node_order']); $op = $new_item; if ($new_item['status_ok']) { $op['mappings'][$id] = $new_item['id']; $this->copy_cfields($id, $new_item['id']); // Now loop to copy all items inside it $my['filters'] = null; $subtree = $this->tree_mgr->get_subtree($id, $my['filters']); if (!is_null($subtree)) { $reqMgr = new requirement_mgr($this->db); $parent_decode = array(); $parent_decode[$id] = $new_item['id']; foreach ($subtree as $the_key => $elem) { // 20100311 - franciscom $the_parent_id = isset($parent_decode[$elem['parent_id']]) ? $parent_decode[$elem['parent_id']] : null; switch ($elem['node_type_id']) { case $this->node_types_descr_id['requirement']: $ret = $reqMgr->copy_to($elem['id'], $the_parent_id, $user_id, $tproject_id, $my['options']['copy_also']); $op['status_ok'] = $ret['status_ok']; $op['mappings'] += $ret['mappings']; break; case $this->node_types_descr_id['requirement_spec']: $item_info = $this->get_by_id($elem['id']); $target_doc = $this->generateDocID($elem['id'], $tproject_id); $ret = $this->create($tproject_id, $the_parent_id, $target_doc, $item_info['title'], $item_info['scope'], $item_info['total_req'], $item_info['author_id'], $item_info['type'], $item_info['node_order']); $parent_decode[$elem['id']] = $ret['id']; $op['mappings'][$elem['id']] = $ret['id']; if ($op['status_ok'] = $ret['status_ok']) { $this->copy_cfields($elem['id'], $ret['id']); } break; } if ($op['status_ok'] == 0) { break; } } } } return $op; }
* @author Martin Havlat * * * internal revisions * @since 1.9.11 */ require_once "../../config.inc.php"; require_once "common.php"; require_once 'requirements.inc.php'; require_once 'exttable.class.php'; testlinkInitPage($db, false, false, "checkRights"); $templateCfg = templateConfiguration(); $smarty = new TLSmarty(); $tproject_mgr = new testproject($db); $tplan_mgr = new testplan($db); $req_mgr = new requirement_mgr($db); $req_spec_mgr = new requirement_spec_mgr($db); $title_sep = config_get('gui_title_separator_1'); $charset = config_get('charset'); $req_cfg = config_get('req_cfg'); list($req_spec_type_labels, $req_type_labels, $status_labels, $labels) = setUpLabels($req_cfg); list($results_cfg, $status_code_map, $code_status_map, $eval_status_map) = setUpReqStatusCfg(); $args = init_args($tproject_mgr, $tplan_mgr, $req_cfg); $images = $smarty->getImages(); $gui = init_gui($args, $tplan_mgr); $i2u = array('edit_icon', 'exec_icon', 'history_small'); foreach ($i2u as $ik) { $images[$ik] = $gui->baseHref . $images[$ik]; } $reqContext = array('tproject_id' => $args->tproject_id, 'tplan_id' => $args->tplan_id, 'platform_id' => $args->platform); $reqSetX = (array) $req_mgr->getAllByContext($reqContext);
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions * 20121017 - asimon - TICKET 5288 - print priority when printing test plan */ function renderTestCaseForPrinting(&$db, &$node, &$options, $level, $context) { static $req_mgr; static $tc_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; static $force = null; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; // init static elements // tplan_id = 0, // $prefix = null, $tprojectID = 0, $platform_id = 0) if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr); if (!is_null($context->prefix)) { $tcase_prefix = $context->prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; } $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); $versionID = isset($node['tcversion_id']) ? intval($node['tcversion_id']) : testcase::LATEST_VERSION; $tcInfo = $tc_mgr->get_by_id($id, $versionID); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); // ----- BUGID 3451 and related --------------------------------------- // asimon: I finally found the real problem here: // $versionID was used in the following "dirty" SQL statement, but was still set to "-1" //(the value to load all tc versions) instead of a real testcase version ID. $versionID = $tcInfo['id']; // This still does not change the fact that this marked SQL statement below // should be removed and replaced by existing functions. $cfields = array('specScope' => null, 'execScope' => null); // get custom fields that has specification scope if ($options['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } foreach ($locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $context->tplan_id, $context->tproject_id, $cfieldFormatting, $tcInfo['id']); } } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getExecutions = false; if ($options["docType"] != DOC_TEST_SPEC && $options["docType"] != SINGLE_TESTCASE) { $getExecutions = $options['cfields'] || $options['passfail']; } if ($getExecutions) { $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON E.build_id= B.id " . " WHERE E.tcversion_id = {$versionID} " . " AND E.testplan_id = {$context->tplan_id} " . " AND E.platform_id = {$context->platform_id} " . " ORDER BY execution_id DESC"; echo $sql; $exec_info = $db->get_recordset($sql, null, 1); } // Added condition for the display on/off of the custom fields on test cases. if ($options['cfields'] && !is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $context->tplan_id, $context->tproject_id, $cfieldFormatting); } if ($options['toc']) { $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $table_style = 'style="margin-left: 0;"'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td></tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>' . '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; switch ($tcInfo['execution_type']) { case testcase::EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case testcase::EXECUTION_TYPE_MANUAL: $code .= $labels['execution_type_manual']; break; default: $code .= lang_get('execution_type_custom_' . $tcInfo['execution_type']); break; } $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['status'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['text_status_labels'][$tcInfo['status']]; $code .= "</td></tr>\n"; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_execution_duration']; $code .= "</td></tr>\n"; // TICKET 5288 - print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($options['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes']); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC if ($options['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $code .= "</table>\n</div>\n"; return $code; }
/** * * */ function doBulkAssignment(&$dbHandler, &$argsObj, $targetTestCaseSet = null) { $req_mgr = new requirement_mgr($dbHandler); $assignmentCounter = 0; $requirements = array_keys($argsObj->reqIdSet); if (!is_null($requirements) && count($requirements) > 0) { $tcase_set = $targetTestCaseSet; if (is_null($tcase_set)) { $tsuite_mgr = new testsuite($dbHandler); $tcase_set = $tsuite_mgr->get_testcases_deep($argsObj->id, 'only_id'); } if (!is_null($tcase_set) && count($tcase_set)) { $assignmentCounter = $req_mgr->bulk_assignment($requirements, $tcase_set); } } return $assignmentCounter; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions * 20100920 - franciscom - changed key on $cfieldFormatting * 20100905 - franciscom - BUGID 3431 - Custom Field values at Test Case VERSION Level * 20100724 - asimon - BUGID 3459 - added platform ID * 20100723 - asimon - BUGID 3451 and related finally solved * 20090517 - havlatm - fixed execution layot; added tester name * 20080819 - franciscom - removed mysql only code * 20071014 - franciscom - display test case version * 20070509 - franciscom - added Contribution */ function renderTestCaseForPrinting(&$db, &$node, &$printingOptions, $level, $tplan_id = 0, $prefix = null, $tprojectID = 0, $platform_id = 0) { static $req_mgr; static $tc_mgr; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); } $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; // init static elements $id = $node['id']; if (!$cfg) { $tc_mgr = new testcase($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; } // 20100920 - franciscom $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); $versionID = isset($node['tcversion_id']) ? $node['tcversion_id'] : testcase::LATEST_VERSION; $tcInfo = $tc_mgr->get_by_id($id, $versionID); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); // ----- BUGID 3451 and related --------------------------------------- // asimon: I finally found the real problem here: // $versionID was used in the following "dirty" SQL statement, but was still set to "-1" //(the value to load all tc versions) instead of a real testcase version ID. $versionID = $tcInfo['id']; // This still does not change the fact that this marked SQL statement below // should be removed and replaced by existing functions. // ----- BUGID 3451 and related --------------------------------------- $cfields = array('specScope' => null, 'execScope' => null); // get custom fields that has specification scope if ($printingOptions['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } foreach ($locationFilters as $fkey => $fvalue) { // BUGID 3431 - Custom Field values at Test Case VERSION Level $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $cfieldFormatting, $tcInfo['id']); } } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $bGetExecutions = false; if ($printingOptions["docType"] != DOC_TEST_SPEC) { $bGetExecutions = $printingOptions['cfields'] || $printingOptions['passfail']; } if ($bGetExecutions) { $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id,E.has_attach," . " B.name AS build_name " . " FROM {$tables['executions']} E, {$tables['builds']} B" . " WHERE E.build_id= B.id " . " AND E.tcversion_id = {$versionID} " . " AND E.testplan_id = {$tplan_id} " . " AND E.platform_id = {$platform_id} " . " ORDER BY execution_id DESC"; $exec_info = $db->get_recordset($sql, null, 1); } // Added condition for the display on/off of the custom fields on test cases. if ($printingOptions['cfields'] && !is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $tplan_id, $tprojectID, $cfieldFormatting); } if ($printingOptions['toc']) { if ($printingOptions['passfail']) { if ($exec_info) { //<span style="color:green">different text color</span> switch ($exec_info[0]['status']) { case "p": $result_of_case .= '<span style="color:green">' . $cfg['status_labels'][$exec_info[0]['status']] . '</span>'; break; case "f": $result_of_case .= '<span style="color:red">' . $cfg['status_labels'][$exec_info[0]['status']] . '</span>'; break; default: $result_of_case .= $cfg['status_labels'][$exec_info[0]['status']]; break; } } else { $result_of_case .= "<b>Not Run</b>"; } } $printingOptions['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . $name . '</a> ' . $result_of_case . '</p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $code .= '<p> </p><div> <table class="tc" width="90%">'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; if ($cfg['doc']->tc_version_enabled) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($printingOptions['author']) { $authorName = gendocGetUserName($db, $tcInfo['author_id']); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $authorName; if ($tcInfo['updater_id'] > 0 && $tcInfo['updater_id'] != $tcInfo['author_id']) { // add updater if available and differs from author $updaterName = gendocGetUserName($db, $tcInfo['updater_id']); $code .= '<br />' . $labels['last_edit'] . " " . $updaterName; } $code .= "</td></tr>\n"; } if ($printingOptions['body'] || $printingOptions['summary']) { $tcase_pieces = array('summary'); } if ($printingOptions['body']) { $tcase_pieces[] = 'preconditions'; $tcase_pieces[] = 'steps'; // $tcase_pieces[] = 'expected_results'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { // 20090719 - franciscom - cf location if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td></tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>' . '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; // 20090719 - franciscom - cf location $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($printingOptions['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC // based on contribution by JMU (#1045) if ($printingOptions['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC // based on contribution by JMU (#1045) if ($printingOptions['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $code .= "</table>\n</div>\n"; return $code; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions */ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context) { static $req_mgr; static $tc_mgr; static $build_mgr; static $tplan_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; static $force = null; static $bugInterfaceOn = false; static $its; static $buildCfields; static $statusL10N; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; $level = $context['level']; $prefix = isset($context['prefix']) ? $context['prefix'] : null; $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0; $build_id = isset($context['build_id']) ? $context['build_id'] : 0; // init static elements if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); $build_mgr = new build_mgr($db); $tplan_mgr = new testplan($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; $its = null; $tproject_mgr = new testproject($db); $info = $tproject_mgr->get_by_id($tprojectID); $bugInterfaceOn = $info['issue_tracker_enabled']; if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($db); $its = $it_mgr->getInterfaceObject($tprojectID); unset($it_mgr); } $statusL10N = null; foreach ($cfg['results']['code_status'] as $vc => $vstat) { if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) { $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]); } } } $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getExecutions = false; $getByID['filters'] = null; switch ($options["docType"]) { case DOC_TEST_SPEC: $getByID['tcversion_id'] = testcase::LATEST_VERSION; break; case SINGLE_TESTCASE: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status']; break; default: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status']; break; } if ($getExecutions) { // Thanks to Evelyn from Cortado, have found a very old issue never reported. // 1. create TC-1A VERSION 1 // 2. add to test plan and execute FAILED ON BUILD 1 // 3. Request Test Report (Test Plan EXECUTION REPORT). // You will get spec for VERSION 1 and result for VERSION 1 - OK cool! // 4. create VERSION 2 // 5. update linked Test Case Versions // 6. do nothing more than repeat step 3 // without this fix you will get // You will get spec for VERSION 2 and result for VERSION 1 - Hmmm // and in addition is not clear that execution was on VERSION 1 . No GOOD!! // // HOW has been fixed ? // Getting info about THE CURRENT LINKED test case version and looking for // exec info for this. // // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided // // // Get Linked test case version $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id); $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " B.name AS build_name,E.execution_duration " . " FROM {$tables['executions']} E, {$tables['builds']} B" . " WHERE E.build_id = B.id " . " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']); if ($build_id > 0) { $sql .= " AND E.build_id = " . intval($build_id); } else { // We are looking for LATEST EXECUTION of CURRENT LINKED test case version $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']); } $sql .= " ORDER BY execution_id DESC"; $exec_info = $db->get_recordset($sql, null, 1); $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id']; $getByID['filters'] = null; if (!is_null($exec_info)) { // $getByID['tcversion_id'] = null; $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']); if ($options['build_cfields']) { if (!isset($buildCfields[$exec_info[0]['build_id']])) { $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID); } } } } $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true)); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); $versionID = $tcInfo['id']; $cfields = array('specScope' => null, 'execScope' => null); if ($options['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } // Get custom fields that has specification scope // Custom Field values at Test Case VERSION Level foreach ($locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $cfieldFormatting, $tcInfo['id']); } if (!is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $tplan_id, $tprojectID, $cfieldFormatting); } } if ($options['toc']) { // EXTERNAL ID added $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } // change table style in case of single TC printing to not be indented $table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $table_style = 'style="margin-left: 0;"'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version switch ($env->reportType) { case DOC_TEST_PLAN_DESIGN: $version_number = $node['version']; break; case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $version_number = $tcInfo['version']; break; default: $version_number = $tcInfo['version']; break; } if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; } if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) { $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>'; if ($options['step_exec_notes'] || $options['step_exec_status']) { $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']); if ($options['step_exec_notes']) { $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>'; } if ($options['step_exec_status']) { $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>'; } } $code .= '</tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>'; if ($options['step_exec_notes']) { $code .= '<td>' . $sxni[$tcInfo[$key][$ydx]['id']]['notes'] . '</td>'; } if ($options['step_exec_status']) { $code .= '<td>' . $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']] . '</td>'; } $code .= '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; switch ($tcInfo['execution_type']) { case TESTCASE_EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case TESTCASE_EXECUTION_TYPE_MANUAL: default: $code .= $labels['execution_type_manual']; break; } $code .= "</td></tr>\n"; // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration']; $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($options['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $its, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes'], $buildCfields); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC if ($options['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } // Attachments $attachSet = (array) $tc_mgr->getAttachmentInfos($id); if (count($attachSet) > 0) { $code .= "<tr><td><span class=\"label\">" . $labels['attached_files'] . "</span></td><td><ul>"; foreach ($attachSet as $item) { $fname = ""; if ($item['title']) { $fname .= htmlspecialchars($item['title']) . " : "; } $fname .= htmlspecialchars($item['file_name']); $code .= "<li>{$fname}</li>"; if ($item['is_image']) { $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>'; } } $code .= "</ul></td></tr>"; } $code .= "</table>\n</div>\n"; return $code; }
/** * process_req * */ function process_req(&$dbHandler, $docID, $tprojectID, $tprojectPrefix) { $tables = tlObjectWithDB::getDBTables(array('requirements', 'nodes_hierarchy', 'req_specs', 'tcversions')); $ret = array(); $ret['url'] = null; $ret['msg'] = sprintf(lang_get('req_not_found'), $docID, $tprojectPrefix); $req_mgr = new requirement_mgr($dbHandler); $req = $req_mgr->getByDocID($docID, $tprojectID); if (!is_null($req)) { // link to open in requirement frame $req = current($req); $ret['url'] = "lib/requirements/reqView.php?item=requirement&requirement_id={$req['id']}"; $cookie = buildCookie($dbHandler, $req['id'], $tprojectID, 'ys-requirement_spec'); setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/'); } return $ret; }
/** * * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg, &$dbHandler) { $smartyObj = new TLSmarty(); $renderType = 'none'; // @TODO document $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'createTestCases' => 'doCreateTestCases', 'doCreateTestCases' => 'doCreateTestCases', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'doCreateVersion' => 'doCreateVersion', 'doCreateRevision' => 'doCreateRevision', 'doDeleteVersion' => '', 'doFreezeVersion' => 'doFreezeVersion', 'doAddRelation' => 'doAddRelation', 'doDeleteRelation' => 'doDeleteRelation'); $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: if ($opObj->suggest_revision || $opObj->prompt_for_log) { $owebEditor->Value = $argsObj->scope; } else { $owebEditor->Value = getItemTemplateContents('requirement_template', $owebEditor->InstanceName, $argsObj->scope); } break; } $guiObj->askForRevision = $opObj->suggest_revision ? 1 : 0; $guiObj->askForLog = $opObj->prompt_for_log ? 1 : 0; $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; switch ($argsObj->doAction) { case "doDelete": $guiObj->refreshTree = 1; // has to be forced break; case "doCreate": $guiObj->refreshTree = $argsObj->refreshTree; break; case "doUpdate": // IMPORTANT NOTICE // we do not set tree refresh here, because on this situation // tree update has to be done when reqView page is called. // If we ask for tree refresh here we are going to do double refresh (useless and time consuming) break; } switch ($argsObj->doAction) { case "edit": case "create": case "reorder": case "doDelete": case "doReorder": case "createTestCases": case "doCreateTestCases": case "doCreate": case "doFreezeVersion": case "doUpdate": case "copy": case "doCopy": case "doCreateVersion": case "doDeleteVersion": case "doAddRelation": case "doDeleteRelation": case "doCreateRevision": $renderType = 'template'; $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } // exceptions $guiObj->askForRevision = $opObj->suggest_revision ? 1 : 0; $guiObj->askForLog = $opObj->prompt_for_log ? 1 : 0; $guiObj->operation = $actionOperation[$argsObj->doAction]; $tplDir = !isset($opObj->template_dir) || is_null($opObj->template_dir) ? $templateCfg->template_dir : $opObj->template_dir; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tplDir . $tpl; } else { $renderType = 'redirect'; } break; } $req_mgr = new requirement_mgr($dbHandler); $guiObj->last_doc_id = $req_mgr->get_last_doc_id_for_testproject($argsObj->tproject_id); $guiObj->doAction = $argsObj->doAction; switch ($renderType) { case 'template': $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
/** * * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg, &$dbHandler) { $smartyObj = new TLSmarty(); $renderType = 'none'; // @TODO document $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'createTestCases' => 'doCreateTestCases', 'doCreateTestCases' => 'doCreateTestCases', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'doCreateVersion' => 'doCreateVersion', 'doDeleteVersion' => '', 'doFreezeVersion' => 'doFreezeVersion', 'doAddRelation' => 'doAddRelation', 'doDeleteRelation' => 'doDeleteRelation'); $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: $owebEditor->Value = getItemTemplateContents('requirement_template', $owebEditor->InstanceName, $argsObj->scope); break; } $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; // 20100808 - aismon - added logic to refresh filtered tree on action switch ($argsObj->doAction) { case "doDelete": case "doCreate": $guiObj->refreshTree = $argsObj->refreshTree; break; } switch ($argsObj->doAction) { case "edit": case "create": case "reorder": case "doDelete": case "doReorder": case "createTestCases": case "doCreateTestCases": case "doCreate": case "doFreezeVersion": case "doUpdate": case "copy": case "doCopy": case "doCreateVersion": case "doDeleteVersion": // BUGID 1748 // BUGID 1748 case "doAddRelation": case "doDeleteRelation": $renderType = 'template'; $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } $guiObj->operation = $actionOperation[$argsObj->doAction]; $tplDir = !isset($opObj->template_dir) || is_null($opObj->template_dir) ? $templateCfg->template_dir : $opObj->template_dir; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tplDir . $tpl; } else { $renderType = 'redirect'; } break; } $req_mgr = new requirement_mgr($dbHandler); $guiObj->last_doc_id = $req_mgr->get_last_doc_id_for_testproject($argsObj->tproject_id); $guiObj->doAction = $argsObj->doAction; switch ($renderType) { case 'template': $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
/** * doUploadFile * */ function doUploadFile(&$dbHandler, $fileName, $importScope, &$argsObj, &$reqSpecMgr) { $retval = new stdClass(); $retval->items = null; $retval->file_check = array('status_ok' => 1, 'msg' => 'ok'); $source = isset($_FILES['uploadedFile']['tmp_name']) ? $_FILES['uploadedFile']['tmp_name'] : null; if ($source != 'none' && $source != '') { if ($retval->file_check['status_ok']) { if (move_uploaded_file($source, $fileName)) { // Must be recoded - $file_check = check_syntax($gui->fileName,$args->importType); if ($retval->file_check['status_ok']) { if (strcasecmp($argsObj->importType, 'XML') == 0) { $retval->file_check['status_ok'] = !(($xml = simplexml_load_file($fileName)) === FALSE); if ($retval->file_check['status_ok']) { $retval->items = array(); // New simple check on file contents $isReqSpec = property_exists($xml, 'req_spec'); $fileFormatOK = $isReqSpec && $importScope != 'items' || !$isReqSpec && $importScope == 'items'; // if($isReqSpec) // // switch($importScope) // { // case 'branch': // case 'tree': // $fileFormatOK = property_exists($xml,'req_spec'); // break; // // case 'items': // // break; // // } // we can have two types of files: // 1. req. specs + requirements // 2. just requirements if ($isReqSpec) { foreach ($xml->req_spec as $xkm) { $retval->items = array_merge($retval->items, $reqSpecMgr->xmlToMapReqSpec($xkm)); } } else { $reqMgr = new requirement_mgr($dbHandler); $loop2do = count($xml->requirement); $items = null; for ($zdx = 0; $zdx <= $loop2do; $zdx++) { $xml_req = $reqMgr->xmlToMapRequirement($xml->requirement[$zdx]); if (!is_null($xml_req)) { $items[] = $xml_req; } } if ($loop2do > 0) { // IMPORTANT NOTICE // this keys must be same that returned by $reqSpecMgr->xmlToMapReqSpec // because are used at GUI to draw $retval->items[] = array('requirements' => $items, 'req_spec' => null, 'level' => 0); } } } else { $retval->file_check['msg'] = lang_get('xml_load_file_failed'); } } else { $retval->items = doReqImport($dbHandler, $argsObj->tproject_id, $argsObj->user_id, $argsObj->req_spec_id, $fileName, $argsObj->importType, $argsObj->emptyScope, $argsObj->conflictSolution, false); } } } } } else { $retval->file_check = array('status_ok' => 0, 'msg' => lang_get('please_choose_req_file')); } return $retval; }
function compareImportedReqs(&$dbHandler, $arrImportSource, $tprojectID, $reqSpecID) { $reqCfg = config_get('req_cfg'); $labels = array('type' => $reqCfg->type_labels, 'status' => $reqCfg->status_labels); $verbose = array('type' => null, 'status' => null); $cache = array('type' => null, 'status' => null); $cacheKeys = array_keys($cache); $unknown_code = lang_get('unknown_code'); $reqMgr = new requirement_mgr($dbHandler); $arrImport = null; if ($loop2do = count($arrImportSource)) { $getOptions = array('output' => 'minimun'); $messages = array('ok' => '', 'import_req_conflicts_other_branch' => '', 'import_req_exists_here' => ''); foreach ($messages as $key => $dummy) { $messages[$key] = lang_get($key); } for ($idx = 0; $idx < $loop2do; $idx++) { $msgID = 'ok'; $req = $arrImportSource[$idx]; // Check: // If item with SAME DOCID exists inside container // If there is a hit // We will follow user option: update,create new version // // If do not exist check must be repeated, but on WHOLE test project // If there is a hit -> we can not create // else => create // // // 20100321 - we do not manage yet user option $check_in_reqspec = $reqMgr->getByDocID($req['docid'], $tprojectID, $reqSpecID, $getOptions); if (is_null($check_in_reqspec)) { $check_in_tproject = $reqMgr->getByDocID($req['docid'], $tprojectID, null, $getOptions); if (!is_null($check_in_tproject)) { $msgID = 'import_req_conflicts_other_branch'; } } else { $msgID = 'import_req_exists_here'; } foreach ($cacheKeys as $attr) { if (isset($labels[$attr][$req[$attr]])) { if (!isset($cache[$attr][$req[$attr]])) { $cache[$attr][$req[$attr]] = lang_get($labels[$attr][$req[$attr]]); } $verbose[$attr] = $cache[$attr][$req[$attr]]; } else { $verbose[$attr] = sprintf($unknown_code, $req[$attr]); } } $arrImport[] = array('req_doc_id' => $req['docid'], 'title' => trim($req['title']), 'scope' => $req['description'], 'type' => $verbose['type'], 'status' => $verbose['status'], 'expected_coverage' => $req['expected_coverage'], 'node_order' => $req['order'], 'check_status' => $messages[$msgID]); } } return $arrImport; }
* @author asimon * @copyright 2005-2009, TestLink community * @version CVS: $Id: reqSearchForm.php,v 1.3 2010/05/08 17:59:36 franciscom Exp $ * @link http://www.teamst.org/index.php * * This page presents the search formular for requirements. * * @internal Revisions: * 20100323 - asimon - added searching for req relation types (BUGID 1748) */ require_once "../../config.inc.php"; require_once "../functions/common.php"; testlinkInitPage($db); $templateCfg = templateConfiguration(); $tproject_mgr = new testproject($db); $req_mgr = new requirement_mgr($db); $tcase_cfg = config_get('testcase_cfg'); $args = init_args(); $gui = new stdClass(); $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($args->tprojectID); $gui->tcasePrefix .= $tcase_cfg->glue_character; $gui->mainCaption = lang_get('testproject') . " " . $args->tprojectName; $enabled = 1; $no_filters = null; $gui->design_cf = $tproject_mgr->cfield_mgr->get_linked_cfields_at_design($args->tprojectID, $enabled, $no_filters, 'requirement'); $gui->keywords = $tproject_mgr->getKeywords($args->tprojectID); $reqSpecSet = $tproject_mgr->getOptionReqSpec($args->tprojectID, testproject::GET_NOT_EMPTY_REQSPEC); $gui->filter_by['design_scope_custom_fields'] = !is_null($gui->design_cf); $gui->filter_by['keyword'] = !is_null($gui->keywords); $gui->filter_by['requirement_doc_id'] = !is_null($reqSpecSet); $reqCfg = config_get('req_cfg');
/** * * */ function initialize_gui(&$dbHandler, $argsObj) { $tproject_mgr = new testproject($dbHandler); $req_mgr = new requirement_mgr($dbHandler); $commandMgr = new reqCommands($dbHandler); $gui = $commandMgr->initGuiBean(); $gui->refreshTree = $argsObj->refreshTree; $gui->req_cfg = config_get('req_cfg'); $gui->tproject_id = $argsObj->tproject_id; $gui->tproject_name = $argsObj->tproject_name; $gui->grants = new stdClass(); $gui->grants->req_mgmt = $argsObj->user->hasRight($dbHandler, "mgt_modify_req", $argsObj->tproject_id); // IMPORTANT NOTICE // We can arrive here after following operation // 1. user click on left pane tree on REQ SPEC NODE // 2. on right pane screen user click on CREATE button on Requirements Operations // 3. on new screen user CLICK CANCEL // In this situation $argsObj->req_id is 0 OR EMPTY $gui->req_id = $argsObj->req_id; if ($gui->req_id <= 0) { // Quick Exit // is not too clear why do not need to add lib/requirements/ on target $target = "reqSpecView.php?tproject_id={$gui->tproject_id}" . "&req_spec_id={$argsObj->req_spec_id}"; header("Location: {$target}"); exit; } // everything is fine - standard processing $gui->tcasePrefix = $tproject_mgr->getTestCasePrefix($argsObj->tproject_id); $gui->glueChar = config_get('testcase_cfg')->glue_character; $gui->pieceSep = config_get('gui_title_separator_1'); /* if wanted, show only the given version */ $gui->version_option = $argsObj->req_version_id ? $argsObj->req_version_id : requirement_mgr::ALL_VERSIONS; $gui->req_versions = $req_mgr->get_by_id($gui->req_id, $gui->version_option); $gui->req_has_history = count($req_mgr->get_history($gui->req_id, array('output' => 'array'))) > 1; $gui->req = current($gui->req_versions); $gui->req_coverage = $req_mgr->get_coverage($gui->req_id); // This seems weird but is done to adapt template than can display multiple // requirements. This logic has been borrowed from test case versions management $gui->current_version[0] = array($gui->req); $gui->cfields_current_version[0] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $gui->req['version_id'], $argsObj->tproject_id); // Now CF for other Versions $gui->other_versions[0] = null; $gui->cfields_other_versions[] = null; if (count($gui->req_versions) > 1) { $gui->other_versions[0] = array_slice($gui->req_versions, 1); $loop2do = count($gui->other_versions[0]); for ($qdx = 0; $qdx < $loop2do; $qdx++) { $target_version = $gui->other_versions[0][$qdx]['version_id']; $gui->cfields_other_versions[0][$qdx] = $req_mgr->html_table_of_custom_field_values($gui->req_id, $target_version, $argsObj->tproject_id); } } $gui->show_title = false; $gui->main_descr = lang_get('req') . $gui->pieceSep . $gui->req['title']; $gui->showReqSpecTitle = $argsObj->showReqSpecTitle; if ($gui->showReqSpecTitle) { $gui->parent_descr = lang_get('req_spec_short') . $gui->pieceSep . $gui->req['req_spec_title']; } $gui->attachments[$gui->req_id] = $req_mgr->getAttachmentInfos($gui->req_id); $gui->attachmentTableName = $req_mgr->getAttachmentTableName(); $gui->reqStatus = init_labels($gui->req_cfg->status_labels); $gui->reqTypeDomain = init_labels($gui->req_cfg->type_labels); // added req relations for BUGID 1748 $gui->req_relations = FALSE; $gui->req_relation_select = FALSE; $gui->testproject_select = FALSE; $gui->req_add_result_msg = isset($argsObj->relation_add_result_msg) ? $argsObj->relation_add_result_msg : ""; if ($gui->req_cfg->relations->enable) { $gui->req_relations = $req_mgr->get_relations($gui->req_id); $gui->req_relation_select = $req_mgr->init_relation_type_select(); if ($gui->req_cfg->relations->interproject_linking) { $gui->testproject_select = initTestprojectSelect($argsObj->userID, $argsObj->tproject_id, $tproject_mgr); } } return $gui; }
/** * process_req * * @internal revisions: * 20110601 - asimon - add a new (valid) direct link to output if a nonexistent version of a valid req is requested * 20110530 - asimon - BUGID 4298: refactored this function to be able to operate with specific versions */ function process_req(&$dbHandler, $docID, $tprojectID, $tprojectPrefix, $version) { $ret = array('url' => null, 'msg' => null); // First step: get this requirement's database ID by its Doc-ID (only if this Doc-ID exists). $req_mgr = new requirement_mgr($dbHandler); $req = $req_mgr->getByDocID($docID, $tprojectID); $req = is_null($req) ? null : current($req); $req_id = is_null($req) ? null : $req['id']; $version_id = null; if (is_null($req_id)) { $ret['msg'] = sprintf(lang_get('req_not_found'), $docID, $tprojectPrefix); } // Second step: If the requirement exists and a version was given, we have to check here if this specific version exists, too. if (!is_null($req_id) && !is_null($version) && is_numeric($version)) { $req = $req_mgr->get_by_id($req_id, null, $version); $req = is_null($req) ? null : current($req); // does this requirement really have the correct version number? $version_id = !is_null($req) && $req['version'] == $version ? $req['version_id'] : null; if (is_null($version_id)) { // add direct link to current version to output $req_url = $_SESSION['basehref'] . 'linkto.php?load&tprojectPrefix=' . urlencode($tprojectPrefix) . '&item=req&id=' . urlencode($docID); $ret['msg'] = sprintf(lang_get('req_version_not_found'), $version, $docID, $tprojectPrefix); $ret['msg'] .= sprintf(" <a href=\"{$req_url}\">%s</a>", lang_get('direct_link_on_wrong_version')); $req_id = null; } } // Third and last step: set cookie and build the link (only if the requested item really was found). if (!is_null($req_id)) { if (!is_null($version_id)) { // link to open in requirement frame must include version $ret['url'] = "lib/requirements/reqView.php?item=requirement&requirement_id={$req_id}&req_version_id={$version_id}"; } else { // link to open in requirement frame does not include a version, it was not requested $ret['url'] = "lib/requirements/reqView.php?item=requirement&requirement_id={$req_id}"; } $cookie = buildCookie($dbHandler, $req_id, $tprojectID, 'ys-requirement_spec'); setcookie($cookie['value'], $cookie['path'], TL_COOKIE_KEEPTIME, '/'); } return $ret; }
* @copyright 2010,2014 TestLink community * @filesource reqOverview.php * * List requirements with (or without) Custom Field Data in an ExtJS Table. * See TICKET 3227 for a more detailed description of this feature. * * */ require_once "../../config.inc.php"; require_once "common.php"; require_once 'exttable.class.php'; testlinkInitPage($db, false, false, "checkRights"); $cfield_mgr = new cfield_mgr($db); $templateCfg = templateConfiguration(); $tproject_mgr = new testproject($db); $req_mgr = new requirement_mgr($db); $cfg = getCfg(); $args = init_args($tproject_mgr); $gui = init_gui($args); $gui->reqIDs = $tproject_mgr->get_all_requirement_ids($args->tproject_id); $smarty = new TLSmarty(); if (count($gui->reqIDs) > 0) { $chronoStart = microtime(true); $pathCache = null; $imgSet = $smarty->getImages(); $gui->warning_msg = ''; // get type and status labels $type_labels = init_labels($cfg->req->type_labels); $status_labels = init_labels($cfg->req->status_labels); $labels2get = array('no' => 'No', 'yes' => 'Yes', 'not_aplicable' => null, 'never' => null, 'req_spec_short' => null, 'title' => null, 'version' => null, 'th_coverage' => null, 'frozen' => null, 'type' => null, 'status' => null, 'th_relations' => null, 'requirements' => null, 'number_of_reqs' => null, 'number_of_versions' => null, 'requirement' => null, 'version_revision_tag' => null, 'week_short' => 'calendar_week_short'); $labels = init_labels($labels2get);
// log to event viewer fails, but log to file works ok testlinkInitPage($db); if ($cfg->bts_type != 'NO') { require_once TL_ABS_PATH . 'lib' . DIRECTORY_SEPARATOR . 'bugtracking' . DIRECTORY_SEPARATOR . 'int_bugtracking.php'; } $templateCfg = templateConfiguration(); $tcversion_id = null; $submitResult = null; $args = init_args($cfg); $smarty = new TLSmarty(); $tree_mgr = new tree($db); $tplan_mgr = new testplan($db); $tcase_mgr = new testcase($db); $exec_cfield_mgr = new exec_cfield_mgr($db, $args->tproject_id); $attachmentRepository = tlAttachmentRepository::create($db); $req_mgr = new requirement_mgr($db); $gui = initializeGui($db, $args, $cfg, $tplan_mgr, $tcase_mgr); $_SESSION['history_on'] = $gui->history_on; $attachmentInfos = null; $do_show_instructions = $args->level == "" || $args->level == 'testproject' ? 1 : 0; if ($do_show_instructions) { show_instructions('executeTest'); exit; } // --------------------------------------------------------- // Testplan executions and result archiving. Checks whether execute cases button was clicked // if ($args->doExec == 1) { /** @note get testcase ids in an array */ if (!is_null($args->tc_versions) && count($args->tc_versions)) { $status_and_notes = do_remote_execution($db, $args->tc_versions);
* 20100323 - asimon - show columns for relations and coverage only if these features are enabled. * added number of requirement relations to table. * 20100312 - asimon - replaced "100%"-value (in case where req has no coverage) by N/A-string * 20100311 - asimon - fixed a little bug (only notice) when no cfields are defined * 20100310 - asimon - refactoring as requested * 20100309 - asimon - initial commit * */ require_once "../../config.inc.php"; require_once "common.php"; require_once 'exttable.class.php'; testlinkInitPage($db, false, false, "checkRights"); $cfield_mgr = new cfield_mgr($db); $templateCfg = templateConfiguration(); $tproject_mgr = new testproject($db); $req_mgr = new requirement_mgr($db); $args = init_args($tproject_mgr); $gui = init_gui($args); $glue_char = config_get('gui_title_separator_1'); $charset = config_get('charset'); $req_cfg = config_get('req_cfg'); $date_format_cfg = config_get('date_format'); $week_short = lang_get('calendar_week_short'); $time_format_cfg = config_get('timestamp_format'); $coverage_enabled = $req_cfg->expected_coverage_management; $relations_enabled = $req_cfg->relations->enable; $gui->reqIDs = $tproject_mgr->get_all_requirement_ids($args->tproject_id); if (count($gui->reqIDs) > 0) { // get type and status labels $type_labels = init_labels($req_cfg->type_labels); $status_labels = init_labels($req_cfg->status_labels);
function copy_to($id, $parent_id, $tproject_id, $user_id, $options = null) { static $get_tree_nt2exclude; if (!$get_tree_nt2exclude) { $get_tree_nt2exclude = array('req_version' => 'exclude_me', 'req_revision' => 'exclude_me', 'requirement_spec_revision' => 'exclude_me'); } $debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__; $op = array('status_ok' => 1, 'msg' => 'ok', 'id' => -1, 'mappings' => null); $my['options'] = array('copy_also' => null); $my['options'] = array_merge($my['options'], (array) $options); $item_info = $this->get_by_id($id); $target_doc = $this->generateDocID($id, $tproject_id); $new_item = $this->create($tproject_id, $parent_id, $target_doc, $item_info['title'], $item_info['scope'], $item_info['total_req'], $item_info['author_id'], $item_info['type'], $item_info['node_order']); $op = $new_item; if ($new_item['status_ok']) { $op['mappings'][$id] = $new_item['id']; $op['mappings']['req_spec'] = array(); $op['mappings']['req'] = array(); $op['mappings']['req_version'] = array(); $idCard = array('parent_id' => $id, 'tproject_id' => $tproject_id); $this->copy_cfields($idCard, $new_item['id']); $this->copy_attachments($id, $new_item['id']); // Now loop to copy all items inside it // null is OK, because $id is a req spec, there is no risk // to copy/traverse wrong node types. // Hmmm may be req_revi ??? $my['filters']['exclude_node_types'] = $get_tree_nt2exclude; $subtree = $this->tree_mgr->get_subtree($id, $my['filters'], array('output' => 'essential')); if (!is_null($subtree)) { $reqMgr = new requirement_mgr($this->db); $parent_decode = array(); $parent_decode[$id] = $new_item['id']; // using reference has to avoid duplicate => memory consumption // (at least this is info found on Internet) // Few test indicates that it's true, but that using a counter // is still better. // $loop2do = count($subtree); for ($sdx = 0; $sdx <= $loop2do; $sdx++) { $elem =& $subtree[$sdx]; $the_parent_id = isset($parent_decode[$elem['parent_id']]) ? $parent_decode[$elem['parent_id']] : null; switch ($elem['node_type_id']) { case $this->node_types_descr_id['requirement']: $ret = $reqMgr->copy_to($elem['id'], $the_parent_id, $user_id, $tproject_id, $my['options']); $op['status_ok'] = $ret['status_ok']; $op['mappings']['req'] += $ret['mappings']['req']; $op['mappings']['req_version'] += $ret['mappings']['req_version']; break; case $this->node_types_descr_id['requirement_spec']: $item_info = $this->get_by_id($elem['id']); // hmm, when copy_to() is called because we are duplicating // a test project, call to generateDocID(), can be avoided. // we have IMHO an absolute inexistent risk. $target_doc = $this->generateDocID($elem['id'], $tproject_id); $ret = $this->create($tproject_id, $the_parent_id, $target_doc, $item_info['title'], $item_info['scope'], $item_info['total_req'], $item_info['author_id'], $item_info['type'], $item_info['node_order']); $parent_decode[$elem['id']] = $ret['id']; $op['mappings']['req_spec'][$elem['id']] = $ret['id']; if ($op['status_ok'] = $ret['status_ok']) { // try to reduce memory usage // $idCard = array('parent_id' => $elem['id'], 'tproject_id' => $tproject_id); $this->copy_cfields(array('parent_id' => $elem['id'], 'tproject_id' => $tproject_id), $ret['id']); } break; } if ($op['status_ok'] == 0) { break; } } } } return $op; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions */ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context, $indentLevel) { static $req_mgr; static $tc_mgr; static $build_mgr; static $tplan_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $tables = null; static $force = null; static $bugInterfaceOn = false; static $its; static $buildCfields; static $statusL10N; static $docRepo; static $st; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; $level = $indentLevel; $prefix = isset($context['prefix']) ? $context['prefix'] : null; $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0; $build_id = isset($context['build_id']) ? $context['build_id'] : 0; // init static elements if (!$tables) { $st = new stdClass(); $tables = tlDBObject::getDBTables(array('executions', 'builds', 'execution_tcsteps')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); $build_mgr = new build_mgr($db); $tplan_mgr = new testplan($db); $req_mgr = new requirement_mgr($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; $its = null; $tproject_mgr = new testproject($db); $info = $tproject_mgr->get_by_id($tprojectID); $bugInterfaceOn = $info['issue_tracker_enabled']; if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($db); $its = $it_mgr->getInterfaceObject($tprojectID); unset($it_mgr); } $statusL10N = null; foreach ($cfg['results']['code_status'] as $vc => $vstat) { if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) { $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]); } } $docRepo = tlAttachmentRepository::create($db); $st->locationFilters = $tc_mgr->buildCFLocationMap(); // change table style in case of single TC printing to not be indented $st->table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $st->table_style = 'style="margin-left: 0;"'; } $st->cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '); $info = null; } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getByID['filters'] = null; $opt = array(); $opt['step_exec_notes'] = isset($options['step_exec_notes']) && $options['step_exec_notes']; $opt['step_exec_status'] = isset($options['step_exec_status']) && $options['step_exec_status']; switch ($options["docType"]) { case DOC_TEST_SPEC: $getByID['tcversion_id'] = testcase::LATEST_VERSION; $getExecutions = false; break; case SINGLE_TESTCASE: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status']; break; default: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status']; break; } if ($getExecutions) { // Thanks to Evelyn from Cortado, have found a very old issue never reported. // 1. create TC-1A VERSION 1 // 2. add to test plan and execute FAILED ON BUILD 1 // 3. Request Test Report (Test Plan EXECUTION REPORT). // You will get spec for VERSION 1 and result for VERSION 1 - OK cool! // 4. create VERSION 2 // 5. update linked Test Case Versions // 6. do nothing more than repeat step 3 // without this fix you will get // You will get spec for VERSION 2 and result for VERSION 1 - Hmmm // and in addition is not clear that execution was on VERSION 1 . No GOOD!! // // HOW has been fixed ? // Getting info about THE CURRENT LINKED test case version and looking for // exec info for this. // // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided // // // Get Linked test case version $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id); $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " E.execution_type, E.execution_duration, " . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON B.id = E.build_id " . " WHERE 1 = 1 "; if (isset($context['exec_id'])) { $sql .= " AND E.id=" . intval($context['exec_id']); } else { $sql .= " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']); if ($build_id > 0) { $sql .= " AND E.build_id = " . intval($build_id); } else { // We are looking for LATEST EXECUTION of CURRENT LINKED test case version $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']); } $sql .= " ORDER BY execution_id DESC"; } $exec_info = $db->get_recordset($sql, null, 1); $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id']; $getByID['filters'] = null; $linkedItem = null; if (!is_null($exec_info)) { $getByID['tcversion_id'] = null; $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']); if (isset($options['build_cfields']) && $options['build_cfields']) { if (!isset($buildCfields[$exec_info[0]['build_id']])) { $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID); } } } } $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true, 'renderImageInline' => true)); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); $cfields = array('specScope' => null, 'execScope' => null); if ($options['cfields']) { // Get custom fields that has specification scope // Custom Field values at Test Case VERSION Level foreach ($st->locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $st->cfieldFormatting, $tcInfo['id']); } if (!is_null($exec_info)) { $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($tcInfo['id'], 'execution', null, $exec_info[0]['execution_id'], $tplan_id, $tprojectID, $st->cfieldFormatting); } } if ($options['toc']) { // EXTERNAL ID added $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $st->table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version switch ($env->reportType) { case DOC_TEST_PLAN_DESIGN: $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; break; case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $version_number = $tcInfo['version']; break; default: $version_number = $tcInfo['version']; break; } if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; } if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) { $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Check user rights in order to understand if can delete attachments here // function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false) // $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; // $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $canManageAttachments = false; if (isset($context['user']) && !is_null($context['user'])) { $canManageAttachments = $context['user']->hasRight($db, 'testplan_execute', $tprojectID, $tplan_id); } // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if (!is_null($tcInfo[$key]) && $tcInfo[$key] != '') { $td_colspan = 3; $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>'; $sxni = null; if ($opt['step_exec_notes'] || $opt['step_exec_status']) { $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']); if ($opt['step_exec_notes']) { $td_colspan++; $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>'; } if ($opt['step_exec_status']) { $td_colspan++; $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>'; } } $code .= '</tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>'; $nike = !is_null($sxni) && isset($sxni[$tcInfo[$key][$ydx]['id']]) && !is_null($sxni[$tcInfo[$key][$ydx]['id']]); if ($opt['step_exec_notes']) { $code .= '<td>'; if ($nike) { $code .= $sxni[$tcInfo[$key][$ydx]['id']]['notes']; } $code .= '</td>'; } if ($opt['step_exec_status']) { $code .= '<td>'; if ($nike) { $code .= $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']]; } $code .= '</td>'; } $code .= '</tr>'; // Attachment management if ($getExecutions) { if (isset($sxni[$tcInfo[$key][$ydx]['id']])) { $attachInfo = getAttachmentInfos($docRepo, $sxni[$tcInfo[$key][$ydx]['id']]['id'], $tables['execution_tcsteps'], true, 1); if (!is_null($attachInfo)) { $code .= '<tr><td colspan="' . $td_colspan . '">'; $code .= '<b>' . $labels['exec_attachments'] . '</b><br>'; foreach ($attachInfo as $fitem) { $code .= '<form method="POST" name="fda' . $fitem['id'] . '" ' . ' id="fda' . $fitem['id'] . "' " . ' action="' . $env->base_href . 'lib/execute/execPrint.php">'; $code .= '<input type="hidden" name="id" value="' . intval($context['exec_id']) . '">'; $code .= '<input type="hidden" name="deleteAttachmentID" value="' . intval($fitem['id']) . '">'; if ($fitem['is_image']) { $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>"; $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '">'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a>'; } $code .= '<input type="image" alt="' . $labels['alt_delete_attachment'] . '"' . 'src="' . $env->base_href . TL_THEME_IMG_DIR . 'trash.png"></li></form>'; } $code .= '</td></tr>'; } } } // $getExecutions } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; // This is what have been choosen DURING DESIGN, but may be we can choose at DESIGN // manual and the execute AUTO, or may be choose AUTO and execute MANUAL. // After report on MANTIS, seems that we need to provide in output two values: // DESIGN execution type // EXECUTION execution type switch ($tcInfo['execution_type']) { case TESTCASE_EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case TESTCASE_EXECUTION_TYPE_MANUAL: default: $code .= $labels['execution_type_manual']; break; } $code .= "</td></tr>\n"; // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration']; $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // $cfields = null; $prio_info = null; // $code = null; // 20140813 $relSet = $tc_mgr->getRelations($id); if (!is_null($relSet['relations'])) { // $fx = str_repeat(' ',5); // MAGIC allowed $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['relations'] . '</span></td>'; $code .= '<td>'; for ($rdx = 0; $rdx < $relSet['num_relations']; $rdx++) { if ($relSet['relations'][$rdx]['source_id'] == $id) { $ak = 'source_localized'; } else { $ak = 'destination_localized'; } $code .= htmlspecialchars($relSet['relations'][$rdx][$ak]) . ' - ' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['fullExternalID']) . ':' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['name']) . '<br>'; } $code .= '</td></tr>'; } $relSet = null; // collect REQ for TC if ($options['requirement']) { $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } $requirements = null; // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $kwSet = $tc_mgr->getKeywords($id, null, array('fields' => 'keyword_id,keywords.keyword')); if (sizeof($kwSet)) { foreach ($kwSet as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $kwSet = null; // Attachments $attachSet = (array) $tc_mgr->getAttachmentInfos($id); if (count($attachSet) > 0) { $code .= '<tr><td> <span class="label">' . $labels['attached_files'] . '</span></td>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 2) . '"><ul>'; foreach ($attachSet as $item) { $fname = ""; if ($item['title']) { $fname .= htmlspecialchars($item['title']) . " : "; } $fname .= htmlspecialchars($item['file_name']); $code .= "<li>{$fname}</li>"; if ($item['is_image']) { $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>'; } } $code .= "</ul></td></tr>"; } $attachSet = null; // generate test results data for test report if ($options['passfail']) { $tsp = $cfg['tableColspan'] - 1; $code .= '<tr style="' . "font-weight: bold;background: #EEE;text-align: left;" . '">' . '<td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['execution_details'] . '</td>' . '<td colspan="' . $tsp . '">' . " " . "</b></td></tr>\n"; $bn = ''; switch ($env->reportType) { case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $ib = $build_mgr->get_by_id($build_id); $bn = htmlspecialchars($ib['name']); break; case DOC_TEST_PLAN_EXECUTION: if ($exec_info) { $bn = htmlspecialchars($exec_info[0]['build_name']); } break; } if ($bn != '') { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['build'] . '</td>' . '<td ' . $tsp . '>' . $bn . "</b></td></tr>\n"; } if (isset($node['assigned_to'])) { $crew = explode(',', $node['assigned_to']); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['assigned_to'] . '</td>' . '<td colspan="' . $tsp . '">'; $xdx = 0; foreach ($crew as $mm) { if ($xdx != 0) { $code .= ','; } $xdx = -1; echo $mm . '<br>'; $code .= gendocGetUserName($db, $mm); } $code .= "</td></tr>\n"; } if ($exec_info) { $settings['cfg'] = $cfg; $settings['lbl'] = $labels; $settings['opt'] = array('show_notes' => $options['notes']); $settings['colspan'] = $cfg['tableColspan'] - 1; $code .= buildTestExecResults($db, $its, $exec_info, $settings, $buildCfields); // Get Execution Attachments $execAttachInfo = getAttachmentInfos($docRepo, $exec_info[0]['execution_id'], $tables['executions'], true, 1); if (!is_null($execAttachInfo)) { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">'; $code .= '<b>' . $labels['exec_attachments'] . '</b><br>'; foreach ($execAttachInfo as $fitem) { if ($fitem['is_image']) { $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>"; $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '"> </li>'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a></li>'; } } $code .= '</td></tr>'; } } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['report_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } $execAttachInfo = null; $exec_info = null; } $code .= "</table>\n</div>\n"; return $code; }
/** * replace BBCode-link tagged links in req/reqspec scope with actual links * * @internal revisions: * 20110525 - Julian - BUGID 4487 - allow to specify requirement version for internal links * 20100301 - asimon - added anchor and tproj parameters to tags * * @param resource $dbHandler database handle * @param string $scope text in which to replace tags with links * @param integer $tprojectID ID of testproject to which req/reqspec belongs * @return string $scope text with generated links */ function req_link_replace($dbHandler, $scope, $tprojectID) { // Use this to improve performance when is called in loops static $tree_mgr; static $tproject_mgr; static $req_mgr; static $cfg; static $l18n; static $title; static $tables; if (!$tproject_mgr) { $tproject_mgr = new testproject($dbHandler); $tree_mgr = new tree($dbHandler); $req_mgr = new requirement_mgr($dbHandler); $tables = tlObjectWithDB::getDBTables(array('requirements', 'req_specs')); $cfg = config_get('internal_links'); $l18n['version'] = lang_get('tcversion_indicator'); $prop2loop = array('req' => array('prop' => 'req_link_title', 'default_lbl' => 'requirement'), 'req_spec' => array('prop' => 'req_spec_link_title', 'default_lbl' => 'req_spec_short')); // configure link title (first part of the generated link) $title = array(); foreach ($prop2loop as $key => $elem) { $prop = $elem['prop']; if ($cfg->{$prop}->type == 'string' && $cfg->{$prop}->value != '') { $title[$key] = lang_get($cfg->{$prop}->value); } else { if ($cfg->{$prop}->type == 'none') { $title[$key] = ''; } else { $title[$key] = lang_get($elem['default_lbl']) . ": "; } } } } $prefix = $tproject_mgr->getTestCasePrefix($tprojectID); $string2replace = array(); // configure target in which link shall open // use a reasonable default value if nothing is set in config $cfg->target = isset($cfg->target) ? $cfg->target : 'popup'; switch ($cfg->target) { case 'popup': // use javascript to open popup window $string2replace['req'] = '<a href="javascript:openLinkedReqVersionWindow(%s,%s,\'%s\')">%s%s%s</a>'; $string2replace['req_spec'] = '<a href="javascript:openLinkedReqSpecWindow(%s,\'%s\')">%s%s</a>'; break; case 'window': case 'frame': // open in same frame $target = $cfg->target == 'window' ? 'target="_blank"' : 'target="_self"'; $string2replace['req'] = '<a ' . $target . ' href="lib/requirements/reqView.php?' . 'item=requirement&requirement_id=%s&req_version_id=%s#%s">%s%s%s</a>'; $string2replace['req_spec'] = '<a ' . $target . ' href="lib/requirements/reqSpecView.php?' . 'item=req_spec&req_spec_id=%s#%s">%s%s</a>'; break; } // now the actual replacing $patterns2search = array(); $patterns2search['req'] = "#\\[req(.*)\\](.*)\\[/req\\]#iU"; $patterns2search['req_spec'] = "#\\[req_spec(.*)\\](.*)\\[/req_spec\\]#iU"; $patternPositions = array('complete_string' => 0, 'attributes' => 1, 'doc_id' => 2); $items2search['req'] = array('tproj', 'anchor', 'version'); $items2search['req_spec'] = array('tproj', 'anchor'); $itemPositions = array('item' => 0, 'item_value' => 1); $sql2exec = array(); $sql2exec['req'] = " SELECT id, req_doc_id AS doc_id " . " FROM {$tables['requirements']} WHERE req_doc_id="; $sql2exec['req_spec'] = " SELECT id, doc_id FROM {$tables['req_specs']} " . " WHERE doc_id="; foreach ($patterns2search as $accessKey => $pattern) { $matches = array(); preg_match_all($pattern, $scope, $matches); // if no req_doc_id is set skip loop if (count($matches[$patternPositions['doc_id']]) == 0) { continue; } foreach ($matches[$patternPositions['complete_string']] as $key => $matched_string) { $matched = array(); $matched['tproj'] = ''; $matched['anchor'] = ''; $matched['version'] = ''; // only look for attributes if any found if ($matches[$patternPositions['attributes']][$key] != '') { foreach ($items2search[$accessKey] as $item) { $matched_item = array(); preg_match('/' . $item . '=([\\w]+)/', $matched_string, $matched_item); $matched[$item] = isset($matched_item[$itemPositions['item_value']]) ? $matched_item[$itemPositions['item_value']] : ''; } } // set tproj to current project if tproj is not specified in attributes if (!isset($matched['tproj']) || $matched['tproj'] == '') { $matched['tproj'] = $prefix; } // get all reqs / req specs with the specified doc_id $sql = $sql2exec[$accessKey] . "'{$matches[$patternPositions['doc_id']][$key]}'"; $rs = $dbHandler->get_recordset($sql); if (count($rs) > 0) { foreach ($rs as $key => $value) { // get root of linked node and check $real_root = $tree_mgr->getTreeRoot($value['id']); $matched_root_info = $tproject_mgr->get_by_prefix($matched['tproj']); // do only continue if project with the specified project exists and // if the requirement really belongs to the specified project (requirements // with the same doc_id may exist within different projects) if ($real_root == $matched_root_info['id']) { if ($accessKey == 'req') { // add version to link title if set $version = ''; $req_version_id = 'null'; if ($matched['version'] != '') { // get requirement version_id of the specified version $req_version = $req_mgr->get_by_id($value['id'], null, $matched['version']); // if version is not set or wrong version was set // -> show latest version by setting version_id to null $req_version_id = isset($req_version[0]['version_id']) ? $req_version[0]['version_id'] : 'null'; // if req_version_id exists set the version to show on hyperlink text if ($req_version_id != 'null') { $version = sprintf($l18n['version'], $matched['version']); } } $urlString = sprintf($string2replace[$accessKey], $value['id'], $req_version_id, $matched['anchor'], $title[$accessKey], $value['doc_id'], $version); } else { // build urlString for req specs which do not have a version $urlString = sprintf($string2replace[$accessKey], $value['id'], $matched['anchor'], $title[$accessKey], $value['doc_id']); } $scope = str_replace($matched_string, $urlString, $scope); } } } } } return $scope; }
/** * create a req spec tree on system from $xml data * * * */ function createFromXML($xml, $tproject_id, $parent_id, $author_id, $filters = null, $options = null) { $user_feedback = null; $items = $this->xmlToMapReqSpec($xml); $req_mgr = new requirement_mgr($this->db); $copy_reqspec = null; $copy_req = null; $getOptions = array('output' => 'minimun'); $has_filters = !is_null($filters); $my['options'] = array('actionOnDuplicate' => "update"); $my['options'] = array_merge($my['options'], (array) $options); $labels = array('import_req_spec_created' => '', 'import_req_spec_skipped' => '', 'import_req_spec_updated' => '', 'import_req_spec_ancestor_skipped' => '', 'import_req_created' => '', 'import_req_skipped' => '', 'import_req_updated' => ''); foreach ($labels as $key => $dummy) { $labels[$key] = lang_get($key); } if ($has_filters) { if (!is_null($filters['requirements'])) { foreach ($filters['requirements'] as $reqspec_pos => $requirements_pos) { $copy_req[$reqspec_pos] = is_null($requirements_pos) ? null : array_keys($requirements_pos); } } } $loop2do = count($items); $container_id[0] = is_null($parent_id) || $parent_id == 0 ? $tproject_id : $parent_id; // items is an array of req. specs $skip_level = -1; for ($idx = 0; $idx < $loop2do; $idx++) { $rspec = $items[$idx]['req_spec']; $depth = $rspec['level']; if ($skip_level > 0 && $depth >= $skip_level) { $msgID = 'import_req_spec_ancestor_skipped'; $user_feedback[] = array('doc_id' => $rspec['doc_id'], 'title' => $rspec['title'], 'import_status' => sprintf($labels[$msgID], $rspec['doc_id'])); continue; } $req_spec_order = isset($rspec['node_order']) ? $rspec['node_order'] : 0; // 20100320 - // Check if req spec with same DOCID exists, inside container_id // If there is a hit // We will go in update // If Check fails, need to repeat check on WHOLE Testproject. // If now there is a HIT we can not import this branch // If Check fails => we can import creating a new one. // // Important thing: // Working in this way, i.e. doing check while walking the structure to import // we can end importing struct with 'holes'. // $check_in_container = $this->getByDocID($rspec['doc_id'], $tproject_id, $container_id[$depth], $getOptions); $skip_level = $depth + 1; $result['status_ok'] = 0; $msgID = 'import_req_spec_skipped'; if (is_null($check_in_container)) { $check_in_tproject = $this->getByDocID($rspec['doc_id'], $tproject_id, null, $getOptions); if (is_null($check_in_tproject)) { $msgID = 'import_req_spec_created'; $result = $this->create($tproject_id, $container_id[$depth], $rspec['doc_id'], $rspec['title'], $rspec['scope'], $rspec['total_req'], $author_id, $rspec['type'], $req_spec_order); } } else { $msgID = 'import_req_spec_updated'; $reqSpecID = key($check_in_container); $result = $this->update($reqSpecID, $rspec['doc_id'], $rspec['title'], $rspec['scope'], $rspec['total_req'], $author_id, $rspec['type'], $req_spec_order); $result['id'] = $reqSpecID; } $user_feedback[] = array('doc_id' => $rspec['doc_id'], 'title' => $rspec['title'], 'import_status' => sprintf($labels[$msgID], $rspec['doc_id'])); if ($result['status_ok']) { $skip_level = -1; $container_id[$depth + 1] = $reqSpecID = $result['id']; $reqSet = $items[$idx]['requirements']; $create_req = (!$has_filters || isset($copy_req[$idx])) && !is_null($reqSet); if ($create_req) { $items_qty = isset($copy_req[$idx]) ? count($copy_req[$idx]) : count($reqSet); $keys2insert = isset($copy_req[$idx]) ? $copy_req[$idx] : array_keys($reqSet); for ($jdx = 0; $jdx < $items_qty; $jdx++) { $req = $reqSet[$keys2insert[$jdx]]; // Check: // If item with SAME DOCID exists inside container // If there is a hit // We will follow user option: update,create new version // // If do not exist check must be repeated, but on WHOLE test project // If there is a hit -> we can not create // else => create // // // 20100321 - we do not manage yet user option $msgID = 'import_req_skipped'; $check_in_reqspec = $req_mgr->getByDocID($req['docid'], $tproject_id, $reqSpecID, $getOptions); if (is_null($check_in_reqspec)) { $check_in_tproject = $req_mgr->getByDocID($req['docid'], $tproject_id, null, $getOptions); if (is_null($check_in_tproject)) { $req_mgr->create($result['id'], $req['docid'], $req['title'], $req['description'], $author_id, $req['status'], $req['type'], $req['expected_coverage'], $req['node_order']); $msgID = 'import_req_created'; } } else { // function update($id,$version_id,$reqdoc_id,$title, $scope, $user_id, $status, $type, // $expected_coverage,$node_order=null,$skip_controls=0) // // Need to get Last Version no matter active or not. // What to do if is Frozen ??? -> now ignore and update anyway $reqID = key($check_in_reqspec); $last_version = $req_mgr->get_last_version_info($reqID); $result = $req_mgr->update($reqID, $last_version['id'], $req['docid'], $req['title'], $req['description'], $author_id, $req['status'], $req['type'], $req['expected_coverage'], $req['node_order']); $msgID = 'import_req_updated'; } } $user_feedback[] = array('doc_id' => $req['docid'], 'title' => $req['title'], 'import_status' => sprintf($labels[$msgID], $req['docid'])); } // if($create_req) } // if($result['status_ok']) } return $user_feedback; }
/** * copyReqAssignmentTo * copy requirement assignments for $from test case id to $to test case id * * mappings is only useful when source_id and target_id do not belong to same Test Project. * Because keywords are defined INSIDE a Test Project, ID will be different for same keyword * in a different Test Project. * */ function copyReqAssignmentTo($from, $to, $mappings, $userID) { static $req_mgr; if (is_null($req_mgr)) { $req_mgr = new requirement_mgr($this->db); } $itemSet = $req_mgr->get_all_for_tcase($from); if (!is_null($itemSet)) { $loop2do = count($itemSet); for ($idx = 0; $idx < $loop2do; $idx++) { if (isset($mappings[$itemSet[$idx]['id']])) { $items[$idx] = $mappings[$itemSet[$idx]['id']]; } else { $items[$idx] = $itemSet[$idx]['id']; } } $req_mgr->assign_to_tcase($items, $to, $userID); } }
* 20100819 - asimon - BUGIDs 3261, 3439, 3488, 3569, 3299, 3259, 3687: * complete redesign/rewrite of requirement based report * 20090506 - franciscom - requirements refactoring * 20090402 - amitkhullar - added TC version while displaying the Req -> TC Mapping * 20090111 - franciscom - BUGID 1967 + improvements * 20060104 - fm - BUGID 0000311: Requirements based Report shows errors */ require_once "../../config.inc.php"; require_once "common.php"; require_once 'requirements.inc.php'; require_once 'exttable.class.php'; testlinkInitPage($db, false, false, "checkRights"); $templateCfg = templateConfiguration(); $tproject_mgr = new testproject($db); $tplan_mgr = new testplan($db); $req_mgr = new requirement_mgr($db); $req_spec_mgr = new requirement_spec_mgr($db); $glue_char = config_get('gui_title_separator_1'); // BUGID 3439 $no_srs_msg_key = 'no_srs_defined'; $no_finished_reqs_msg_key = 'no_finished_reqs'; $charset = config_get('charset'); $req_cfg = config_get('req_cfg'); $req_spec_cfg = config_get('req_spec_cfg'); $results_cfg = config_get('results'); $coverage_algorithm = $req_cfg->coverageStatusAlgorithm; $coverage_enabled = $req_cfg->expected_coverage_management; $external_req_mgmt = $req_cfg->external_req_management; $req_type_labels = init_labels($req_cfg->type_labels); $req_spec_type_labels = init_labels($req_spec_cfg->type_labels); $status_labels = init_labels($req_cfg->status_labels);