/** * * */ private function exportTestSuiteDataToXML($container, $tproject_id, $tplan_id, $platform_id) { static $keywordMgr; static $getLastVersionOpt = array('output' => 'minimun'); static $tcaseMgr; static $tsuiteMgr; static $tcaseExportOptions; static $linkedItems; if (is_null($keywordMgr)) { $tcaseExportOptions = array('CFIELDS' => true, 'KEYWORDS' => true, 'EXEC_ORDER' => 0); $keywordMgr = new tlKeyword(); $tsuiteMgr = new testsuite($this->db); $linkedItems = $this->getLinkedItems($tplan_id); } $xmlTC = null; $cfXML = null; $kwXML = null; if (isset($container['id'])) { $kwMap = $tsuiteMgr->getKeywords($container['id']); if ($kwMap) { $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>"; } $cfMap = (array) $tsuiteMgr->get_linked_cfields_at_design($container['id'], null, null, $tproject_id); if (count($cfMap) > 0) { $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap); } $tsuiteData = $tsuiteMgr->get_by_id($container['id']); $xmlTC = "\n\t<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n\t\t<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>" . "\n\t\t<details><![CDATA[{$tsuiteData['details']}]]>" . "\n\t\t{$kwXML}{$cfXML}</details>"; } $childNodes = isset($container['childNodes']) ? $container['childNodes'] : null; if (!is_null($childNodes)) { $loop_qty = sizeof($childNodes); for ($idx = 0; $idx < $loop_qty; $idx++) { $cNode = $childNodes[$idx]; switch ($cNode['node_table']) { case 'testsuites': $xmlTC .= $this->exportTestSuiteDataToXML($cNode, $tproject_id, $tplan_id, $platform_id); break; case 'testcases': if (is_null($tcaseMgr)) { $tcaseMgr = new testcase($this->db); } // testcase::LATEST_VERSION, $tcaseExportOptions['EXEC_ORDER'] = $linkedItems[$cNode['id']][$platform_id]['node_order']; $xmlTC .= $tcaseMgr->exportTestCaseDataToXML($cNode['id'], $cNode['tcversion_id'], $tproject_id, testcase::NOXMLHEADER, $tcaseExportOptions); break; } } } if (isset($container['id'])) { $xmlTC .= "</testsuite>"; } return $xmlTC; }
/** * Return a TestSuite by ID * * @param * @param struct $args * @param string $args["devKey"] * @param int $args["testsuiteid"] * @return mixed $resultInfo * * @access public */ public function getTestSuiteByID($args) { $operation = __FUNCTION__; $msg_prefix = "({$operation}) - "; $this->_setArgs($args); $status_ok = $this->_runChecks(array('authenticate', 'checkTestSuiteID'), $msg_prefix); $details = 'simple'; $key2search = self::$detailsParamName; if ($this->_isParamPresent($key2search)) { $details = $this->args[$key2search]; } if ($status_ok && $this->userHasRight("mgt_view_tc", self::CHECK_PUBLIC_PRIVATE_ATTR)) { $testSuiteID = $this->args[self::$testSuiteIDParamName]; $tsuiteMgr = new testsuite($this->dbObj); return $tsuiteMgr->get_by_id($testSuiteID); } else { return $this->errors; } }
/** * */ function buildContentForTestPlanBranch(&$dbHandler, $itemsTree, $branchRoot, $tplanID, $platformIDSet, &$docInfo, $decode, &$tplanMgr, $options = null) { $linkedBy = array(); $branch_tsuites = null; $contentByPlatform = array(); $pnOptions = array('hideTestCases' => 0); $pnOptions = array_merge($pnOptions, (array) $options); $tsuite = new testsuite($dbHandler); $tInfo = $tsuite->get_by_id($branchRoot); $tInfo['node_type_id'] = $decode['node_descr_id']['testsuite']; $docInfo->title = htmlspecialchars(isset($tInfo['name']) ? $tInfo['name'] : $docInfo->testplan_name); $children_tsuites = $tsuite->tree_manager->get_subtree_list($branchRoot, $decode['node_descr_id']['testsuite']); if (!is_null($children_tsuites) and trim($children_tsuites) != "") { $branch_tsuites = explode(',', $children_tsuites); } $branch_tsuites[] = $branchRoot; $metrics = (object) array('estimatedExecTime' => null, 'realExecTime' => null); $filters = array('tsuites_id' => $branch_tsuites); foreach ($platformIDSet as $platform_id) { // IMPORTANTE NOTICE: // This need to be initialized on each iteration because prepareNode() make changes on it. $tInfo['childNodes'] = isset($itemsTree['childNodes']) ? $itemsTree['childNodes'] : null; $filters['platform_id'] = $platform_id; $metrics->estimatedExecTime[$platform_id] = null; $metrics->realExecTime[$platform_id] = null; $avalon = $tplanMgr->getLTCVNewGeneration($tplanID, $filters, array('addExecInfo' => true)); $k2l = array_keys($avalon); foreach ($k2l as $key) { $linkedBy[$platform_id][$key] = $avalon[$key][$platform_id]; } // After architecture changes on how CF design values for Test Cases are // managed, we need the test case version ID and not test case ID // In addition if we loop over Platforms we need to save this set each time!!! $items2loop = !is_null($linkedBy[$platform_id]) ? array_keys($linkedBy[$platform_id]) : null; if (!is_null($items2loop)) { foreach ($items2loop as $rdx) { $metrics->estimatedExecTime[$platform_id][] = $linkedBy[$platform_id][$rdx]['tcversion_id']; } } // Prepare Node -> pn $pnFilters = null; $dummy4reference = null; $contentByPlatform[$platform_id]['childNodes'] = array(); if (!is_null($linkedBy[$platform_id])) { prepareNode($dbHandler, $tInfo, $decode, $dummy4reference, $dummy4reference, $linkedBy[$platform_id], $pnFilters, $pnOptions); $contentByPlatform[$platform_id]['childNodes'] = array($tInfo); } } $metrics->realExecTime = $linkedBy; return array($contentByPlatform, $metrics); }
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); }
function renderTestSuiteNodeForPrinting(&$db, &$node, &$options, $tocPrefix, $level, $tplan_id, $tproject_id) { static $tsuite_mgr; $labels = array('test_suite' => lang_get('test_suite'), 'details' => lang_get('details')); $code = null; $name = isset($node['name']) ? htmlspecialchars($node['name']) : ''; $title_separator = config_get('gui_title_separator_1'); $cfields = array('design' => ''); $cfieldFormatting = array('table_css_style' => 'class="cf"'); $docHeadingNumbering = ''; if ($options['headerNumbering']) { $docHeadingNumbering = "{$tocPrefix}. "; } if ($options['toc']) { $spacing = $level == 2 && $tocPrefix != 1 ? "<br>" : ""; $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $level . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n"; $code .= "<a name='" . prefixToHTMLID($tocPrefix) . "'></a>\n"; } $docHeadingLevel = $level - 1; //we would like to have html top heading H1 - H6 $docHeadingLevel = $docHeadingLevel > 6 ? 6 : $docHeadingLevel; $code .= "<h{$docHeadingLevel} class='doclevel'>" . $docHeadingNumbering . $labels['test_suite'] . $title_separator . $name . "</h{$docHeadingLevel}>\n"; // ----- get Test Suite text ----------------- if ($options['header']) { if (!$tsuite_mgr) { $tsuite_mgr = new testsuite($db); } $tInfo = $tsuite_mgr->get_by_id($node['id']); if ($tInfo['details'] != '') { $code .= '<div>' . $tInfo['details'] . '</div>'; } // get Custom fields // Attention: for test suites custom fields can not be edited during execution, // then we need to get just custom fields with scope 'design' foreach ($cfields as $key => $value) { $cfields[$key] = $tsuite_mgr->html_table_of_custom_field_values($node['id'], $key, null, $tproject_id, $cfieldFormatting); if ($cfields[$key] != "") { $add_br = true; $code .= '<p>' . $cfields[$key] . '</p>'; } } } return $code; }
$tree['childNodes'] = null; } //@TODO:REFACTOR // prepareNode($db,$tree,$decoding_hash,$dummy,$dummy,$tp_tcs, // SHOW_TESTCASES,null,null,0,1,0); $dummy = null; $pnFilters = null; $pnOptions = array('hideTestCases' => 0, 'showTestCaseID' => 1, 'getExternalTestCaseID' => 0, 'ignoreInactiveTestCases' => 0); prepareNode($db, $tree, $decoding_hash, $dummy, $dummy, $tp_tcs, $pnFilters, $pnOptions); $treeForPlatform[$platform_id] = $tree; } break; case 'testsuite': foreach ($platforms as $platform_id => $platform_name) { $tsuite = new testsuite($db); $tInfo = $tsuite->get_by_id($args->itemID); $children_tsuites = $tree_manager->get_subtree_list($args->itemID, $hash_descr_id['testsuite']); if (!is_null($children_tsuites) and trim($children_tsuites) != "") { $branch_tsuites = explode(',', $children_tsuites); } $branch_tsuites[] = $args->itemID; $filters = array('tsuites_id' => $branch_tsuites, 'platform_id' => $platform_id); $tp_tcs = $tplan_mgr->get_linked_tcversions($args->tplan_id, $filters); $tcase_filter = !is_null($tp_tcs) ? array_keys((array) $tp_tcs) : null; $tInfo['node_type_id'] = $hash_descr_id['testsuite']; $tInfo['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null; //@TODO: schlundus, can we speed up with NO_EXTERNAL? $dummy = null; $pnFilters = null; $pnOptions = array('hideTestCases' => 0); // 3624
$do_display = 1; break; case 'doSavePlatforms': doSavePlatforms($args, $tplan_mgr); $do_display = 1; break; case 'doSaveCustomFields': doSaveCustomFields($args, $_REQUEST, $tplan_mgr, $tcase_mgr); $do_display = 1; break; default: break; } $smarty = new TLSmarty(); if ($do_display) { $tsuite_data = $tsuite_mgr->get_by_id($args->object_id); // This does filter on keywords ALWAYS in OR mode. // // CRITIC: // We have arrived after clicking in a node of Test Spec Tree where we have two classes of filters // 1. filters on attribute COMMON to all test case versions => TEST CASE attribute like keyword_id // 2. filters on attribute that can change on each test case version => execution type. // // For attributes at Version Level, filter is done ON LAST ACTIVE version, that can be NOT the VERSION // already linked to test plan. // This can produce same weird effects like this: // // 1. Test Suite A - create TC1 - Version 1 - exec type MANUAL // 2. Test Suite A - create TC2 - Version 1 - exec type AUTO // 3. Test Suite A - create TC3 - Version 1 - exec type MANUAL // 4. Use feature ADD/REMOVE test cases from test plan.
function processTestSuite(&$dbHandler, &$guiObj, &$argsObj, $testSet, &$treeMgr, &$tcaseMgr, &$docRepository) { $locationFilters = $tcaseMgr->buildCFLocationMap(); $cf_filters = array('show_on_execution' => 1); $tsuite_mgr = new testsuite($dbHandler); $tsuite_data = $tsuite_mgr->get_by_id($argsObj->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; $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); } 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); }
/** * * @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; }
$tcase_mgr = new testcase($db); $result = null; $keyword_assignment_subtitle = null; $can_do = 0; $itemID = null; $opt_cfg->global_lbl = ''; $opt_cfg->additional_global_lbl = null; $opt_cfg->from->lbl = lang_get('available_kword'); $opt_cfg->to->lbl = lang_get('assigned_kword'); $opt_cfg->from->map = $tproject_mgr->get_keywords_map($args->testproject_id); $opt_cfg->to->map = $tcase_mgr->get_keywords_map($args->id, " ORDER BY keyword ASC "); if ($args->edit == 'testsuite') { // We are going to walk all test suites contained // in the selected container, and assign/remove keywords on each test case. $tsuite_mgr = new testsuite($db); $testsuite = $tsuite_mgr->get_by_id($args->id); $keyword_assignment_subtitle = lang_get('test_suite') . TITLE_SEP . $testsuite['name']; $tcs = $tsuite_mgr->get_testcases_deep($args->id, 'only_id'); if (sizeof($tcs)) { $can_do = 1; if ($args->bAssignTestSuite) { $result = 'ok'; for ($i = 0; $i < sizeof($tcs); $i++) { $tcID = $tcs[$i]; $tcase_mgr->setKeywords($tcID, $args->keywordArray); } } $itemID = $tcs; } } else { if ($args->edit == 'testcase') {
function renderTestSuiteNodeForPrinting(&$db, &$node, $env, &$options, $context, $tocPrefix, $indentLevel) { static $tsuite_mgr; static $l10n; static $title_separator; static $cfieldFormatting; static $getOpt; if (is_null($l10n)) { $tsuite_mgr = new testsuite($db); $l10n = array('test_suite' => 'test_suite', 'details' => 'details', 'attached_files' => 'attached_files'); $l10n = init_labels($l10n); $title_separator = config_get('gui_title_separator_1'); $cfieldFormatting = array('table_css_style' => 'class="cf"'); $getOpt['getByID'] = array('fields' => ' TS.id,TS.details ', 'renderImageInline' => true); } $code = null; $name = isset($node['name']) ? htmlspecialchars($node['name']) : ''; $cfields = array('design' => ''); $docHeadingNumbering = $options['headerNumbering'] ? $tocPrefix . "." : ''; if ($options['toc']) { $spacing = $indentLevel == 2 && $tocPrefix != 1 ? "<br>" : ""; $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $indentLevel . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n"; $code .= "<a name='" . prefixToHTMLID($context['prefix']) . "'></a>\n"; } // we would like to have html top heading H1 - H6 $docHeadingLevel = $indentLevel - 1; // Remember that only H1 to H6 exists $docHeadingLevel = $docHeadingLevel > 6 ? 6 : $docHeadingLevel; $docHeadingLevel = $docHeadingLevel < 1 ? 1 : $docHeadingLevel; $code .= "<h{$docHeadingLevel} class='doclevel'>" . $docHeadingNumbering . $l10n['test_suite'] . $title_separator . $name . "</h{$docHeadingLevel}>\n"; // ----- get Test Suite text ----------------- if ($options['header']) { $tInfo = $tsuite_mgr->get_by_id($node['id'], $getOpt['getByID']); if ($tInfo['details'] != '') { $code .= '<div>' . $tInfo['details'] . '</div>'; } $tInfo = null; $attachSet = (array) $tsuite_mgr->getAttachmentInfos($node['id']); if (count($attachSet) > 0) { $code .= '<table><caption style="text-align:left;">' . $l10n['attached_files'] . '</caption>'; $code .= '<tr><td> </td>'; $code .= '<td><ul>'; foreach ($attachSet as $item) { $fname = ""; if ($item['title']) { $fname .= htmlspecialchars($item['title']) . " : "; } $fname .= htmlspecialchars($item['file_name']); $code .= "<li>{$fname}</li>"; if ($item['is_image']) { $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>'; } } $code .= "</ul></td></tr>"; $code .= "</table>"; } $attachSet = null; // get Custom fields // Attention: for test suites custom fields can not be edited during execution, // then we need to get just custom fields with scope 'design' foreach ($cfields as $key => $value) { $cfields[$key] = $tsuite_mgr->html_table_of_custom_field_values($node['id'], $key, null, $context['tproject_id'], $cfieldFormatting); if ($cfields[$key] != "") { $add_br = true; $code .= '<p>' . $cfields[$key] . '</p>'; } } $cfields = null; } return $code; }
function renderTestSuiteNodeForPrinting(&$db, &$node, $env, &$options, $context) { static $tsuite_mgr; static $labels; static $title_separator; static $cfieldFormatting; if (!is_null($labels)) { $labels = array('test_suite' => lang_get('test_suite'), 'details' => lang_get('details')); $title_separator = config_get('gui_title_separator_1'); $cfieldFormatting = array('table_css_style' => 'class="cf"'); } $code = null; $name = isset($node['name']) ? htmlspecialchars($node['name']) : ''; $cfields = array('design' => ''); $docHeadingNumbering = $options['headerNumbering'] ? $env->tocPrefix . "." : ''; if ($options['toc']) { $spacing = $context['level'] == 2 && $env->tocPrefix != 1 ? "<br>" : ""; $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $context['level'] . 'px;">' . '<a href="#' . prefixToHTMLID($env->tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n"; $code .= "<a name='" . prefixToHTMLID($context['prefix']) . "'></a>\n"; } $docHeadingLevel = $context['level'] - 1; //we would like to have html top heading H1 - H6 $docHeadingLevel = $docHeadingLevel > 6 ? 6 : $docHeadingLevel; $code .= "<h{$docHeadingLevel} class='doclevel'>" . $docHeadingNumbering . $labels['test_suite'] . $title_separator . $name . "</h{$docHeadingLevel}>\n"; // ----- get Test Suite text ----------------- if ($options['header']) { if (!$tsuite_mgr) { $tsuite_mgr = new testsuite($db); } $tInfo = $tsuite_mgr->get_by_id($node['id']); if ($tInfo['details'] != '') { $code .= '<div>' . $tInfo['details'] . '</div>'; } $attachSet = (array) $tsuite_mgr->getAttachmentInfos($node['id']); if (count($attachSet) > 0) { $code .= "<table>"; $code .= "<tr><td><span class=\"label\">" . $labels['attached_files'] . "</span></td><td><ul>"; foreach ($attachSet as $item) { $fname = ""; if ($item['title']) { $fname .= htmlspecialchars($item['title']) . " : "; } $fname .= htmlspecialchars($item['file_name']); $code .= "<li>{$fname}</li>"; if ($item['is_image']) { $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>'; } } $code .= "</ul></td></tr>"; $code .= "</table>"; } // get Custom fields // Attention: for test suites custom fields can not be edited during execution, // then we need to get just custom fields with scope 'design' foreach ($cfields as $key => $value) { $cfields[$key] = $tsuite_mgr->html_table_of_custom_field_values($node['id'], $key, null, $context['tproject_id'], $cfieldFormatting); if ($cfields[$key] != "") { $add_br = true; $code .= '<p>' . $cfields[$key] . '</p>'; } } } return $code; }
$tsuite_info = $tsuite_mgr->get_by_name($tsuite_name); new dBug($tsuite_info); die; $tsuite_id = 689; echo "<pre> testsuite - get_children(\$id)"; echo "</pre>"; echo "<pre> get_children({$tsuite_id})"; echo "</pre>"; $tsuite_info = $tsuite_mgr->get_children($tsuite_id); new dBug($tsuite_info); $tsuite_id = 676; echo "<pre> testsuite - get_by_id(\$id)"; echo "</pre>"; echo "<pre> get_by_id({$tsuite_id})"; echo "</pre>"; $tsuite_info = $tsuite_mgr->get_by_id($tsuite_id); new dBug($tsuite_info); $tsuite_name = $tsuite_info['name']; $tsuite_id = array(); $tsuite_id[] = 676; $tsuite_id[] = 804; $tsuite_id[] = 826; echo "<pre> testsuite - get_by_id(\$id)"; echo "</pre>"; echo "<pre> get_by_id({$tsuite_id})"; echo "</pre>"; $tsuite_info = $tsuite_mgr->get_by_id($tsuite_id); new dBug($tsuite_info); die; echo "<pre> testsuite - get_all()"; echo "</pre>";
/** * create a test suite * * @param struct $args * @param string $args["devKey"] * @param int $args["testprojectid"] * @param string $args["testsuitename"] * @param string $args["details"] * @param int $args["parentid"] optional, if do not provided means test suite must be top level. * @param int $args["order"] optional. Order inside parent container * @param int $args["checkduplicatedname"] optional, default true. * will check if there are siblings with same name. * * @param int $args["actiononduplicatedname"] optional * applicable only if $args["checkduplicatedname"]=true * what to do if already a sibling exists with same name. * * @return mixed $resultInfo */ public function createTestSuite($args) { $result = array(); $this->_setArgs($args); $operation = __FUNCTION__; $msg_prefix = "({$operation}) - "; $checkFunctions = array('authenticate', 'checkTestSuiteName', 'checkTestProjectID'); $status_ok = $this->_runChecks($checkFunctions, $msg_prefix) && $this->userHasRight("mgt_modify_tc"); if ($status_ok) { // Optional parameters $opt = array(self::$orderParamName => testsuite::DEFAULT_ORDER, self::$checkDuplicatedNameParamName => testsuite::CHECK_DUPLICATE_NAME, self::$actionOnDuplicatedNameParamName => 'block'); foreach ($opt as $key => $value) { if ($this->_isParamPresent($key)) { $opt[$key] = $this->args[$key]; } } } if ($status_ok) { $parent_id = $args[self::$testProjectIDParamName]; $tprojectInfo = $this->tprojectMgr->get_by_id($args[self::$testProjectIDParamName]); $tsuiteMgr = new testsuite($this->dbObj); if ($this->_isParamPresent(self::$parentIDParamName)) { $parent_id = $args[self::$parentIDParamName]; // if parentid exists it must: // be a test suite id $node_info = $tsuiteMgr->get_by_id($args[self::$parentIDParamName]); if (!($status_ok = !is_null($node_info))) { $msg = sprintf(INVALID_PARENT_TESTSUITEID_STR, $args[self::$parentIDParamName], $args[self::$testSuiteNameParamName]); $this->errors[] = new IXR_Error(INVALID_PARENT_TESTSUITEID, $msg_prefix . $msg); } if ($status_ok) { // Must belong to target test project $root_node_id = $tsuiteMgr->getTestProjectFromTestSuite($args[self::$parentIDParamName], null); if (!($status_ok = $root_node_id == $args[self::$testProjectIDParamName])) { $msg = sprintf(TESTSUITE_DONOTBELONGTO_TESTPROJECT_STR, $args[self::$parentIDParamName], $tprojectInfo['name'], $args[self::$testProjectIDParamName]); $this->errors[] = new IXR_Error(TESTSUITE_DONOTBELONGTO_TESTPROJECT, $msg_prefix . $msg); } } } } if ($status_ok) { $op = $tsuiteMgr->create($parent_id, $args[self::$testSuiteNameParamName], $args[self::$detailsParamName], $opt[self::$orderParamName], $opt[self::$checkDuplicatedNameParamName], $opt[self::$actionOnDuplicatedNameParamName]); if ($status_ok = $op['status_ok']) { $op['status'] = $op['status_ok'] ? true : false; $op['operation'] = $operation; $op['additionalInfo'] = ''; $op['message'] = $op['msg']; unset($op['msg']); unset($op['status_ok']); $result[] = $op; } else { $op['msg'] = sprintf($op['msg'], $args[self::$testSuiteNameParamName]); $this->errors = $op; } } return $status_ok ? $result : $this->errors; }