Permalink
Browse files

#0008478: Allow add for Latest Req version to test case version link …

…when REQ Version is FROZEN
  • Loading branch information...
fmancardi committed Nov 17, 2018
1 parent acc7dd1 commit 19107ebd5d0d61cef0ab4e3eadc42d745d1f8dc3
@@ -10,7 +10,7 @@ assign REQ to one test case
s="please_select_a_req,test_case,req_title_assign,btn_close,
warning_req_tc_assignment_impossible,req_spec,warning,
req_title_assigned,check_uncheck_all_checkboxes,version,
version_short,
version_short,reqLinkingDisabledAfterExec,
req_msg_norequirement,btn_unassign,req_title_unassigned,
check_uncheck_all_checkboxes,req_msg_norequirement,btn_assign,
req_doc_id,req,scope,assigned_by,timestamp,requirement"}
@@ -45,14 +45,17 @@ function refreshAndClose(tcase_id,callback) {
</script>
</head>
{$msgReqLinkingEnabled = ''}
{$reqLinkingEnabled = 0}
{if $gui->req_tcase_link_management}
{$reqLinkingEnabled = 1}
{$msgReqLinkingEnabled = $labels.yourRoleHasReqLinkingDisabled}
{/if}
{if $tlCfg->testcase_cfg->reqLinkingDisabledAfterExec == 1 &&
$gui->tcaseHasBeenExecuted == 1}
{$reqLinkingEnabled = 0}
{$msgReqLinkingEnabled = $labels.reqLinkingDisabledAfterExec}
{/if}
@@ -123,12 +126,15 @@ function refreshAndClose(tcase_id,callback) {
{$cbDisabled = 0}
{* Has become complex & weird!! *}
{* can_be_removed check LINK STATUS *}
{if $tlCfg->reqTCLink->freezeeLinkOnNewREQVersion == TRUE }
{if $gui->assignedReq[row].reqver_is_open == 0 ||
$gui->assignedReq[row].can_be_removed == 0 }
{if $gui->assignedReq[row].can_be_removed == 0 }
{$cbDisabled = 1}
{/if}
{/if}
{if $reqLinkingEnabled == 0}
{$cbDisabled = 1}
{/if}
<tr>
<td>
{if $cbDisabled == 1}
@@ -159,6 +165,12 @@ function refreshAndClose(tcase_id,callback) {
onclick="return check_action_precondition('reqList','unassign');"/>
</div>
{/if}
{if $reqLinkingEnabled == 0}
<div class="groupBtn">
{$msgReqLinkingEnabled}
</div>
{/if}
</form>
{/if}
@@ -190,7 +202,7 @@ function refreshAndClose(tcase_id,callback) {
{section name=row2 loop=$gui->unassignedReq}
{$freeReq = $gui->unassignedReq[row2]}
<tr>
<td><input type="checkbox" {if $freeReq.reqver_is_open == 0} disabled="disabled" {/if}
<td><input type="checkbox"
id="free_req{$freeReq.id}" value="{$freeReq.id}"
name="req_id[{$freeReq.id}]" /></td>
@@ -279,8 +279,8 @@ var {$gui->dialogName} = new std_dialog('&refreshTree');
{* Current *}
{include file="$this_template_dir/reqViewVersionsViewer.tpl"
args_req_coverage=$gui->current_req_coverage
args_can_manage_coverage=$gui->canAddCoverage
args_req_coverage = $gui->current_req_coverage
args_can_manage_coverage = $gui->canAddCoverage
args_req=$gui->current_version[idx][0]
args_gui=$gui
args_grants=$gui->grants
@@ -472,9 +472,10 @@ var {$gui->dialogName} = new std_dialog('&refreshTree');
onclick="javascript:toogleShowHide('control_panel_{$reqVersionID}','inline');"
title="{$labels.actions}" />
{* Req Version link to Test Case Version only
for Latest Req Version *}
{include file="$this_template_dir/reqViewVersionsViewer.tpl"
args_hide_coverage=false
args_can_manage_coverage=false
args_req_coverage=$gui->other_req_coverage[idx][$rdx]
args_req=$my_req
@@ -205,7 +205,8 @@ viewer for requirement
{section name=row loop=$args_req_coverage}
<span>
{if $args_grants->req_tcase_link_management == "yes" && $args_frozen_version eq null && $args_req_coverage[row].can_be_deleted}
{if $args_grants->req_tcase_link_management == "yes" &&
$args_req_coverage[row].can_be_deleted}
<input type="image" class="clickable" src="{$tlImages.disconnect_small}"
title="{$labels.removeLinkToTestCase}" onClick="tcaseIdentity.value={$args_req_coverage[row].tcversion_id}">
{else}
@@ -231,8 +232,8 @@ viewer for requirement
{/if}
{if ( !isset($args_can_manage_coverage) || $args_can_manage_coverage == TRUE ) &&
(is_null($args_frozen_version) || !$args_frozen_version ) && $args_grants->req_tcase_link_management == "yes"}
{if ( !isset($args_can_manage_coverage) || $args_can_manage_coverage == TRUE ) &&
$args_grants->req_tcase_link_management == "yes"}
<form style="display: inline;" id="reqAddTestCase_{$req_version_id}" name="reqAddTestCase_{$req_version_id}"
action="{$basehref}lib/requirements/reqEdit.php" method="post">
<input type="hidden" id="atRID" name="requirement_id" value="{$args_req.id}" />
@@ -2926,8 +2926,7 @@ function get_exec_status($id,$filters=null, $options=null)
*
* @internal revisions
*/
function getInternalID($stringID,$opt = null)
{
function getInternalID($stringID,$opt = null) {
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$internalID = 0;
$my['opt'] = array('glue' => $this->cfg->testcase->glue_character,
@@ -2940,13 +2939,12 @@ function getInternalID($stringID,$opt = null)
// When using this method on a context where caller certifies that
// test project is OK, we will skip this check.
$tproject_id = $my['opt']['tproject_id'];
if( !is_null($tproject_id) && !is_null($my['opt']['output']) )
{
if( !is_null($tproject_id) && !is_null($my['opt']['output']) ) {
$sql = " SELECT id,is_public FROM {$this->tables['testprojects']} " .
" WHERE id = " . intval($tproject_id);
$tproject_info = $this->db->get_recordset($sql);
if( !is_null($tproject_info) )
{
if( !is_null($tproject_info) ) {
$tproject_info = current($tproject_info);
}
}
@@ -2955,43 +2953,35 @@ function getInternalID($stringID,$opt = null)
// Find the last glue char
$gluePos = strrpos($stringID, $my['opt']['glue']);
$isFullExternal = ($gluePos !== false);
if($isFullExternal)
{
if($isFullExternal) {
$rawTestCasePrefix = substr($stringID, 0, $gluePos);
$rawExternalID = substr($stringID, $gluePos+1);
$status_ok = ($externalID = is_numeric($rawExternalID) ? intval($rawExternalID) : 0) > 0;
}
else
{
} else {
$status_ok = (($externalID = intval($stringID)) > 0);
}
if( $status_ok && is_null($tproject_id) )
{
if( $status_ok && is_null($tproject_id) ) {
$status_ok = false;
if($isFullExternal)
{
if($isFullExternal) {
// Check first if Test Project prefix is valid, if not abort
$testCasePrefix = $this->db->prepare_string($rawTestCasePrefix);
$sql = "SELECT id,is_public FROM {$this->tables['testprojects']} " .
"WHERE prefix = '" . $this->db->prepare_string($testCasePrefix) . "'";
$tproject_info = $this->db->get_recordset($sql);
if( $status_ok = !is_null($tproject_info) )
{
if( $status_ok = !is_null($tproject_info) ) {
$tproject_info = current($tproject_info);
$tproject_id = $tproject_info['id'];
// $tproject_id = $tproject_info[0]['id'];
}
}
else
{
} else {
throw new Exception(__METHOD__ .
' EXCEPTION: When using just numeric part of External ID, test project ID, is mandatory');
}
}
if( $status_ok )
{
if( $status_ok ) {
$internalID = 0;
// get all test cases with requested external ID on all test projects.
@@ -3003,13 +2993,10 @@ function getInternalID($stringID,$opt = null)
" WHERE TCV.tc_external_id = " . intval($externalID);
$testCases = $this->db->fetchRowsIntoMap($sql,'tcase_id');
if(!is_null($testCases))
{
foreach($testCases as $tcaseID => $value)
{
if(!is_null($testCases)) {
foreach($testCases as $tcaseID => $value) {
$path2root = $this->tree_manager->get_path($tcaseID);
if($tproject_id == $path2root[0]['parent_id'])
{
if($tproject_id == $path2root[0]['parent_id']) {
$internalID = $tcaseID;
break;
}
@@ -8818,5 +8805,20 @@ function getTCVersionIDFromVersion($tcaseID,$version) {
return $rs['tcversion_id'];
}
/**
*
*/
function latestVersionHasBeenExecuted($tcaseID) {
$sql = "SELECT COALESCE(E.tcversion_id,0) AS executed
FROM {$this->views['latest_tcase_version_id']} LTCV
LEFT OUTER JOIN {$this->tables['executions']} E
ON E.tcversion_id = LTCV.tcversion_id
WHERE LTCV.testcase_id=" . intval($tcaseID);
$rs = current($this->db->get_recordset($sql));
return ($rs['executed'] != 0);
}
} // Class end
@@ -881,8 +881,7 @@ function doFreezeVersion(&$argsObj,$request)
/**
*
*/
function addTestCase(&$argsObj,$request)
{
function addTestCase(&$argsObj,$request) {
$obj = $this->initGuiBean();
$node = $this->reqMgr->tree_mgr->get_node_hierarchy_info($argsObj->req_version_id);
@@ -895,42 +894,55 @@ function addTestCase(&$argsObj,$request)
$obj->template = "reqView.php?refreshTree=0&requirement_id={$argsObj->req_id}";
// Analise test case identity
$cfg = config_get('testcase_cfg');
$tcaseCfg = config_get('testcase_cfg');
$status_ok = false;
$msg = sprintf(lang_get('provide_full_external_tcase_id'),$argsObj->tcasePrefix, $cfg->glue_character);
$gluePos = strrpos($argsObj->tcaseIdentity, $cfg->glue_character);
$msg = sprintf(lang_get('provide_full_external_tcase_id'),$argsObj->tcasePrefix, $tcaseCfg->glue_character);
$gluePos = strrpos($argsObj->tcaseIdentity, $tcaseCfg->glue_character);
$isFullExternal = ($gluePos !== false);
if($isFullExternal)
{
//echo __LINE__ . ' :: status ok:' . $status_ok . '<br>';
if($isFullExternal) {
$status_ok = true;
$rawTestCasePrefix = substr($argsObj->tcaseIdentity, 0, $gluePos);
$status_ok = (strcmp($rawTestCasePrefix,$argsObj->tcasePrefix) == 0);
//echo __LINE__ . ' :: status ok:' . $status_ok . '<br>';
if(!$status_ok)
{
if(!$status_ok) {
$msg = sprintf(lang_get('seems_to_belong_to_other_tproject'),$rawTestCasePrefix,$argsObj->tcasePrefix);
}
}
if($status_ok) {
// IMPORANT NOTICE: audit info is managed on reqMgr method
// IMPORTANT NOTICE: audit info is managed on reqMgr method
$alienMgr = new testcase($this->db);
$tcase_id = $alienMgr->getInternalID($argsObj->tcaseIdentity,array('tproject_id' => $argsObj->tproject_id));
// Design Choice
// 1. Only latest test case version will be added
// 2. Only if not executed
if($tcase_id > 0) {
$this->reqMgr->assign_to_tcase($argsObj->req_id,$tcase_id,intval($argsObj->user_id));
}
else {
$doLink = true;
if( $tcaseCfg->reqLinkingDisabledAfterExec ) {
if( $alienMgr->latestVersionHasBeenExecuted($tcase_id) == 0) {
$doLink = true;
} else {
$status_ok = false;
$msg = sprintf(lang_get('cannot_link_latest_version_reason_has_been_exec'),
$argsObj->tcaseIdentity);
}
}
if( $doLink ) {
$this->reqMgr->assign_to_tcase($argsObj->req_id,$tcase_id,intval($argsObj->user_id));
}
} else {
$status_ok = false;
$msg = sprintf(lang_get('tcase_doesnot_exist'),$argsObj->tcaseIdentity);
}
}
if(!$status_ok)
{
if(!$status_ok) {
$obj->user_feedback = $msg;
$obj->template .= "&user_feedback=" . urlencode($obj->user_feedback);
}
@@ -3913,4 +3913,10 @@ $TLS_API_TESTPLAN_APIKEY_DOES_NOT_EXIST = 'Test Plan with API KEY: %s does not e
$TLS_tcvqty_with_kw = 'Quantity of Test Case Versions using this keyword';
$TLS_can_not_delete_a_frozen_relation = 'A Frozen relation can not be deleted';
$TLS_cannot_link_latest_version_reason_has_been_exec = 'Link to latest version of test case <b>%s</b> cannot be added - REASON: has been executed';
$TLS_reqLinkingDisabledAfterExec = 'System config blocks requirement version link management for executed test case versions';
$TLS_yourRoleHasReqLinkingDisabled = 'Your Roles does not have requirement version link to test case version right';
// ----- END ------------------------------------------------------------------

0 comments on commit 19107eb

Please sign in to comment.