@@ -43,6 +43,7 @@ class testplan extends tlObjectWithAttachments
4343 var $ assignment_mgr ;
4444 var $ cfield_mgr ;
4545 var $ tcase_mgr ;
46+ var $ tproject_mgr ;
4647
4748 var $ assignment_types ;
4849 var $ assignment_status ;
@@ -89,6 +90,8 @@ function __construct(&$db)
8990 $ this ->cfield_mgr = new cfield_mgr ($ this ->db );
9091 $ this ->tcase_mgr = New testcase ($ this ->db );
9192 $ this ->platform_mgr = new tlPlatform ($ this ->db );
93+ $ this ->tproject_mgr = new testproject ($ this ->db );
94+
9295
9396 $ this ->resultsCfg = config_get ('results ' );
9497 $ this ->tcaseCfg = config_get ('testcase_cfg ' );
@@ -165,14 +168,24 @@ function createFromObject($item,$opt=null) {
165168
166169 // what checks need to be done ?
167170 // 1. test project exist
168- $ pinfo = $ this ->tree_manager ->get_node_hierarchy_info ($ item ->testProjectID );
169- if (is_null ($ pinfo ) || $ this ->node_types_id_descr [$ pinfo ['node_type_id ' ]] != 'testproject ' ) {
171+ $ pinfo = null ;
172+ if ( is_numeric ($ item ->testProjectID ) ) {
173+ $ pinfo = $ this ->tproject_mgr ->get_by_id (intval ($ item ->testProjectID ));
174+ }
175+
176+ if ( null == $ pinfo || count ($ pinfo ) == 0 ) {
177+ $ pinfo = $ this ->tproject_mgr ->get_by_prefix ($ item ->testProjectID );
178+ }
179+
180+ if ( is_null ($ pinfo ) || count ($ pinfo ) == 0 ) {
170181 throw new Exception ('Test project ID does not exist ' );
171182 }
172183
184+ $ tproject_id = intval ($ pinfo ['id ' ]);
185+
173186 // 2. there is NO other test plan on test project with same name
174187 $ name = trim ($ item ->name );
175- $ op = $ this ->checkNameExistence ($ name ,$ item -> testProjectID );
188+ $ op = $ this ->checkNameExistence ($ name ,$ tproject_id );
176189 if (!$ op ['status_ok ' ]) {
177190 throw new Exception ('Test plan name is already in use on Test project ' );
178191 }
@@ -186,12 +199,13 @@ function createFromObject($item,$opt=null) {
186199
187200 $ api_key = md5 (rand ()) . md5 (rand ());
188201
189- $ id = $ this ->tree_manager ->new_node ($ item -> testProjectID ,$ this ->node_types_descr_id ['testplan ' ],$ name );
202+ $ id = $ this ->tree_manager ->new_node ($ tproject_id ,$ this ->node_types_descr_id ['testplan ' ],$ name );
190203 $ sql = "/* $ debugMsg */ " .
191204 " INSERT INTO {$ this ->tables ['testplans ' ]} (id,notes,api_key,testproject_id,active,is_public) " .
192205 " VALUES ( {$ id } " . ", ' " . $ this ->db ->prepare_string ($ item ->notes ) . "', " .
193206 "' " . $ this ->db ->prepare_string ($ api_key ) . "', " .
194- $ item ->testProjectID . ", " . $ active_status . ", " . $ public_status . ") " ;
207+ $ tproject_id . ", " .
208+ $ active_status . ", " . $ public_status . ") " ;
195209 $ result = $ this ->db ->exec_query ($ sql );
196210 return $ result ? $ id : 0 ;
197211 }
@@ -3953,38 +3967,38 @@ private function exportTestSuiteDataToXML($container,$tproject_id,$tplan_id,$pla
39533967 }
39543968 // testcase::LATEST_VERSION,
39553969 $ tcaseExportOptions ['EXEC_ORDER ' ] = $ linkedItems [$ cNode ['id ' ]][$ platform_id ]['node_order ' ];
3956-
3957- $ filter_lv = array ( 'exec_status ' => 'ALL ' , 'active_status ' => 'ALL ' ,'tplan_id ' => $ tplan_id , 'platform_id ' => $ platform_id );
3958- $ output_lv = array ( 'output ' => 'simple ' );
3959- // get tc versions linked in current testplan for current platform
3960- $ info = $ tcaseMgr ->get_linked_versions ($ cNode ['id ' ],$ filter_lv ,$ output_lv );
3961- if ( !is_null ($ info ) )
3962- {
3963- $ tcversID = key ($ info );
3964- }
3965-
3966- // get users assigned to tc version in current testplan for the current build
3967- $ versionAssignInfo = $ tcaseMgr ->get_version_exec_assignment ($ tcversID , $ tplan_id , $ build_id );
3968- $ userList = array ();
3969- // extract user names
3970- if (!is_null ($ versionAssignInfo ))
3971- {
3972- foreach ($ versionAssignInfo [$ tcversID ][$ platform_id ] as $ vaInfo )
3973- {
3974- $ assignedTesterId = intval ($ vaInfo ['user_id ' ]);
3975- if ($ assignedTesterId )
3976- {
3977- $ user = tlUser::getByID ($ this ->db ,$ assignedTesterId );
3978- if ($ user )
3979- {
3980- $ userList [] = $ user ->getDisplayName ();
3981- }
3982- }
3983- }
3984- }
3985- (count ($ userList ) > 0 ) ? $ tcaseExportOptions ['ASSIGNED_USER ' ] = $ userList : $ tcaseExportOptions ['ASSIGNED_USER ' ] = null ;
3986-
3987- $ xmlTC .= $ tcaseMgr ->exportTestCaseDataToXML ($ cNode ['id ' ],$ cNode ['tcversion_id ' ],
3970+
3971+ $ filter_lv = array ( 'exec_status ' => 'ALL ' , 'active_status ' => 'ALL ' ,'tplan_id ' => $ tplan_id , 'platform_id ' => $ platform_id );
3972+ $ output_lv = array ( 'output ' => 'simple ' );
3973+ // get tc versions linked in current testplan for current platform
3974+ $ info = $ tcaseMgr ->get_linked_versions ($ cNode ['id ' ],$ filter_lv ,$ output_lv );
3975+ if ( !is_null ($ info ) )
3976+ {
3977+ $ tcversID = key ($ info );
3978+ }
3979+
3980+ // get users assigned to tc version in current testplan for the current build
3981+ $ versionAssignInfo = $ tcaseMgr ->get_version_exec_assignment ($ tcversID , $ tplan_id , $ build_id );
3982+ $ userList = array ();
3983+ // extract user names
3984+ if (!is_null ($ versionAssignInfo ))
3985+ {
3986+ foreach ($ versionAssignInfo [$ tcversID ][$ platform_id ] as $ vaInfo )
3987+ {
3988+ $ assignedTesterId = intval ($ vaInfo ['user_id ' ]);
3989+ if ($ assignedTesterId )
3990+ {
3991+ $ user = tlUser::getByID ($ this ->db ,$ assignedTesterId );
3992+ if ($ user )
3993+ {
3994+ $ userList [] = $ user ->getDisplayName ();
3995+ }
3996+ }
3997+ }
3998+ }
3999+ (count ($ userList ) > 0 ) ? $ tcaseExportOptions ['ASSIGNED_USER ' ] = $ userList : $ tcaseExportOptions ['ASSIGNED_USER ' ] = null ;
4000+
4001+ $ xmlTC .= $ tcaseMgr ->exportTestCaseDataToXML ($ cNode ['id ' ],$ cNode ['tcversion_id ' ],
39884002 $ tproject_id ,testcase::NOXMLHEADER ,
39894003 $ tcaseExportOptions );
39904004 break ;
0 commit comments