Skip to content

Commit 7b53d09

Browse files
authored
Ticket-8687: TC-Req assignment while proj copy updated
Updated pull request TestLinkOpenSourceTRMS#232 As explained in Ticket-8687: $mappings array consists out of subarrays (at least [0]), proposed approach uses LUT to store in which subarray $reqID can be found. Use this information to find req-tc mapping later. Tested with multiple reqSpecs at same level and w/ nested specs.
1 parent 810e3b4 commit 7b53d09

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

lib/functions/testcase.class.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8656,27 +8656,38 @@ function copyReqVersionLinksTo($source,$dest,$mappings,$userID) {
86568656
}
86578657

86588658
$itemSet = $reqMgr->getGoodForTCVersion($source['version_id']);
8659-
86608659
if( !is_null($itemSet) ) {
86618660

8661+
//Ticket-8687 create LUT: in which subarray of $mappings can the $reqID be found?
8662+
$lut=array();
8663+
foreach ($mappings as $key=>$value){
8664+
if (isset($value['req'])) {
8665+
foreach ($value['req'] as $rkey=>$rvalue){
8666+
$lut[$rkey]=$key;
8667+
}
8668+
}
8669+
}
8670+
86628671
$reqSet = null;
8663-
$reqVerSet = null;
8672+
$reqVerSet = null;
86648673

86658674
$loop2do=count($itemSet);
86668675
for($idx=0; $idx < $loop2do; $idx++) {
86678676

86688677
$reqID = $itemSet[$idx]['req_id'];
86698678
$reqVerID = $itemSet[$idx]['req_version_id'];
86708679

8671-
if( isset($mappings['req'][$reqID]) ) {
8672-
$reqSet[$idx] = $mappings['req'][$reqID];
8673-
$reqVerSet[$idx] = $mappings['req_version'][$reqVerID];
8680+
//Ticket-8687: check if $reqID is in LUT created above and make use of it in case
8681+
if( isset($lut[$reqID]) ) {
8682+
$ind=$lut[$reqID];
8683+
$reqSet[$idx] = $mappings[$ind]['req'][$reqID];
8684+
$reqVerSet[$idx] = $mappings[$ind]['req_version'][$reqVerID];
86748685
} else {
86758686
$reqSet[$idx] = $reqID;
8676-
$reqVerSet[$idx] = $reqVerID;
8687+
$reqVerSet[$idx] = $reqVerID;
86778688
}
86788689

8679-
$reqIdCard = array('id' => $reqSet[$idx],
8690+
$reqIdCard = array('id' => $reqSet[$idx],
86808691
'version_id' => $reqVerSet[$idx]);
86818692
$reqMgr->assignReqVerToTCVer($reqIdCard, $dest, $userID);
86828693
}

0 commit comments

Comments
 (0)