function initializeGUI(&$dbHandler, $argsObj) { $gui = new stdClass(); $gui->tc_id = $argsObj->tcase_id; $gui->compare_selected_versions = $argsObj->compare_selected_versions; $gui->context = $argsObj->context; $tcaseMgr = new testcase($dbHandler); $gui->tc_versions = $tcaseMgr->get_by_id($argsObj->tcase_id); $gui->tcaseName = $gui->tc_versions[0]['name']; unset($tcaseMgr); $lblkeys = array('num_changes' => null, 'no_changes' => null, 'version_short' => null, 'diff_subtitle_tc' => null); $gui->labels = init_labels($lblkeys); $gui->version_short = $gui->labels['version_short']; $gui->subtitle = sprintf($gui->labels['diff_subtitle_tc'], $argsObj->version_left, $argsObj->version_left, $argsObj->version_right, $argsObj->version_right, $gui->tcaseName); $gui->leftID = "v{$argsObj->version_left}"; $gui->rightID = "v{$argsObj->version_right}"; return $gui; }
* 20100124 - franciscom - BUGID 3064 - add logic to manage ONLY ACTIVE test plans **/ require_once "../../config.inc.php"; require_once "common.php"; testlinkInitPage($db); $templateCfg = templateConfiguration(); $tcase_mgr = new testcase($db); $tplan_mgr = new testplan($db); $tproject_mgr = new testproject($db); $glue = config_get('testcase_cfg')->glue_character; $args = init_args(); $gui = initializeGui($args); $getOpt = array('outputFormat' => 'map', 'addIfNull' => true); $gui->platformSet = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt); $options['output'] = 'essential'; $tcase_all_info = $tcase_mgr->get_by_id($args->tcase_id, testcase::ALL_VERSIONS, null, $options); if (!is_null($tcase_all_info)) { foreach ($tcase_all_info as $tcversion_info) { if ($tcversion_info['id'] == $args->tcversion_id) { $version = $tcversion_info['version']; $gui->pageTitle = lang_get('test_case') . ':' . $tcversion_info['name']; $gui->tcaseIdentity = $tproject_mgr->getTestCasePrefix($args->tproject_id); $gui->tcaseIdentity .= $glue . $tcversion_info['tc_external_id'] . ':' . $tcversion_info['name']; break; } } } // 20100514 - franciscom // Why I'm filter on NOT_EXECUTED ??? -> this causes BUGID 3189 // $link_info = $tcase_mgr->get_linked_versions($args->tcase_id,'NOT_EXECUTED'); $link_info = $tcase_mgr->get_linked_versions($args->tcase_id);
$gui->page_title = lang_get('title_tsuite_export'); $gui->export_filename = 'testsuites.xml'; if ($node_id == $args->tproject_id) { $gui->page_title = lang_get('title_tsuite_export_all'); $gui->export_filename = 'all_testsuites.xml'; $check_children = 1; $gui->nothing_todo_msg = lang_get('no_testsuites_to_export'); } } else { // Exporting situations: // All test cases in test suite. // One test case. $exporting_just_one_tc = $args->tcase_id && $args->tcversion_id; if ($exporting_just_one_tc) { $objMgr = new testcase($db); $dummy = $objMgr->get_by_id($args->tcase_id, testcase::ALL_VERSIONS, null, array('output' => 'essential')); $ext = $objMgr->getExternalID($args->tcase_id, $args->tproject_id); $gui->export_filename = 'testcase-' . $ext[0] . '-' . $dummy[0]['name']; $node_id = $args->tcase_id; $gui->page_title = lang_get('title_tc_export'); } else { $dummy = $tree_mgr->get_node_hierarchy_info($args->container_id); $gui->export_filename = $dummy['name'] . '-children-testcases'; $gui->page_title = lang_get('title_tc_export_all'); $check_children = 1; $gui->nothing_todo_msg = lang_get('no_testcases_to_export'); } $gui->export_filename = str_replace(' ', '-', $gui->export_filename) . '.xml'; } $gui->export_filename = is_null($args->export_filename) ? $gui->export_filename : $args->export_filename; if ($check_children) {
* @internal Revisions: * 20091109 - franciscom - BUGID 0002937: add/remove test case hover over test case * tooltip replacement with summary */ require_once '../../config.inc.php'; require_once 'common.php'; testlinkInitPage($db); // BUGID 4066 - take care of proper escaping when magic_quotes_gpc is enabled $_REQUEST = strings_stripSlashes($_REQUEST); $tcase_mgr = new testcase($db); $tcase_id = isset($_REQUEST['tcase_id']) ? $_REQUEST['tcase_id'] : null; $tcversion_id = isset($_REQUEST['tcversion_id']) ? $_REQUEST['tcversion_id'] : 0; $info = ''; if (!is_null($tcase_id)) { if ($tcversion_id > 0) { $tcase = $tcase_mgr->get_by_id($tcase_id, $tcversion_id); if (!is_null($tcase)) { $tcase = $tcase[0]; } } else { $tcase = $tcase_mgr->get_last_version_info($tcase_id); } $info = $tcase['summary']; // <p> and </p> tag at the beginning and the end of summary cause visualization // errors -> remove them and add <br> to get a similar effect $info = str_replace("<p>", "", $info); $info = str_replace("</p>", "<br>", $info); if ($info == "") { $info = lang_get("empty_tc_summary"); } }
/** * get test case specification using external ir internal id * * @param struct $args * @param string $args["devKey"] * @param int $args["testcaseid"]: optional, if does not is present * testcaseexternalid must be present * * @param int $args["testcaseexternalid"]: optional, if does not is present * testcaseid must be present * @param int $args["version"]: optional, if does not is present max version number will be * retuned * * @return mixed $resultInfo */ public function getTestCase($args) { $msg_prefix = "(" . __FUNCTION__ . ") - "; $status_ok = true; $this->_setArgs($args); $checkFunctions = array('authenticate', 'checkTestCaseIdentity'); $status_ok = $this->_runChecks($checkFunctions, $msg_prefix); // && // $this->userHasRight("mgt_view_tc",self::CHECK_PUBLIC_PRIVATE_ATTR); $version_id = testcase::LATEST_VERSION; $version_number = -1; if ($status_ok) { // check optional arguments if ($this->_isParamPresent(self::$versionNumberParamName)) { if ($status_ok = $this->checkTestCaseVersionNumber()) { $version_id = null; $version_number = $this->args[self::$versionNumberParamName]; } } } if ($status_ok) { $testCaseMgr = new testcase($this->dbObj); $id = $this->args[self::$testCaseIDParamName]; // $result = $testCaseMgr->get_by_id($id,$version_id,'ALL','ALL',$version_number); $filters = array('active_status' => 'ALL', 'open_status' => 'ALL', 'version_number' => $version_number); $result = $testCaseMgr->get_by_id($id, $version_id, $filters); // return $result; if (0 == sizeof($result)) { $status_ok = false; $this->errors[] = new IXR_ERROR(NO_TESTCASE_FOUND, $msg_prefix . NO_TESTCASE_FOUND_STR); return $this->errors; } else { if (isset($this->args[self::$testCaseExternalIDParamName])) { $result[0]['full_tc_external_id'] = $this->args[self::$testCaseExternalIDParamName]; } else { $dummy = $this->tcaseMgr->getPrefix($id); $result[0]['full_tc_external_id'] = $dummy[0] . config_get('testcase_cfg')->glue_character . $result[0]['tc_external_id']; } } } if ($status_ok) { // before returning info need to understand if test case belongs to a test project // accessible to user requesting info // return $result[0]['id']; $this->args[self::$testProjectIDParamName] = $this->tcaseMgr->get_testproject($result[0]['id']); $status_ok = $this->userHasRight("mgt_view_tc", self::CHECK_PUBLIC_PRIVATE_ATTR); } return $status_ok ? $result : $this->errors; }
/** * get test case specification using external ir internal id * * @param struct $args * @param string $args["devKey"] * @param int $args["testcaseid"]: optional, if does not is present * testcaseexternalid must be present * * @param int $args["testcaseexternalid"]: optional, if does not is present * testcaseid must be present * @param int $args["version"]: optional, if does not is present max version number will be * retuned * * @return mixed $resultInfo */ public function getTestCase($args) { $msg_prefix = "(" . __FUNCTION__ . ") - "; $status_ok = true; $this->_setArgs($args); $checkFunctions = array('authenticate', 'checkTestCaseIdentity'); $status_ok = $this->_runChecks($checkFunctions, $msg_prefix) && $this->userHasRight("mgt_view_tc"); $version_id = testcase::LATEST_VERSION; $version_number = -1; if ($status_ok) { // check optional arguments if ($this->_isParamPresent(self::$versionNumberParamName)) { if ($status_ok = $this->checkTestCaseVersionNumber()) { $version_id = null; $version_number = $this->args[self::$versionNumberParamName]; } } } if ($status_ok) { $testCaseMgr = new testcase($this->dbObj); $id = $this->args[self::$testCaseIDParamName]; $result = $testCaseMgr->get_by_id($id, $version_id, 'ALL', 'ALL', $version_number); if (0 == sizeof($result)) { $status_ok = false; $this->errors[] = new IXR_ERROR(NO_TESTCASE_FOUND, $msg_prefix . NO_TESTCASE_FOUND_STR); return $this->errors; } } return $status_ok ? $result : $this->errors; }
/** * processTestCase * */ function processTestCase(&$dbHandler, &$argsObj, &$guiObj) { $tproject_mgr = new testproject($dbHandler); $guiObj->arrReqSpec = $tproject_mgr->genComboReqSpec($argsObj->tproject_id, 'dotted', " "); $SRS_qty = count($guiObj->arrReqSpec); if ($SRS_qty > 0) { $tc_mgr = new testcase($dbHandler); $arrTc = $tc_mgr->get_by_id($argsObj->id); if ($arrTc) { $guiObj->tcTitle = $arrTc[0]['name']; // get first ReqSpec if not defined if (is_null($argsObj->idReqSpec)) { reset($guiObj->arrReqSpec); $argsObj->idReqSpec = key($guiObj->arrReqSpec); } if ($argsObj->idReqSpec) { $req_spec_mgr = new requirement_spec_mgr($dbHandler); $guiObj->arrAssignedReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec, 'assigned', $argsObj->id); if (!is_null($guiObj->arrAssignedReq)) { $xc = $req_spec_mgr->getAssignedCoverage($argsObj->idReqSpec); $l2d = count($guiObj->arrAssignedReq); for ($xdx = 0; $xdx < $l2d; $xdx++) { $guiObj->arrAssignedReq[$xdx]['coverageAuthor'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['login']; $guiObj->arrAssignedReq[$xdx]['coverageTS'] = $xc[$guiObj->arrAssignedReq[$xdx]['id']]['creation_ts']; } } $guiObj->arrAllReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec); $guiObj->arrUnassignedReq = array_diff_byId($guiObj->arrAllReq, $guiObj->arrAssignedReq); } } } return $guiObj; }
// SELECT MAX(version) AS version, NH_TCVERSION.parent_id AS id FROM tcversions TCV // JOIN nodes_hierarchy NH_TCVERSION ON NH_TCVERSION.id = TCV.id AND TCV.active=1 // AND NH_TCVERSION.parent_id IN () GROUP BY NH_TCVERSION.parent_id ORDER BY NH_TCVERSION.parent_id , -1) called at [C:\usr\local\xampp-1.7.2\xampp\htdocs\head-20100315\lib\functions\database.class.php:593] // #1 database->fetchRowsIntoMap(/* Class:testcase - Method: get_last_active_version // $old_article = file_get_contents('./old_article.txt'); // $new_article = $_REQUEST['article']; /* Let's say that someone pasted a new article to html form */ // // $diff = xdiff_string_diff($old_article, $new_article, 1); // if (is_string($diff)) { // echo "Differences between two articles:\n"; // echo $diff; // } $version_a = 1; $version_b = 2; $tcase_id = 88; $va = $tcase_mgr->get_by_id($tcase_id, null, 'ALL', 'ALL', $version_a); $vb = $tcase_mgr->get_by_id($tcase_id, null, 'ALL', 'ALL', $version_b); new dBug($va); new dBug($vb); $diff = xdiff_string_diff($va[0]['summary'], $vb[0]['summary'], 1); echo "Differences between two articles:\n"; echo $diff; die; // getByPathName // function getByPathName($pathName,$pathSeparator='::') $pathName = 'ZATHURA::Holodeck::Apollo 10 Simulation::Unload::Full speed unload'; $fname = 'getByPathName'; echo "<pre> testcase - {$fname}(\$pathName,\$pathSeparator='::')"; echo "</pre>"; echo "<pre> {$fname}({$pathName})"; echo "</pre>";
/** * */ function renderExecutionForPrinting(&$dbHandler, $baseHref, $id, $userObj = null) { static $tprojectMgr; static $tcaseMgr; static $st; $out = ''; if (!$st) { $st = new stdClass(); $st->tables = tlDBObject::getDBTables(array('executions', 'builds')); $tprojectMgr = new testproject($dbHandler); $tcaseMgr = new testcase($dbHandler); } $sql = " SELECT E.id AS execution_id, E.status, E.execution_ts, E.tester_id," . " E.notes, E.build_id, E.tcversion_id,E.tcversion_number,E.testplan_id," . " E.platform_id,E.execution_duration, " . " B.name AS build_name, B.id AS build_id " . " FROM {$st->tables['executions']} E " . " JOIN {$st->tables['builds']} B ON B.id = E.build_id " . " WHERE E.id = " . intval($id); $exec_info = $dbHandler->get_recordset($sql); if (!is_null($exec_info)) { $exec_info = $exec_info[0]; $context['exec_id'] = intval($id); $context['tplan_id'] = $exec_info['testplan_id']; $context['platform_id'] = $exec_info['platform_id']; $context['build_id'] = $exec_info['build_id']; $context['level'] = '??'; // ??? $node = $tprojectMgr->tree_manager->get_node_hierarchy_info($context['tplan_id']); $context['prefix'] = $tprojectMgr->getTestCasePrefix($node['parent_id']); $context['tproject_id'] = $node['parent_id']; unset($tprojectMgr); // IMPORTANT DEVELOPMENT NOTICE // Remember that on executions table we have following fields // // testplan_id // tcversion_id // tcversion_number // // a. (testplan_id ,tcversion_id) ARE LINK To testplan_tcversions table // b. if user creates a new version of a LINKED AND EXECUTED test case // when he/she updates test plan, ONLY tcversion_id is updated, // while tcversion_number HAS ALWAYS the VERSION HUMAN READABLE NUMBER // of executed version. // // Then if you want to access specification of executed test case version // you need to proceed this way // 1. with tcversion_id => get test case id // 2. using test case id AND tcversion_number you access the data. // // Why is important to remember this? // Because here we need to get data for renderTestCaseForPrinting // // The Cinematic Orchestra: To build a home Incubus: Wish you were here Mau Mau: La ola $node = $tcaseMgr->tree_manager->get_node_hierarchy_info($exec_info['tcversion_id']); // get_by_id($id,$version_id = self::ALL_VERSIONS, $filters = null, $options=null) $tcase = $tcaseMgr->get_by_id($node['parent_id'], null, array('version_number' => $exec_info['tcversion_number'])); $renderOptions = array('toc' => 0, 'body' => 1, 'summary' => 1, 'header' => 0, 'headerNumbering' => 0, 'passfail' => 1, 'author' => 1, 'notes' => 1, 'requirement' => 1, 'keyword' => 1, 'cfields' => 1, 'displayVersion' => 1, 'displayDates' => 1, 'docType' => SINGLE_TESTCASE, 'importance' => 1, 'step_exec_notes' => 1, 'step_exec_status' => 1); // need to change keys $tcase = $tcase[0]; $tcase['tcversion_id'] = $tcase['id']; $tcase['id'] = $node['parent_id']; $env = new stdClass(); $env->base_href = $baseHref; $env->reportType = $renderOptions['docType']; $indentLevel = 100000; $context['user'] = $userObj; $out .= renderTestCaseForPrinting($dbHandler, $tcase, $renderOptions, $env, $context, $indentLevel); $out .= '<br>' . lang_get('direct_link') . ':' . $env->base_href . 'lnl.php?type=exec&id=' . intval($id) . '<br>'; $exec_info = null; } return $out; }
$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') { $can_do = 1; $tcData = $tcase_mgr->get_by_id($args->id); if (sizeof($tcData)) { $tcData = $tcData[0]; $keyword_assignment_subtitle = lang_get('test_case') . TITLE_SEP . $tcData['name']; } if ($args->bAssignTestCase) { $result = 'ok'; $tcase_mgr->setKeywords($args->id, $args->keywordArray); $itemID = $args->id; } } } if ($itemID) { $opt_cfg->to->map = $tcase_mgr->get_keywords_map($itemID, " ORDER BY keyword ASC "); } keywords_opt_transf_cfg($opt_cfg, $args->keywordList);
$gui->page_title = lang_get('title_tsuite_export'); $dummy = '.testsuite-deep.xml'; if ($node_id == $args->tproject_id) { $gui->page_title = lang_get('title_tsuite_export_all'); $dummy = '.testproject-deep.xml'; $check_children = 1; $gui->nothing_todo_msg = lang_get('no_testsuites_to_export'); } $gui->export_filename .= $dummy; } else { // Exporting situations: // All test cases in test suite. // One test case. if ($gui->oneTestCaseExport) { $tcase_mgr = new testcase($db); $tcinfo = $tcase_mgr->get_by_id($args->tcase_id, $args->tcversion_id, null, array('output' => 'essential')); $tcinfo = $tcinfo[0]; $node_id = $args->tcase_id; $gui->export_filename = $tcinfo['name'] . '.version' . $tcinfo['version'] . '.testcase.xml'; $gui->page_title = lang_get('title_tc_export'); } else { $check_children = 1; $node_info = $tree_mgr->get_node_hierarchy_info($args->container_id); $gui->export_filename = $node_info['name'] . '.testsuite-children-testcases.xml'; $gui->page_title = lang_get('title_tc_export_all'); $gui->nothing_todo_msg = lang_get('no_testcases_to_export'); } } $gui->export_filename = is_null($args->export_filename) ? $gui->export_filename : $args->export_filename; if ($check_children) { // Check if there is something to export
* * Compares selected testcase versions with each other. * * @internal Revisions: */ require_once "../../config.inc.php"; require_once "common.php"; require '../../third_party/diff/diff.php'; $templateCfg = templateConfiguration(); testlinkInitPage($db); $smarty = new TLSmarty(); $differ = new diff(); $args = init_args(); $gui = new stdClass(); $tcaseMgr = new testcase($db); $tcaseSet = $tcaseMgr->get_by_id($args->tcase_id); $gui->tc_versions = $tcaseSet; $gui->tc_id = $args->tcase_id; $gui->compare_selected_versions = $args->compare_selected_versions; $gui->context = $args->context; $gui->version_short = lang_get('version_short'); $labels = array(); $labels["num_changes"] = lang_get("num_changes"); $labels["no_changes"] = lang_get("no_changes"); //if already two versions are selected, display diff //else display template with versions to select if ($args->compare_selected_versions) { $diff_array = array("summary" => array(), "preconditions" => array()); foreach ($tcaseSet as $tcase) { if ($tcase['version'] == $args->version_left) { $left = $tcase;
require_once "common.php"; testlinkInitPage($db, false, false, "checkRights"); $templateCfg = templateConfiguration(); $testcase_cfg = config_get('testcase_cfg'); $tree_mgr = new tree($db); $tsuite_mgr = new testsuite($db); $tplan_mgr = new testplan($db); $tcase_mgr = new testcase($db); $args = init_args(); $gui = new stdClass(); $gui->can_manage_testplans = $_SESSION['currentUser']->hasRight($db, "mgt_testplan_create"); $gui->tplans = array(); $gui->show_details = 0; $gui->user_feedback = ''; $gui->tcasePrefix = $tcase_mgr->tproject_mgr->getTestCasePrefix($args->tproject_id) . $testcase_cfg->glue_character; $tplan_info = $tcase_mgr->get_by_id($args->tplan_id); $gui->tplan_name = $tplan_info['name']; $gui->tplan_id = $args->tplan_id; $gui->tproject_name = $args->tproject_name; // $linked_tcases = $tplan_mgr->get_linked_tcversions($args->tplan_id); $linked_tcases = $tplan_mgr->get_linked_items_id($args->tplan_id); $qty_linked = count($linked_tcases); $gui->testcases = $tplan_mgr->get_linked_and_newest_tcversions($args->tplan_id); if ($qty_linked) { $qty_newest = count($gui->testcases); if ($qty_newest) { $gui->show_details = 1; // get path $tcaseSet = array_keys($gui->testcases); $path_info = $tree_mgr->get_full_path_verbose($tcaseSet); foreach ($gui->testcases as $tcase_id => $value) {
/** * processTestCase * */ function processTestCase(&$dbHandler, &$argsObj, &$guiObj) { $tproject_mgr = new testproject($dbHandler); // $guiObj->arrReqSpec = $tproject_mgr->getOptionReqSpec($argsObj->tproject_id,testproject::GET_NOT_EMPTY_REQSPEC); $guiObj->arrReqSpec = $tproject_mgr->genComboReqSpec($argsObj->tproject_id); $SRS_qty = count($guiObj->arrReqSpec); if ($SRS_qty > 0) { $tc_mgr = new testcase($dbHandler); $arrTc = $tc_mgr->get_by_id($argsObj->id); if ($arrTc) { $guiObj->tcTitle = $arrTc[0]['name']; // get first ReqSpec if not defined if (is_null($argsObj->idReqSpec)) { reset($guiObj->arrReqSpec); $argsObj->idReqSpec = key($guiObj->arrReqSpec); } if ($argsObj->idReqSpec) { $req_spec_mgr = new requirement_spec_mgr($dbHandler); $guiObj->arrAssignedReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec, 'assigned', $argsObj->id); $guiObj->arrAllReq = $req_spec_mgr->get_requirements($argsObj->idReqSpec); $guiObj->arrUnassignedReq = array_diff_byId($guiObj->arrAllReq, $guiObj->arrAssignedReq); } } } return $guiObj; }
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellID, $field); $cellAreaEnd = $cellRange[$zdx]; } $cellArea .= "{$cellAreaEnd}{$startingRow}"; $objPHPExcel->getActiveSheet()->getStyle($cellArea)->applyFromArray($styleDataHeader); $startingRow++; break; } $qta_loops = count($gui->matrix); $target = array("<p>", "</p>", "<br />", "<br>"); $replace = array("", "", "", ""); // $startingRow $cellArea = "A{$startingRow}:"; for ($idx = 0; $idx < $qta_loops; $idx++) { // get pulp $item = $tcaseMgr->get_by_id(null, $gui->matrix[$idx]['tcversionid']); $item = $item[0]; // make a big text with steps and expected results if (!is_null($item['steps'])) { $stepBlob = ''; $resBlob = ''; $qta_steps = count($item['steps']); $initial = ''; for ($sdx = 0; $sdx < $qta_steps; $sdx++) { $dummy = str_replace($target, $replace, $item['steps'][$sdx]['actions']); $stepBlob .= $initial . '#' . $item['steps'][$sdx]['step_number'] . "\n" . $dummy . "\n"; $dummy = trim($item['steps'][$sdx]['expected_results']); $dummy = $dummy == '' ? 'N/A' : $dummy; $dummy = str_replace($target, $replace, $dummy); $resBlob .= $initial . '#' . $item['steps'][$sdx]['step_number'] . "\n" . $dummy . "\n"; $initial = "\n";