|
首先,找到testlink\lib\req\reqTcAssign.php,下面是原代码
// redirect if a user doesn't choose test case
if ($edit == 'testproject' || $edit == 'testsuite')
{
redirect($_SESSION['basehref'] . "/lib/general/show_help.php?help=assignReqs&locale={$_SESSION['locale']}");
exit();
}
else if($edit == 'testcase')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tc_mgr = new testcase($db);
$arrTc = $tc_mgr->get_by_id($tc_id);
if ($arrTc)
{
$tcTitle = $arrTc[0]['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tc_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
} // if( $SRS_qty > 0 )
}
else
{
tlog("Wrong GET/POST arguments.", 'ERROR');
exit();
}
将这段代码修改如下,即可使testsuite和testproject关联需求
$tsuite_id = isset($_GET['id']) ? intval($_GET['id']) : null;
#----testcase--------
if($edit == 'testcase')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tc_mgr = new testcase($db);
$arrTc = $tc_mgr->get_by_id($tc_id);
if ($arrTc)
{
$tcTitle = $arrTc[0]['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tc_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
} // if( $SRS_qty > 0 )
}
#-------testproject------------
else if($edit == 'testproject' )
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tproject_mgr = new testproject($db);
$arrTproject = $tproject_mgr->get_by_id($tproject_id);
if ($arrTproject)
{
$tprojectTitle = $arrTproject[0]['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tproject_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
} // if( $SRS_qty > 0 )
}
#-----testsuite-------------------
else if($edit == 'testsuite')
{
//get list of ReqSpec (not_empty)
$get_not_empty=1;
$arrReqSpec = getOptionReqSpec($db,$tproject_id,$get_not_empty);
$SRS_qty=count($arrReqSpec);
if( $SRS_qty > 0 )
{
$tsuite_mgr = new testsuite($db);
$arrTsuite = $tsuite_mgr->get_by_id($tsuite_id);
if ($arrTsuite)
{
$tsuiteTitle = $arrTsuite[0]['name'];
//get first ReqSpec if not defined
if (!$idReqSpec && $SRS_qty > 0)
{
reset($arrReqSpec);
$idReqSpec = key($arrReqSpec);
tLog('Set first SRS ID: ' . $idReqSpec);
}
if ($idReqSpec)
{
$arrAssignedReq = getRequirements($db,$idReqSpec, 'assigned', $tsuite_id);
$arrAllReq = getRequirements($db,$idReqSpec);
$arrUnassignedReq = array_diff_byId($arrAllReq, $arrAssignedReq);
}
}
} // if( $SRS_qty > 0 )
}
else
{
tlog("Wrong GET/POST arguments.", 'ERROR');
exit();
} |
|