function processTestSuite(&$dbHandler, &$guiObj, &$argsObj, $linked_tcversions, &$treeMgr, &$tcaseMgr, &$docRepository) { $locationFilters = $tcaseMgr->buildCFLocationMap(); $testSet = new stdClass(); $cf_filters = array('show_on_execution' => 1); // BUGID 1650 (REQ) $tsuite_mgr = new testsuite($dbHandler); $tsuite_data = $tsuite_mgr->get_by_id($argsObj->id); $opt = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1); // @TODO - 20090815 - franciscom // why here we do not have filtered by tester ? // same for platform_id $filters = array('keywords' => $argsObj->keyword_id); $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $argsObj->id, $tsuite_data['name'], $linked_tcversions, null, $filters, $opt); $testSet->tcase_id = array(); $testSet->tcversion_id = array(); foreach ($out['spec_view'] as $key => $value) { if (count($value['testcases']) > 0) { foreach ($value['testcases'] as $xkey => $xvalue) { $testSet->tcase_id[] = $xkey; $testSet->tcversion_id[] = $xvalue['linked_version_id']; } } } // --------------------------------------------------------------------------------- // Get the path for every test case, grouping test cases that have same parent. $testCaseQty = count($testSet->tcase_id); if ($testCaseQty > 0) { $dummy = $tcaseMgr->cfield_mgr->getLocations(); $verboseLocationCode = array_flip($dummy['testcase']); $filters = null; foreach ($verboseLocationCode as $key => $value) { $filters[$key]['location'] = $value; } $dummy_id = current($testSet->tcase_id); $index = $testCaseQty == 1 ? $dummy_id : 0; // 0 => BULK $suffix = '_' . $index; $execution_time_cfields = $tcaseMgr->html_table_of_custom_field_inputs($dummy_id, $argsObj->tproject_id, 'execution', $suffix, null, null, $argsObj->tproject_id); $guiObj->execution_time_cfields[$index] = $execution_time_cfields; $gdx = 0; foreach ($testSet->tcase_id as $testcase_id) { $path_f = $treeMgr->get_path($testcase_id, null, 'full'); foreach ($path_f as $key => $path_elem) { if ($path_elem['parent_id'] == $argsObj->id) { // Can be added because is present in the branch the user wants to view // ID of branch starting node is in $argsObj->id $guiObj->tcAttachments[$testcase_id] = getAttachmentInfos($docRepository, $testcase_id, 'nodes_hierarchy', true, 1); foreach ($locationFilters as $locationKey => $filterValue) { $finalFilters = $cf_filters + $filterValue; // // BUGID 3431 - Custom Field values at Test Case VERSION Level // $guiObj->design_time_cfields[$testcase_id][$locationKey] = // $tcaseMgr->html_table_of_custom_field_values($testcase_id,'design',$finalFilters); $guiObj->design_time_cfields[$testcase_id][$locationKey] = $tcaseMgr->html_table_of_custom_field_values($testcase_id, 'design', $finalFilters, null, null, $argsObj->tproject_id, null, $testSet->tcversion_id[$gdx]); $guiObj->testplan_design_time_cfields[$testcase_id] = $tcaseMgr->html_table_of_custom_field_values($testcase_id, 'testplan_design', $cf_filters, null, null, $argsObj->tproject_id); } // BUGID 856: Guest user can execute test case if ($guiObj->grants->execute) { $guiObj->execution_time_cfields[$testcase_id] = $tcaseMgr->html_table_of_custom_field_inputs($testcase_id, null, 'execution', "_" . $testcase_id, null, null, $argsObj->tproject_id); } } // if( $path_elem['parent_id'] == $argsObj->id ) // We do this because do not know if some test case not yet analised will be direct // child of this test suite, then we get this info in advance. // In situations where only last test suite on branch have test cases, we are colleting // info we will never use. if ($path_elem['node_table'] == 'testsuites' && !isset($guiObj->tSuiteAttachments[$path_elem['id']])) { $guiObj->tSuiteAttachments[$path_elem['id']] = getAttachmentInfos($docRepository, $path_elem['id'], 'nodes_hierarchy', true, 1); } } //foreach($path_f as $key => $path_elem) $gdx++; } } return array($testSet->tcase_id, $testSet->tcversion_id); }
$assignment_mgr->deleteBySignature($signature); break; } switch ($args->level) { case 'testcase': // build the data need to call gen_spec_view $xx = $tcase_mgr->getPathLayered(array($args->id)); $yy = array_keys($xx); // done to silence warning on end() $tsuite_data['id'] = end($yy); $tsuite_data['name'] = $xx[$tsuite_data['id']]['value']; $xx = $tplan_mgr->getLinkInfo($args->tplan_id, $args->id, $args->control_panel['setting_platform'], array('output' => 'assignment_info', 'build4assignment' => $args->build_id)); $linked_items[$args->id] = $xx; $opt = array('write_button_only_if_linked' => 1, 'user_assignments_per_build' => $args->build_id, 'useOptionalArrayFields' => true); $filters = array('keywords' => $keywordsFilter->items, 'testcases' => $args->id); $my_out = gen_spec_view($db, 'testplan', $args->tplan_id, $tsuite_data['id'], $tsuite_data['name'], $linked_items, null, $filters, $opt); // index 0 contains data for the parent test suite of this test case, // other elements are not needed. $out = array(); $out['spec_view'][0] = $my_out['spec_view'][0]; $out['num_tc'] = 1; break; case 'testsuite': $filters = array(); $filters['keywordsFilter'] = $keywordsFilter; $filters['testcaseFilter'] = isset($args->testcases_to_show) ? $args->testcases_to_show : null; $filters['assignedToFilter'] = property_exists($args, 'filter_assigned_to') ? $args->filter_assigned_to : null; $filters['executionTypeFilter'] = $args->control_panel['filter_execution_type']; $filters['cfieldsFilter'] = $args->control_panel['filter_custom_fields']; // ORDER IS CRITIC - Attention in refactoring $opt = array('assigned_on_build' => $args->build_id, 'addPriority' => true, 'addExecInfo' => false);
} if ($gui->has_tc = !is_null($uncovered) && count($uncovered) > 0) { // Get external ID $testSet = array_keys($uncovered); $inClause = implode(',', $testSet); $debugMsg = 'File: ' . basename(__FILE__) . ' - Line: ' . __LINE__ . ' - '; $sql = "/* {$debugMsg} */ " . " SELECT distinct NHA.id AS tc_id, TCV.tc_external_id " . " FROM {$tables['nodes_hierarchy']} NHA, " . " {$tables['nodes_hierarchy']} NHB, " . " {$tables['tcversions']} TCV, {$tables['node_types']} NT " . " WHERE NHA.node_type_id=NT.id AND NHA.id=NHB.parent_id AND NHB.id=TCV.id " . " AND NHA.id IN ({$inClause}) AND NT.description='testcase' "; $external_id = $db->fetchRowsIntoMap($sql, 'tc_id'); foreach ($external_id as $key => $value) { $uncovered[$key]['external_id'] = $value['tc_external_id']; } // $out = gen_spec_view($db,'uncoveredtestcases',$args->tproject_id,$args->tproject_id,null, // $uncovered,null,null,$testSet,1,0,0); $opt = array('write_button_only_if_linked' => 1); $filters = array('testcases' => $testSet); $out = gen_spec_view($db, 'uncoveredtestcases', $args->tproject_id, $args->tproject_id, null, $uncovered, null, $filters, $opt); $gui->items = $out['spec_view']; } $tcase_cfg = config_get('testcase_cfg'); $gui->pageTitle = lang_get('report_testcases_without_requirement'); $gui->testCasePrefix = $tproject_mgr->getTestCasePrefix($args->tproject_id); $gui->testCasePrefix .= $tcase_cfg->glue_character; $smarty = new TLSmarty(); $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $templateCfg->default_template); function init_args() { $args = new stdClass(); $args->tproject_id = isset($_SESSION['testprojectID']) ? $_SESSION['testprojectID'] : 0; $args->tproject_name = isset($_SESSION['testprojectName']) ? $_SESSION['testprojectName'] : ''; return $args;
if (!is_null($keywordsFilter)) { // With this pieces we implement the AND type of keyword filter. $keywordsTestCases = $tproject_mgr->get_keywords_tcases($args->tproject_id, $keywordsFilter->items, $keywordsFilter->type); if (sizeof($keywordsTestCases)) { $testCaseSet = array_keys($keywordsTestCases); } } // Choose enable/disable display of custom fields, analysing if this kind of custom fields // exists on this test project. $cfields = $tsuite_mgr->cfield_mgr->get_linked_cfields_at_testplan_design($args->tproject_id, 1, 'testcase'); $opt = array('write_button_only_if_linked' => 0, 'add_custom_fields' => 0); $opt['add_custom_fields'] = count($cfields) > 0 ? 1 : 0; // 20101025 - BUGID 3889: Add Test Cases to Test plan - Right pane does not honor custom field filter // 20100411 - BUGID 2797 - filter by test case execution type $filters = array('keywords' => $args->keyword_id, 'testcases' => $testCaseSet, 'exec_type' => $args->executionType, 'importance' => $args->importance, 'cfields' => $args->control_panel['filter_custom_fields'], 'tcase_name' => $args->control_panel['filter_testcase_name']); $out = gen_spec_view($db, 'testPlanLinking', $args->tproject_id, $args->object_id, $tsuite_data['name'], $tplan_linked_tcversions, null, $filters, $opt); $gui->has_tc = $out['num_tc'] > 0 ? 1 : 0; $gui->items = $out['spec_view']; $gui->has_linked_items = $out['has_linked_items']; $gui->add_custom_fields = $opt['add_custom_fields']; $gui->drawSavePlatformsButton = false; $gui->drawSaveCFieldsButton = false; if (!is_null($gui->items)) { initDrawSaveButtons($gui); } // This has to be done ONLY AFTER has all data needed => after gen_spec_view() call setAdditionalGuiData($gui); // 20100927 - asimon - refresh tree only when action is done switch ($args->doAction) { case 'doReorder': case 'doSavePlatforms':
/** * * @internal revisions: * 20100721 - asimon - BUGID 3406 - added $options for new user assignments per build * 20100218 - asimon - BUGID 3026 - added parameter $testcaseFilter to include functionality * previously used on tc_exec_assignment.php * to show only testcases present in filter argument * */ function keywordFilteredSpecView(&$dbHandler, &$argsObj, $keywordsFilter, &$tplanMgr, &$tcaseMgr, $testcaseFilter = null, $options = null) { $tsuiteMgr = new testsuite($dbHandler); $tprojectMgr = new testproject($dbHandler); $tsuite_data = $tsuiteMgr->get_by_id($argsObj->id); $filterAssignedTo = property_exists($argsObj, 'filter_assigned_to') ? $argsObj->filter_assigned_to : null; // 3406 // $ua_build = !is_null($options) && isset($options['user_assignments_per_build']) ? // $options['user_assignments_per_build'] : null; // @TODO - 20081019 // Really understand differences between: // $argsObj->keyword_id and $keywordsFilter // BUGID 1041 $filters = array('keyword_id' => $argsObj->keyword_id, 'assigned_to' => $filterAssignedTo); // 20100715 - asimon - why the double writing to $tplan_linked_tcversions? // will be overwritten again two lines below // $tplan_linked_tcversions = $tplanMgr->get_linked_tcversions($argsObj->tplan_id, $filters, $options); // This does filter on keywords ALWAYS in OR mode. // 3406: added $options $tplan_linked_tcversions = getFilteredLinkedVersions($argsObj, $tplanMgr, $tcaseMgr, $options); // With this pieces we implement the AND type of keyword filter. $testCaseSet = null; if (!is_null($keywordsFilter) && !is_null($keywordsFilter->items)) { $keywordsTestCases = $tprojectMgr->get_keywords_tcases($argsObj->tproject_id, $keywordsFilter->items, $keywordsFilter->type); $testCaseSet = array_keys($keywordsTestCases); } // BUGID 3026 - added $testcaseFilter if (!is_null($testCaseSet) && !is_null($testcaseFilter)) { $testCaseSet = array_intersect($testCaseSet, array($testcaseFilter)); } else { if (is_null($testCaseSet) && !is_null($testcaseFilter)) { $testCaseSet = $testcaseFilter; } } // now get values as keys // 20100722 - asimon - additional check here because of warning from array_combine when $testCaseSet is null //$testCaseSet = array_combine($testCaseSet, $testCaseSet); $testCaseSet = !is_null($testCaseSet) ? array_combine($testCaseSet, $testCaseSet) : null; // function gen_spec_view(&$db,$spec_view_type='testproject',$tobj_id,$id,$name,&$linked_items, // $map_node_tccount,$filters=null, $options = null,$tproject_id = null) // // 3406 $options = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1) + (array) $options; $filters = array('keywords' => $argsObj->keyword_id, 'testcases' => $testCaseSet); $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $argsObj->id, $tsuite_data['name'], $tplan_linked_tcversions, null, $filters, $options); return $out; }
/** * * */ function processTestCase(&$dbHandler, &$argsObj, $keywordsFilter, &$tplanMgr) { $my_path = $tplanMgr->tree_manager->get_path($argsObj->id); $idx_ts = count($my_path) - 1; $tsuite_data = $my_path[$idx_ts - 1]; $filters = array('tcase_id' => $argsObj->id); $opt = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1); $dummy_items = $tplanMgr->get_linked_tcversions($argsObj->tplan_id, $filters); // 20100131 - franciscom // adapt data structure to gen_spec_view() desires $linked_items[key($dummy_items)][0] = current($dummy_items); $filters = array('keywords' => $argsObj->keyword_id, 'testcases' => $argsObj->id); $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $tsuite_data['id'], $tsuite_data['name'], $linked_items, null, $filters, $opt); return $out; }
/** * * @param obj $dbHandler * @param obj $argsObj: user input * @param obj $argsObj: user input * @param obj $tplanMgr: test plan manager * @param obj $tcaseMgr: test case manager * @param map $filters: keys keywordsFilter, testcaseFilter,assignedToFilter, * executionTypeFilter, cfieldsFilter * * IMPORTANT NOTICE: not all filters are here, other arrive via argsObj * @param map $options: keys ?? * USED TO PASS options to other method called here -> see these method docs. * * @internal revisions * */ function getFilteredSpecView(&$dbHandler, &$argsObj, &$tplanMgr, &$tcaseMgr, $filters = null, $options = null) { $tprojectMgr = new testproject($dbHandler); $tsuite_data = $tcaseMgr->tree_manager->get_node_hierarchy_info($argsObj->id); $my = array(); // some sort of local scope $my['filters'] = array('keywordsFilter' => null, 'testcaseFilter' => null, 'assignedToFilter' => null, 'executionTypeFilter' => null); $my['filters'] = array_merge($my['filters'], (array) $filters); $my['options'] = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1); $my['options'] = array_merge($my['options'], (array) $options); // This does filter on keywords ALWAYS in OR mode. $tplan_linked_tcversions = getFilteredLinkedVersions($dbHandler, $argsObj, $tplanMgr, $tcaseMgr, $options); // With these pieces we implement the AND type of keyword filter. $testCaseSet = null; $tryNextFilter = true; $filterApplied = false; if (!is_null($my['filters']['keywordsFilter']) && !is_null($my['filters']['keywordsFilter']->items)) { $keywordsTestCases = $tprojectMgr->get_keywords_tcases($argsObj->tproject_id, $my['filters']['keywordsFilter']->items, $my['filters']['keywordsFilter']->type); $testCaseSet = array_keys((array) $keywordsTestCases); $tryNextFilter = !is_null($testCaseSet); $filterApplied = true; } if ($tryNextFilter && !is_null($my['filters']['testcaseFilter'])) { $filterApplied = true; if (is_null($testCaseSet)) { $testCaseSet = $my['filters']['testcaseFilter']; } else { // wrong use of array() instead of (array) $testCaseSet = array_intersect($testCaseSet, (array) $my['filters']['testcaseFilter']); } } // when $testCaseSet is null because we have applied filters => we do not need to call other // method because we know we are going to get NOTHING $testCaseSet = !is_null($testCaseSet) ? array_combine($testCaseSet, $testCaseSet) : null; if ($filterApplied && is_null($testCaseSet)) { return null; } $genSpecFilters = array('keywords' => $argsObj->keyword_id, 'testcases' => $testCaseSet, 'exec_type' => $my['filters']['executionTypeFilter'], 'cfields' => null); if (isset($my['filters']['cfieldsFilter'])) { $genSpecFilters['cfields'] = $my['filters']['cfieldsFilter']; } $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $argsObj->id, $tsuite_data['name'], $tplan_linked_tcversions, null, $genSpecFilters, $my['options']); return $out; }
/** * * */ function processTestCase(&$dbHandler, &$argsObj, $keywordsFilter, &$tplanMgr, &$treeMgr) { $xx = $tplanMgr->getLinkInfo($argsObj->tplan_id, $argsObj->id, null, array('output' => 'tcase_info', 'collapse' => true)); $linked_items[$xx['tc_id']][0] = $xx; // adapt data structure to gen_spec_view() desires $my_path = $treeMgr->get_path($argsObj->id); $idx_ts = count($my_path) - 1; $tsuite_data = $my_path[$idx_ts - 1]; // Again here need to understand why we seems to consider ONLY keywords filter. $filters = array('keywords' => $argsObj->keyword_id, 'testcases' => $argsObj->id); $opt = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1); $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $tsuite_data['id'], $tsuite_data['name'], $linked_items, null, $filters, $opt); // need new processing tideUpForGUI($out); return $out; }
/** * * @param obj $dbHandler * @param obj $argsObj: user input * @param obj $argsObj: user input * @param obj $tplanMgr: test plan manager * @param obj $tcaseMgr: test case manager * @param map $filters: keys keywordsFilter, testcaseFilter,assignedToFilter, * executionTypeFilter, cfieldsFilter * * IMPORTANT NOTICE: not all filters are here, other arrive via argsObj * @param map $options: keys ?? * USED TO PASS options to other method called here -> see these method docs. * * @internal revisions: * * 20101024 - franciscom - name changed because was misleading, this do lot of filters * interface changed. * * 20100721 - asimon - BUGID 3406 - added $options for new user assignments per build * 20100218 - asimon - BUGID 3026 - added parameter $testcaseFilter to include functionality * previously used on tc_exec_assignment.php * to show only testcases present in filter argument * */ function getFilteredSpecView(&$dbHandler, &$argsObj, &$tplanMgr, &$tcaseMgr, $filters = null, $options = null) { $tprojectMgr = new testproject($dbHandler); $tsuite_data = $tcaseMgr->tree_manager->get_node_hierarchy_info($argsObj->id); $my = array(); // some sort of local scope $my['filters'] = array('keywordsFilter' => null, 'testcaseFilter' => null, 'assignedToFilter' => null, 'executionTypeFilter' => null); $my['filters'] = array_merge($my['filters'], (array) $filters); $my['options'] = array('write_button_only_if_linked' => 1, 'prune_unlinked_tcversions' => 1); $my['options'] = array_merge($my['options'], (array) $options); // This does filter on keywords ALWAYS in OR mode. // BUGID 3406: added $options $tplan_linked_tcversions = getFilteredLinkedVersions($argsObj, $tplanMgr, $tcaseMgr, $options); // With these pieces we implement the AND type of keyword filter. $testCaseSet = null; if (!is_null($my['filters']['keywordsFilter']) && !is_null($my['filters']['keywordsFilter']->items)) { $keywordsTestCases = $tprojectMgr->get_keywords_tcases($argsObj->tproject_id, $my['filters']['keywordsFilter']->items, $my['filters']['keywordsFilter']->type); $testCaseSet = array_keys($keywordsTestCases); } // BUGID 3026 - added $testcaseFilter if (!is_null($my['filters']['testcaseFilter'])) { if (is_null($testCaseSet)) { $testCaseSet = $my['filters']['testcaseFilter']; } else { $testCaseSet = array_intersect($testCaseSet, array($my['filters']['testcaseFilter'])); } } // now get values as keys // 20100722 - asimon - additional check here because of warning from array_combine when $testCaseSet is null $testCaseSet = !is_null($testCaseSet) ? array_combine($testCaseSet, $testCaseSet) : null; // BUGID 3406 // BUGID 3936: Assign Test Case Execution - Right pane does not reflect custom field filter. $genSpecFilters = array('keywords' => $argsObj->keyword_id, 'testcases' => $testCaseSet, 'exec_type' => $my['filters']['executionTypeFilter'], 'cfields' => $my['filters']['cfieldsFilter']); $out = gen_spec_view($dbHandler, 'testplan', $argsObj->tplan_id, $argsObj->id, $tsuite_data['name'], $tplan_linked_tcversions, null, $genSpecFilters, $my['options']); return $out; }