MantisBT - TestLink
View Issue Details
0008687TestLinkRequirement to Test Case Assignmentpublic2019-06-11 08:112019-11-10 12:06
heju 
 
normalmajoralways
newopen 
 
 
mysql
0008687: Create TestProject from old project modifies source project test case assignments
Dear TestLink Team,

observed in 1.9.20.
When copying a test project (create, create from existing), the copied test cases are assigned to the source requirement instead of the newly created requirement.
The created duplicate requirement in the new project has no test case assigned.
Create req and test case, assign to each other.
Copy the project and check the requriement- tc assignments in new and old project.
No tags attached.
Issue History
2019-06-11 08:11hejuNew Issue
2019-06-11 18:08fmanNote Added: 0028926
2019-06-16 09:12hejuNote Added: 0028952
2019-11-01 17:36hejuNote Added: 0029280
2019-11-10 12:04hejuNote Added: 0029288
2019-11-10 12:06hejuNote Edited: 0029288bug_revision_view_page.php?bugnote_id=29288#r5968

Notes
(0028926)
fman   
2019-06-11 18:08   
thanks, I'm going to check

IMPORTANT thing is : from 1.9.18 and up RELATIONS is between REQ VERSION AND TEST CASE VERSION
(0028952)
heju   
2019-06-16 09:12   
Tried again with a fresh database & install, confirming this still happens.

The created duplicate test cases link to the source requirements.
(0029280)
heju   
2019-11-01 17:36   
Dear TestLink team,

I would like to kindly ask if this issue can be reproduced on your side.
In case not I need to further investigate why this happens on my end, maybe some problem in the data base(?)

Thank you in advance!
(0029288)
heju   
2019-11-10 12:04   
(edited on: 2019-11-10 12:06)
Dear fman,

I did some debugging on this one and wanted to share, maybe it helps to fix this.

In testcase.class.php::copyReqVersionLinksTo: Line 8647
The $mappings are checked by:

if( isset($mappings['req'][$reqID]) ) {

It turns out this is always false as the content of $mappings at this point while test project copy is:
$mappings:
array (size=1)
  0 =>
    array (size=5)
      604 => int 1008
      'req_spec' =>
        array (size=0)
          empty
      'req' =>
        array (size=1)
          654 => int 1010
      'req_version' =>
        array (size=1)
          655 => int 1011
      'req_tree' =>
        array (size=1)
          654 =>
            array (size=1)
              ...

I think $mappings[0]['req'][$reqID] instead of $mappings['req'][$reqID] would point to the needed data.

The "zero" array holding all the other data is created in testproject.class.php::copy_requirements::line2948

$mappings[] = $op['mappings'];

I wans't quite sure if this "zero" array holding all the data is needed at all, therefore I tried to replace this line by:
$mappings = $op['mappings'];
Now the test project copy function assigns the tcases to the reqs as expected.

Is this the correct fix, or is the "zero" array needed and this fix causes side effects?