function edit(&$argsObj) { $guiObj = new stdClass(); $dummy = $this->milestone_mgr->get_by_id($argsObj->id); $guiObj->milestone = $dummy[$argsObj->id]; // $dummyy necessary because localize_dateOrTimeStamp wants second parameter to be passed by reference $dummy = null; // localize target date (is always set on edit) $guiObj->milestone['target_date'] = localize_dateOrTimeStamp(null, $dummy, 'date_format', $guiObj->milestone['target_date']); // as start date is optional it can be "0000-00-00" (default timestamp) if ($guiObj->milestone['start_date'] != "0000-00-00") { $guiObj->milestone['start_date'] = localize_dateOrTimeStamp(null, $dummy, 'date_format', $guiObj->milestone['start_date']); } else { $guiObj->milestone['start_date'] = ""; } $guiObj->main_descr = lang_get('testplan') . TITLE_SEP; $guiObj->action_descr = sprintf(lang_get('edit_milestone'), $guiObj->milestone['name']); $guiObj->template = $this->defaultTemplate; $guiObj->submit_button_label = $this->submit_button_label; return $guiObj; }
$op = doDelete($args, $build_mgr); break; case 'do_update': $op = doUpdate($args, $build_mgr, $tplan_mgr, $date_format_cfg); $of->Value = $op->notes; $templateCfg->template = $op->template; break; case 'do_create': $op = doCreate($args, $build_mgr, $tplan_mgr, $date_format_cfg); $of->Value = $op->notes; $templateCfg->template = $op->template; break; } // BUGID 3716 $dummy = null; $gui->release_date = isset($op->status_ok) && $op->status_ok && $args->release_date != "" ? localize_dateOrTimeStamp(null, $dummy, 'date_format', $args->release_date) : $args->release_date_original; $gui->closed_on_date = $args->closed_on_date; $gui->operation_descr = $op->operation_descr; $gui->user_feedback = $op->user_feedback; $gui->buttonCfg = $op->buttonCfg; $gui->mgt_view_events = $_SESSION['currentUser']->hasRight($db, "mgt_view_events", $args->tproject_id, $args->tplan_id); $gui->editorType = $editorCfg['type']; $smarty = new TLSmarty(); renderGui($smarty, $args, $tplan_mgr, $templateCfg, $of, $gui); /* * INITialize page ARGuments, using the $_REQUEST and $_SESSION * super-global hashes. * Important: changes in HTML input elements on the Smarty template * must be reflected here. * *
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions * 20121017 - asimon - TICKET 5288 - print priority when printing test plan */ function renderTestCaseForPrinting(&$db, &$node, &$options, $level, $context) { static $req_mgr; static $tc_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; static $force = null; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; // init static elements // tplan_id = 0, // $prefix = null, $tprojectID = 0, $platform_id = 0) if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr); if (!is_null($context->prefix)) { $tcase_prefix = $context->prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; } $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); $versionID = isset($node['tcversion_id']) ? intval($node['tcversion_id']) : testcase::LATEST_VERSION; $tcInfo = $tc_mgr->get_by_id($id, $versionID); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); // ----- BUGID 3451 and related --------------------------------------- // asimon: I finally found the real problem here: // $versionID was used in the following "dirty" SQL statement, but was still set to "-1" //(the value to load all tc versions) instead of a real testcase version ID. $versionID = $tcInfo['id']; // This still does not change the fact that this marked SQL statement below // should be removed and replaced by existing functions. $cfields = array('specScope' => null, 'execScope' => null); // get custom fields that has specification scope if ($options['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } foreach ($locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $context->tplan_id, $context->tproject_id, $cfieldFormatting, $tcInfo['id']); } } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getExecutions = false; if ($options["docType"] != DOC_TEST_SPEC && $options["docType"] != SINGLE_TESTCASE) { $getExecutions = $options['cfields'] || $options['passfail']; } if ($getExecutions) { $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," . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON E.build_id= B.id " . " WHERE E.tcversion_id = {$versionID} " . " AND E.testplan_id = {$context->tplan_id} " . " AND E.platform_id = {$context->platform_id} " . " ORDER BY execution_id DESC"; echo $sql; $exec_info = $db->get_recordset($sql, null, 1); } // Added condition for the display on/off of the custom fields on test cases. if ($options['cfields'] && !is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $context->tplan_id, $context->tproject_id, $cfieldFormatting); } if ($options['toc']) { $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $table_style = 'style="margin-left: 0;"'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td></tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>' . '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; switch ($tcInfo['execution_type']) { case testcase::EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case testcase::EXECUTION_TYPE_MANUAL: $code .= $labels['execution_type_manual']; break; default: $code .= lang_get('execution_type_custom_' . $tcInfo['execution_type']); break; } $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['status'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['text_status_labels'][$tcInfo['status']]; $code .= "</td></tr>\n"; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_execution_duration']; $code .= "</td></tr>\n"; // TICKET 5288 - print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($options['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes']); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC if ($options['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $code .= "</table>\n</div>\n"; return $code; }
/** * * */ function buildExtTable($gui, $show_icon, $charset) { $table = null; if (count($gui->events) > 0) { $columns = array(); $columns[] = array('title' => lang_get('th_timestamp'), 'width' => 15); $columns[] = array('title' => lang_get('th_loglevel'), 'width' => 15); $columns[] = array('title' => lang_get('th_user'), 'width' => 15); $columns[] = array('title' => lang_get('th_event_description'), 'type' => 'text'); $columns[] = array('title' => lang_get('th_transaction'), 'width' => 15, 'hidden' => 'true'); // Extract the relevant data and build a matrix $matrixData = array(); foreach ($gui->events as $event_key => $event) { $transactionID = $event->transactionID; $rowData = array(); // necessary as localize_dateOrTimeStamp expects 2nd parameter to pass by reference $dummy = null; // use html comment to sort properly by timestamp $rowData[] = "<!--{$event->timestamp}-->" . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $event->timestamp); $rowData[] = $event->getlogLevel(); if (isset($event->userID)) { $rowData[] = $gui->users[$event->userID]; } else { $rowData[] = ""; } $rowData[] = "<a onClick=\"showEventDetails({$event->dbID});\" style=\"cursor: hand; cursor: pointer;\">" . "<img title=\"" . lang_get("show_eventdetails") . "\" src=\"{$show_icon}\" /> </a>" . htmlentities($event->description, ENT_QUOTES, $charset); $rowData[] = $event->transactionID; $matrixData[] = $rowData; } $table = new tlExtTable($columns, $matrixData, 'tl_table_eventviewer'); $table->addCustomBehaviour('text', array('render' => 'columnWrap')); $table->setGroupByColumnName(lang_get('th_loglevel')); $table->setSortByColumnName(lang_get('th_timestamp')); $table->sortDirection = 'DESC'; $table->showToolbar = true; $table->toolbarExpandCollapseGroupsButton = true; $table->toolbarShowAllColumnsButton = true; } return $table; }
/** * Add a time in smarty template (registered to Smarty class) * @uses localize_dateOrTimeStamp() */ function localize_timestamp_smarty($params, &$smarty) { return localize_dateOrTimeStamp($params, $smarty, 'timestamp_format', $params['ts']); }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions */ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context, $indentLevel) { static $req_mgr; static $tc_mgr; static $build_mgr; static $tplan_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $tables = null; static $force = null; static $bugInterfaceOn = false; static $its; static $buildCfields; static $statusL10N; static $docRepo; static $st; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; $level = $indentLevel; $prefix = isset($context['prefix']) ? $context['prefix'] : null; $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0; $build_id = isset($context['build_id']) ? $context['build_id'] : 0; // init static elements if (!$tables) { $st = new stdClass(); $tables = tlDBObject::getDBTables(array('executions', 'builds', 'execution_tcsteps')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); $build_mgr = new build_mgr($db); $tplan_mgr = new testplan($db); $req_mgr = new requirement_mgr($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; $its = null; $tproject_mgr = new testproject($db); $info = $tproject_mgr->get_by_id($tprojectID); $bugInterfaceOn = $info['issue_tracker_enabled']; if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($db); $its = $it_mgr->getInterfaceObject($tprojectID); unset($it_mgr); } $statusL10N = null; foreach ($cfg['results']['code_status'] as $vc => $vstat) { if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) { $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]); } } $docRepo = tlAttachmentRepository::create($db); $st->locationFilters = $tc_mgr->buildCFLocationMap(); // change table style in case of single TC printing to not be indented $st->table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $st->table_style = 'style="margin-left: 0;"'; } $st->cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '); $info = null; } /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getByID['filters'] = null; $opt = array(); $opt['step_exec_notes'] = isset($options['step_exec_notes']) && $options['step_exec_notes']; $opt['step_exec_status'] = isset($options['step_exec_status']) && $options['step_exec_status']; switch ($options["docType"]) { case DOC_TEST_SPEC: $getByID['tcversion_id'] = testcase::LATEST_VERSION; $getExecutions = false; break; case SINGLE_TESTCASE: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status']; break; default: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $opt['step_exec_notes'] || $opt['step_exec_status']; break; } if ($getExecutions) { // Thanks to Evelyn from Cortado, have found a very old issue never reported. // 1. create TC-1A VERSION 1 // 2. add to test plan and execute FAILED ON BUILD 1 // 3. Request Test Report (Test Plan EXECUTION REPORT). // You will get spec for VERSION 1 and result for VERSION 1 - OK cool! // 4. create VERSION 2 // 5. update linked Test Case Versions // 6. do nothing more than repeat step 3 // without this fix you will get // You will get spec for VERSION 2 and result for VERSION 1 - Hmmm // and in addition is not clear that execution was on VERSION 1 . No GOOD!! // // HOW has been fixed ? // Getting info about THE CURRENT LINKED test case version and looking for // exec info for this. // // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided // // // Get Linked test case version $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id); $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.execution_type, E.execution_duration, " . " B.name AS build_name " . " FROM {$tables['executions']} E " . " JOIN {$tables['builds']} B ON B.id = E.build_id " . " WHERE 1 = 1 "; if (isset($context['exec_id'])) { $sql .= " AND E.id=" . intval($context['exec_id']); } else { $sql .= " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']); if ($build_id > 0) { $sql .= " AND E.build_id = " . intval($build_id); } else { // We are looking for LATEST EXECUTION of CURRENT LINKED test case version $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']); } $sql .= " ORDER BY execution_id DESC"; } $exec_info = $db->get_recordset($sql, null, 1); $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id']; $getByID['filters'] = null; $linkedItem = null; if (!is_null($exec_info)) { $getByID['tcversion_id'] = null; $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']); if (isset($options['build_cfields']) && $options['build_cfields']) { if (!isset($buildCfields[$exec_info[0]['build_id']])) { $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID); } } } } $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true, 'renderImageInline' => true)); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); $cfields = array('specScope' => null, 'execScope' => null); if ($options['cfields']) { // Get custom fields that has specification scope // Custom Field values at Test Case VERSION Level foreach ($st->locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $st->cfieldFormatting, $tcInfo['id']); } if (!is_null($exec_info)) { $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($tcInfo['id'], 'execution', null, $exec_info[0]['execution_id'], $tplan_id, $tprojectID, $st->cfieldFormatting); } } if ($options['toc']) { // EXTERNAL ID added $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $st->table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version switch ($env->reportType) { case DOC_TEST_PLAN_DESIGN: $version_number = isset($node['version']) ? $node['version'] : $tcInfo['version']; break; case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $version_number = $tcInfo['version']; break; default: $version_number = $tcInfo['version']; break; } if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; } if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) { $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Check user rights in order to understand if can delete attachments here // function hasRight(&$db,$roleQuestion,$tprojectID = null,$tplanID = null,$getAccess=false) // $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; // $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $canManageAttachments = false; if (isset($context['user']) && !is_null($context['user'])) { $canManageAttachments = $context['user']->hasRight($db, 'testplan_execute', $tprojectID, $tplan_id); } // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if (!is_null($tcInfo[$key]) && $tcInfo[$key] != '') { $td_colspan = 3; $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>'; $sxni = null; if ($opt['step_exec_notes'] || $opt['step_exec_status']) { $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']); if ($opt['step_exec_notes']) { $td_colspan++; $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>'; } if ($opt['step_exec_status']) { $td_colspan++; $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>'; } } $code .= '</tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>'; $nike = !is_null($sxni) && isset($sxni[$tcInfo[$key][$ydx]['id']]) && !is_null($sxni[$tcInfo[$key][$ydx]['id']]); if ($opt['step_exec_notes']) { $code .= '<td>'; if ($nike) { $code .= $sxni[$tcInfo[$key][$ydx]['id']]['notes']; } $code .= '</td>'; } if ($opt['step_exec_status']) { $code .= '<td>'; if ($nike) { $code .= $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']]; } $code .= '</td>'; } $code .= '</tr>'; // Attachment management if ($getExecutions) { if (isset($sxni[$tcInfo[$key][$ydx]['id']])) { $attachInfo = getAttachmentInfos($docRepo, $sxni[$tcInfo[$key][$ydx]['id']]['id'], $tables['execution_tcsteps'], true, 1); if (!is_null($attachInfo)) { $code .= '<tr><td colspan="' . $td_colspan . '">'; $code .= '<b>' . $labels['exec_attachments'] . '</b><br>'; foreach ($attachInfo as $fitem) { $code .= '<form method="POST" name="fda' . $fitem['id'] . '" ' . ' id="fda' . $fitem['id'] . "' " . ' action="' . $env->base_href . 'lib/execute/execPrint.php">'; $code .= '<input type="hidden" name="id" value="' . intval($context['exec_id']) . '">'; $code .= '<input type="hidden" name="deleteAttachmentID" value="' . intval($fitem['id']) . '">'; if ($fitem['is_image']) { $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>"; $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '">'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a>'; } $code .= '<input type="image" alt="' . $labels['alt_delete_attachment'] . '"' . 'src="' . $env->base_href . TL_THEME_IMG_DIR . 'trash.png"></li></form>'; } $code .= '</td></tr>'; } } } // $getExecutions } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; // This is what have been choosen DURING DESIGN, but may be we can choose at DESIGN // manual and the execute AUTO, or may be choose AUTO and execute MANUAL. // After report on MANTIS, seems that we need to provide in output two values: // DESIGN execution type // EXECUTION execution type switch ($tcInfo['execution_type']) { case TESTCASE_EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case TESTCASE_EXECUTION_TYPE_MANUAL: default: $code .= $labels['execution_type_manual']; break; } $code .= "</td></tr>\n"; // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration']; $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // $cfields = null; $prio_info = null; // $code = null; // 20140813 $relSet = $tc_mgr->getRelations($id); if (!is_null($relSet['relations'])) { // $fx = str_repeat(' ',5); // MAGIC allowed $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['relations'] . '</span></td>'; $code .= '<td>'; for ($rdx = 0; $rdx < $relSet['num_relations']; $rdx++) { if ($relSet['relations'][$rdx]['source_id'] == $id) { $ak = 'source_localized'; } else { $ak = 'destination_localized'; } $code .= htmlspecialchars($relSet['relations'][$rdx][$ak]) . ' - ' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['fullExternalID']) . ':' . htmlspecialchars($relSet['relations'][$rdx]['related_tcase']['name']) . '<br>'; } $code .= '</td></tr>'; } $relSet = null; // collect REQ for TC if ($options['requirement']) { $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } $requirements = null; // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $kwSet = $tc_mgr->getKeywords($id, null, array('fields' => 'keyword_id,keywords.keyword')); if (sizeof($kwSet)) { foreach ($kwSet as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } $kwSet = null; // Attachments $attachSet = (array) $tc_mgr->getAttachmentInfos($id); if (count($attachSet) > 0) { $code .= '<tr><td> <span class="label">' . $labels['attached_files'] . '</span></td>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 2) . '"><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>"; } $attachSet = null; // generate test results data for test report if ($options['passfail']) { $tsp = $cfg['tableColspan'] - 1; $code .= '<tr style="' . "font-weight: bold;background: #EEE;text-align: left;" . '">' . '<td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['execution_details'] . '</td>' . '<td colspan="' . $tsp . '">' . " " . "</b></td></tr>\n"; $bn = ''; switch ($env->reportType) { case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $ib = $build_mgr->get_by_id($build_id); $bn = htmlspecialchars($ib['name']); break; case DOC_TEST_PLAN_EXECUTION: if ($exec_info) { $bn = htmlspecialchars($exec_info[0]['build_name']); } break; } if ($bn != '') { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['build'] . '</td>' . '<td ' . $tsp . '>' . $bn . "</b></td></tr>\n"; } if (isset($node['assigned_to'])) { $crew = explode(',', $node['assigned_to']); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . $labels['assigned_to'] . '</td>' . '<td colspan="' . $tsp . '">'; $xdx = 0; foreach ($crew as $mm) { if ($xdx != 0) { $code .= ','; } $xdx = -1; echo $mm . '<br>'; $code .= gendocGetUserName($db, $mm); } $code .= "</td></tr>\n"; } if ($exec_info) { $settings['cfg'] = $cfg; $settings['lbl'] = $labels; $settings['opt'] = array('show_notes' => $options['notes']); $settings['colspan'] = $cfg['tableColspan'] - 1; $code .= buildTestExecResults($db, $its, $exec_info, $settings, $buildCfields); // Get Execution Attachments $execAttachInfo = getAttachmentInfos($docRepo, $exec_info[0]['execution_id'], $tables['executions'], true, 1); if (!is_null($execAttachInfo)) { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">'; $code .= '<b>' . $labels['exec_attachments'] . '</b><br>'; foreach ($execAttachInfo as $fitem) { if ($fitem['is_image']) { $code .= "<li>" . htmlspecialchars($fitem['file_name']) . "</li>"; $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '"> </li>'; } else { $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $fitem['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($fitem['file_name']) . '</a></li>'; } } $code .= '</td></tr>'; } } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['report_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } $execAttachInfo = null; $exec_info = null; } $code .= "</table>\n</div>\n"; return $code; }
// buildExternalIdString($gui->tcasePrefix, $item['tc_external_id']) . // ' : ' . $item['tcase_name'] . '</a>'; $rowData[] = $item['tcversion_number']; if ($args->showPlatforms) { $rowData[] = $item['platform_name']; } $rowData[] = $item['build_name']; $rowData[] = $item['tester']; // use html comment to be able to sort table by timestamp and not by link // only link is visible in table but comment is used for sorting $dummy = null; // $rowData[] = "<!--{$item['execution_ts']}--><a href=\"lib/execute/execSetResults.php?" . // "level=testcase&build_id={$item['builds_id']}&id={$item['tcase_id']}" . // "&version_id={$item['tcversion_id']}&tplan_id={$gui->tplan_id}\">" . // localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $item['execution_ts']) . '</a>'; $rowData[] = "<!--{$item['execution_ts']}-->" . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $item['execution_ts']); // Use array for status to get correct rendering and sorting $rowData[] = array('value' => $item['exec_status'], 'text' => $gui->status_code_labels[$item['exec_status']], 'cssClass' => $gui->code_status[$item['exec_status']] . '_text'); $hasValue = false; $rowData[] = strip_tags($item['exec_notes']); if ($item['exec_notes']) { $hasValue = true; } foreach ($item['cfields'] as $cf_value) { $rowData[] = preg_replace('!\\s+!', ' ', htmlspecialchars($cf_value, ENT_QUOTES, $charset)); if ($cf_value) { $hasValue = true; } } if ($hasValue) { $matrixData[] = $rowData;
/** * * */ function createSpreadsheet($gui, $args) { $lbl = init_labels(array('title_test_suite_name' => null, 'platform' => null, 'priority' => null, 'build' => null, 'title_test_case_title' => null, 'test_exec_by' => null, 'notes' => null, 'date_time_run' => null, 'execution_duration' => null, 'testproject' => null, 'generated_by_TestLink_on' => null, 'testplan' => null, 'result_on_last_build' => null, 'last_execution' => null, 'assigned_to' => null, 'tcexec_result' => null, 'version' => null, 'execution_type' => null)); $buildIDSet = $args->builds->idSet; // contribution to have more than 26 columns $cellRange = range('A', 'Z'); $cellRangeLen = count($cellRange); for ($idx = 0; $idx < $cellRangeLen; $idx++) { for ($jdx = 0; $jdx < $cellRangeLen; $jdx++) { $cellRange[] = $cellRange[$idx] . $cellRange[$jdx]; } } $styleReportContext = array('font' => array('bold' => true)); $styleDataHeader = array('font' => array('bold' => true), 'borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'vertical' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FF9999FF'))); $dummy = ''; $lines2write = array(array($lbl['testproject'], $gui->tproject_name), array($lbl['testplan'], $gui->tplan_name), array($lbl['generated_by_TestLink_on'], localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', time()))); $objPHPExcel = new PHPExcel(); $cellArea = "A1:"; foreach ($lines2write as $zdx => $fields) { $cdx = $zdx + 1; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$cdx}", current($fields))->setCellValue("B{$cdx}", end($fields)); } $cellArea .= "A{$cdx}"; $objPHPExcel->getActiveSheet()->getStyle($cellArea)->applyFromArray($styleReportContext); // Step 2 // data is organized with following columns $dataHeader[] // Test suite // Test case // Test case version (for humans) // [Platform] => if any exists // // Priority ===> Just discovered that we have choosen to make this column // displayabled or not according test project configuration // IMHO has no sense work without priority // // Build // Assigned To // Exec result // Date // Tester // Notes // Duration // // ?? Exec result on ON LATEST CREATED Build // ?? Latest Execution result (Hmm need to explain better) // $dataHeader = array($lbl['title_test_suite_name'], $lbl['title_test_case_title'], $lbl['version']); if ($showPlatforms = !is_null($gui->platforms)) { $dataHeader[] = $lbl['platform']; } if ($gui->options->testPriorityEnabled) { $dataHeader[] = $lbl['priority']; } $gui->filterFeedback = null; $dataHeader[] = $lbl['build']; $dataHeader[] = $lbl['assigned_to']; $dataHeader[] = $lbl['tcexec_result']; $dataHeader[] = $lbl['date_time_run']; $dataHeader[] = $lbl['test_exec_by']; $dataHeader[] = $lbl['notes']; $dataHeader[] = $lbl['execution_duration']; $dataHeader[] = $lbl['execution_type']; $startingRow = count($lines2write) + 2; // MAGIC $cellArea = "A{$startingRow}:"; foreach ($dataHeader as $zdx => $field) { $cellID = $cellRange[$zdx] . $startingRow; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellID, $field); $cellAreaEnd = $cellRange[$zdx]; } $cellArea .= "{$cellAreaEnd}{$startingRow}"; $objPHPExcel->getActiveSheet()->getStyle($cellArea)->applyFromArray($styleDataHeader); $startingRow++; $qta_loops = count($gui->matrix); for ($idx = 0; $idx < $qta_loops; $idx++) { foreach ($gui->matrix[$idx] as $ldx => $field) { $cellID = $cellRange[$ldx] . $startingRow; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellID, $field); } $startingRow++; } // Final step $objPHPExcel->setActiveSheetIndex(0); $settings = array(); $settings['Excel2007'] = array('ext' => '.xlsx', 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $settings['Excel5'] = array('ext' => '.xls', 'Content-Type' => 'application/vnd.ms-excel'); $xlsType = 'Excel5'; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $xlsType); $tmpfname = tempnam(config_get('temp_dir'), "resultsTCFlat.tmp"); $objWriter->save($tmpfname); $content = file_get_contents($tmpfname); unlink($tmpfname); $f2d = 'resultsTCFlat_' . $gui->tproject_name . '_' . $gui->tplan_name . $settings[$xlsType]['ext']; downloadContentsToFile($content, $f2d, array('Content-Type' => $settings[$xlsType]['Content-Type'])); exit; }
/** * render Test Case content for generated documents * * @param $integer db DB connection identifier * @return string generated html code * * @internal revisions */ function renderTestCaseForPrinting(&$db, &$node, &$options, $env, $context) { static $req_mgr; static $tc_mgr; static $build_mgr; static $tplan_mgr; static $tplan_urgency; static $labels; static $tcase_prefix; static $userMap = array(); static $cfg; static $locationFilters; static $tables = null; static $force = null; static $bugInterfaceOn = false; static $its; static $buildCfields; static $statusL10N; $code = null; $tcInfo = null; $tcResultInfo = null; $tcase_pieces = null; $id = $node['id']; $level = $context['level']; $prefix = isset($context['prefix']) ? $context['prefix'] : null; $tplan_id = isset($context['tplan_id']) ? $context['tplan_id'] : 0; $tprojectID = isset($context['tproject_id']) ? $context['tproject_id'] : 0; $platform_id = isset($context['platform_id']) ? $context['platform_id'] : 0; $build_id = isset($context['build_id']) ? $context['build_id'] : 0; // init static elements if (!$tables) { $tables = tlDBObject::getDBTables(array('executions', 'builds')); $tc_mgr = new testcase($db); $tplan_urgency = new testPlanUrgency($db); $build_mgr = new build_mgr($db); $tplan_mgr = new testplan($db); list($cfg, $labels) = initRenderTestCaseCfg($tc_mgr, $options); if (!is_null($prefix)) { $tcase_prefix = $prefix; } else { list($tcase_prefix, $dummy) = $tc_mgr->getPrefix($id); } $tcase_prefix .= $cfg['testcase']->glue_character; $force['displayVersion'] = isset($options['displayVersion']) ? $options['displayVersion'] : false; $force['displayLastEdit'] = isset($options['displayLastEdit']) ? $options['displayLastEdit'] : false; $its = null; $tproject_mgr = new testproject($db); $info = $tproject_mgr->get_by_id($tprojectID); $bugInterfaceOn = $info['issue_tracker_enabled']; if ($info['issue_tracker_enabled']) { $it_mgr = new tlIssueTracker($db); $its = $it_mgr->getInterfaceObject($tprojectID); unset($it_mgr); } $statusL10N = null; foreach ($cfg['results']['code_status'] as $vc => $vstat) { if (isset($cfg['results']['status_label_for_exec_ui'][$vstat])) { $statusL10N[$vc] = lang_get($cfg['results']['status_label_for_exec_ui'][$vstat]); } } } $cspan = ' colspan = "' . ($cfg['tableColspan'] - 1) . '" '; $cfieldFormatting = array('label_css_style' => '', 'add_table' => false, 'value_css_style' => $cspan); /** * @TODO THIS IS NOT THE WAY TO DO THIS IS ABSOLUTELY WRONG AND MUST BE REFACTORED, * using existent methods - franciscom - 20090329 * Need to get CF with execution scope */ $exec_info = null; $getExecutions = false; $getByID['filters'] = null; switch ($options["docType"]) { case DOC_TEST_SPEC: $getByID['tcversion_id'] = testcase::LATEST_VERSION; break; case SINGLE_TESTCASE: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status']; break; default: $getByID['tcversion_id'] = $node['tcversion_id']; $getExecutions = $options['cfields'] || $options['passfail'] || $options['notes'] || $options['step_exec_notes'] || $options['step_exec_status']; break; } if ($getExecutions) { // Thanks to Evelyn from Cortado, have found a very old issue never reported. // 1. create TC-1A VERSION 1 // 2. add to test plan and execute FAILED ON BUILD 1 // 3. Request Test Report (Test Plan EXECUTION REPORT). // You will get spec for VERSION 1 and result for VERSION 1 - OK cool! // 4. create VERSION 2 // 5. update linked Test Case Versions // 6. do nothing more than repeat step 3 // without this fix you will get // You will get spec for VERSION 2 and result for VERSION 1 - Hmmm // and in addition is not clear that execution was on VERSION 1 . No GOOD!! // // HOW has been fixed ? // Getting info about THE CURRENT LINKED test case version and looking for // exec info for this. // // ATTENTION: THIS IS OK ONLY WHEN BUILD ID is not provided // // // Get Linked test case version $linkedItem = $tplan_mgr->getLinkInfo($tplan_id, $id, $platform_id); $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," . " B.name AS build_name,E.execution_duration " . " FROM {$tables['executions']} E, {$tables['builds']} B" . " WHERE E.build_id = B.id " . " AND E.testplan_id = " . intval($tplan_id) . " AND E.platform_id = " . intval($platform_id) . " AND E.tcversion_id = " . intval($linkedItem[0]['tcversion_id']); if ($build_id > 0) { $sql .= " AND E.build_id = " . intval($build_id); } else { // We are looking for LATEST EXECUTION of CURRENT LINKED test case version $sql .= " AND E.tcversion_number=" . intval($linkedItem[0]['version']); } $sql .= " ORDER BY execution_id DESC"; $exec_info = $db->get_recordset($sql, null, 1); $getByID['tcversion_id'] = $linkedItem[0]['tcversion_id']; $getByID['filters'] = null; if (!is_null($exec_info)) { // $getByID['tcversion_id'] = null; $getByID['filters'] = array('version_number' => $exec_info[0]['tcversion_number']); if ($options['build_cfields']) { if (!isset($buildCfields[$exec_info[0]['build_id']])) { $buildCfields[$exec_info[0]['build_id']] = $build_mgr->html_table_of_custom_field_values($exec_info[0]['build_id'], $tprojectID); } } } } $tcInfo = $tc_mgr->get_by_id($id, $getByID['tcversion_id'], $getByID['filters'], array('renderGhost' => true)); if ($tcInfo) { $tcInfo = $tcInfo[0]; } $external_id = $tcase_prefix . $tcInfo['tc_external_id']; $name = htmlspecialchars($node['name']); $versionID = $tcInfo['id']; $cfields = array('specScope' => null, 'execScope' => null); if ($options['cfields']) { if (!$locationFilters) { $locationFilters = $tc_mgr->buildCFLocationMap(); } // Get custom fields that has specification scope // Custom Field values at Test Case VERSION Level foreach ($locationFilters as $fkey => $fvalue) { $cfields['specScope'][$fkey] = $tc_mgr->html_table_of_custom_field_values($id, 'design', $fvalue, null, $tplan_id, $tprojectID, $cfieldFormatting, $tcInfo['id']); } if (!is_null($exec_info)) { $execution_id = $exec_info[0]['execution_id']; $cfields['execScope'] = $tc_mgr->html_table_of_custom_field_values($versionID, 'execution', null, $execution_id, $tplan_id, $tprojectID, $cfieldFormatting); } } if ($options['toc']) { // EXTERNAL ID added $options['tocCode'] .= '<p style="padding-left: ' . 15 * $level . 'px;"><a href="#' . prefixToHTMLID('tc' . $id) . '">' . htmlspecialchars($external_id) . ": " . $name . '</a></p>'; $code .= '<a name="' . prefixToHTMLID('tc' . $id) . '"></a>'; } // change table style in case of single TC printing to not be indented $table_style = ""; if (isset($options['docType']) && $options['docType'] == SINGLE_TESTCASE) { $table_style = 'style="margin-left: 0;"'; } $code .= '<p> </p><div> <table class="tc" width="90%" ' . $table_style . '>'; $code .= '<tr><th colspan="' . $cfg['tableColspan'] . '">' . $labels['test_case'] . " " . htmlspecialchars($external_id) . ": " . $name; // add test case version switch ($env->reportType) { case DOC_TEST_PLAN_DESIGN: $version_number = $node['version']; break; case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $version_number = $tcInfo['version']; break; default: $version_number = $tcInfo['version']; break; } if ($cfg['doc']->tc_version_enabled || $force['displayVersion']) { $code .= ' <span style="font-size: 80%;">' . $cfg['gui']->role_separator_open . $labels['version'] . $cfg['gui']->title_separator_1 . $version_number . $cfg['gui']->role_separator_close . '</span>'; } $code .= "</th></tr>\n"; if ($options['author']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['author'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['author_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['creation_ts']); } $code .= "</td></tr>\n"; if ($tcInfo['updater_id'] > 0) { // add updater if available and differs from author OR forced if ($force['displayLastEdit'] > 0 || $tcInfo['updater_id'] != $tcInfo['author_id']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_edit'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . gendocGetUserName($db, $tcInfo['updater_id']); if (isset($options['displayDates']) && $options['displayDates']) { $dummy = null; $code .= ' - ' . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $tcInfo['modification_ts']); } $code .= "</td></tr>\n"; } } } if ($options['body'] || $options['summary']) { $tcase_pieces = array('summary'); } if ($options['body']) { $tcase_pieces[] = 'preconditions'; } if ($options['body'] || $options['step_exec_notes'] || $options['step_exec_status']) { $tcase_pieces[] = 'steps'; } if (!is_null($tcase_pieces)) { // Multiple Test Case Steps Feature foreach ($tcase_pieces as $key) { if ($key == 'steps') { if (isset($cfields['specScope']['before_steps_results'])) { $code .= $cfields['specScope']['before_steps_results']; } if ($tcInfo[$key] != '') { $code .= '<tr>' . '<td><span class="label">' . $labels['step_number'] . ':</span></td>' . '<td><span class="label">' . $labels['step_actions'] . ':</span></td>' . '<td><span class="label">' . $labels['expected_results'] . ':</span></td>'; if ($options['step_exec_notes'] || $options['step_exec_status']) { $sxni = $tc_mgr->getStepsExecInfo($exec_info[0]['execution_id']); if ($options['step_exec_notes']) { $code .= '<td><span class="label">' . $labels['step_exec_notes'] . ':</span></td>'; } if ($options['step_exec_status']) { $code .= '<td><span class="label">' . $labels['step_exec_status'] . ':</span></td>'; } } $code .= '</tr>'; $loop2do = count($tcInfo[$key]); for ($ydx = 0; $ydx < $loop2do; $ydx++) { $code .= '<tr>' . '<td width="5">' . $tcInfo[$key][$ydx]['step_number'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['actions'] . '</td>' . '<td>' . $tcInfo[$key][$ydx]['expected_results'] . '</td>'; if ($options['step_exec_notes']) { $code .= '<td>' . $sxni[$tcInfo[$key][$ydx]['id']]['notes'] . '</td>'; } if ($options['step_exec_status']) { $code .= '<td>' . $statusL10N[$sxni[$tcInfo[$key][$ydx]['id']]['status']] . '</td>'; } $code .= '</tr>'; } } } else { // disable the field if it's empty if ($tcInfo[$key] != '') { $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '"><span class="label">' . $labels[$key] . ':</span><br />' . $tcInfo[$key] . "</td></tr>"; } } } } $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['execution_type'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; switch ($tcInfo['execution_type']) { case TESTCASE_EXECUTION_TYPE_AUTO: $code .= $labels['execution_type_auto']; break; case TESTCASE_EXECUTION_TYPE_MANUAL: default: $code .= $labels['execution_type_manual']; break; } $code .= "</td></tr>\n"; // $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['estimated_execution_duration'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $tcInfo['estimated_exec_duration']; $code .= "</td></tr>\n"; if (isset($options['importance']) && $options['importance']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['importance'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['importance'][$tcInfo['importance']]; $code .= "</td></tr>\n"; } // print priority when printing test plan if (isset($options['priority']) && $options['priority']) { // Get priority of this tc version for this test plan by using testplanUrgency class. // Is there maybe a better method than this one? $filters = array('tcversion_id' => $tcInfo['id']); $opt = array('details' => 'tcversion'); $prio_info = $tplan_urgency->getPriority($tplan_id, $filters, $opt); $prio = $prio_info[$tcInfo['id']]['priority_level']; $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['priority'] . ':</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '">' . $cfg['priority'][$prio]; $code .= "</td></tr>\n"; } // Spacer $code .= '<tr><td colspan="' . $cfg['tableColspan'] . '">' . "</td></tr>"; $code .= $cfields['specScope']['standard_location'] . $cfields['execScope']; // generate test results data for test report if ($options['passfail']) { if ($exec_info) { $code .= buildTestExecResults($db, $its, $cfg, $labels, $exec_info, $cfg['tableColspan'] - 1, $options['notes'], $buildCfields); } else { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top">' . '<span class="label">' . $labels['last_exec_result'] . '</span></td>' . '<td colspan="' . ($cfg['tableColspan'] - 1) . '"><b>' . $labels["test_status_not_run"] . "</b></td></tr>\n"; } } // collect REQ for TC if ($options['requirement']) { if (!$req_mgr) { $req_mgr = new requirement_mgr($db); } $requirements = $req_mgr->get_all_for_tcase($id); $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['reqs'] . '</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; if (sizeof($requirements)) { foreach ($requirements as $req) { $code .= htmlspecialchars($req['req_doc_id'] . ": " . $req['title']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br />'; } $code .= "</td></tr>\n"; } // collect keywords for TC if ($options['keyword']) { $code .= '<tr><td width="' . $cfg['firstColWidth'] . '" valign="top"><span class="label">' . $labels['keywords'] . ':</span>'; $code .= '<td colspan="' . ($cfg['tableColspan'] - 1) . '">'; $arrKeywords = $tc_mgr->getKeywords($id); if (sizeof($arrKeywords)) { foreach ($arrKeywords as $kw) { $code .= htmlspecialchars($kw['keyword']) . "<br />"; } } else { $code .= ' ' . $labels['none'] . '<br>'; } $code .= "</td></tr>\n"; } // Attachments $attachSet = (array) $tc_mgr->getAttachmentInfos($id); if (count($attachSet) > 0) { $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>\n</div>\n"; return $code; }
/** * */ function createSpreadsheet($gui, $args, $customFieldColumns = null) { $lbl = init_labels(array('title_test_suite_name' => null, 'platform' => null, 'build' => null, 'th_bugs_id_summary' => null, 'title_test_case_title' => null, 'version' => null, 'testproject' => null, 'generated_by_TestLink_on' => null, 'testplan' => null, 'title_execution_notes' => null, 'th_date' => null, 'th_run_by' => null, 'assigned_to' => null, 'summary' => null)); $cellRange = range('A', 'Z'); $styleReportContext = array('font' => array('bold' => true)); $styleDataHeader = array('font' => array('bold' => true), 'borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'vertical' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FF9999FF'))); $dummy = ''; $lines2write = array(array($gui->title, ''), array($lbl['testproject'], $gui->tproject_name), array($lbl['testplan'], $gui->tplan_name), array($lbl['generated_by_TestLink_on'], localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', time())), array($gui->report_context, '')); $objPHPExcel = new PHPExcel(); $cellArea = "A1:"; foreach ($lines2write as $zdx => $fields) { $cdx = $zdx + 1; $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A{$cdx}", current($fields))->setCellValue("B{$cdx}", end($fields)); } $cellArea .= "A{$cdx}"; $objPHPExcel->getActiveSheet()->getStyle($cellArea)->applyFromArray($styleReportContext); // Step 2 // data is organized with following columns$dataHeader[] // Test suite // Test case // Version // [Platform] // Build // Tester // Date // Execution notes // [Custom Field ENABLED ON EXEC 1] // [Custom Field ENABLED ON EXEC 1] // [Custom Field ENABLED ON EXEC 1] // [bugString] only if bugtracking integration exists for this test project // This is HOW gui->dataSet is organized // THIS IS CRITIC ?? // // suiteName Issue Tracker Management // testTitle PTRJ-76:Create issue tracker - no conflict // testVersion 1 // [platformName] // buildName 1.0 // testerName admin // localizedTS 2013-03-28 20:15:06 // notes [empty string] // bugString [empty string] // $dataHeader = array($lbl['title_test_suite_name'], $lbl['title_test_case_title'], $lbl['version']); if ($showPlatforms = property_exists($gui, 'platformSet') && !is_null($gui->platformSet) && !isset($gui->platformSet[0])) { $dataHeader[] = $lbl['platform']; } $dataHeader[] = $lbl['build']; if ($gui->notRunReport) { $dataHeader[] = $lbl['assigned_to']; $dataHeader[] = $lbl['summary']; } else { $dataHeader[] = $lbl['th_run_by']; $dataHeader[] = $lbl['th_date']; $dataHeader[] = $lbl['title_execution_notes']; } if (!is_null($customFieldColumns)) { foreach ($customFieldColumns as $id => $def) { $dataHeader[] = $def['label']; } } // ATTENTION logic regarding NOT RUN IS MISSING // For not run this column and also columns regarding CF on exec are not displayed if ($gui->bugInterfaceOn && !$gui->notRunReport) { $dataHeader[] = $lbl['th_bugs_id_summary']; } $startingRow = count($lines2write) + 2; // MAGIC $cellArea = "A{$startingRow}:"; foreach ($dataHeader as $zdx => $field) { $cellID = $cellRange[$zdx] . $startingRow; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellID, $field); $cellAreaEnd = $cellRange[$zdx]; } $cellArea .= "{$cellAreaEnd}{$startingRow}"; $objPHPExcel->getActiveSheet()->getStyle($cellArea)->applyFromArray($styleDataHeader); // new dBug($gui->dataSet); die(); // Now process data $startingRow++; $qta_loops = count($gui->dataSet); for ($idx = 0; $idx < $qta_loops; $idx++) { $line2write = $gui->dataSet[$idx]; $colCounter = 0; foreach ($gui->dataSet[$idx] as $ldx => $field) { if ($ldx != 'bugString' || $ldx == 'bugString' && $gui->bugInterfaceOn) { $cellID = $cellRange[$colCounter] . $startingRow; $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellID, html_entity_decode($field)); $colCounter++; } // May be same processing can be applied to execution otes if ($ldx == 'bugString' && $gui->bugInterfaceOn) { // To manage new line // http://stackoverflow.com/questions/5960242/how-to-make-new-lines-in-a-cell-using-phpexcel $objPHPExcel->setActiveSheetIndex(0)->getStyle($cellID)->getAlignment()->setWrapText(true); // $objPHPExcel->setActiveSheetIndex(0)->getRowDimension($startingRow)->setRowHeight(-1); // http://stackoverflow.com/questions/6054444/how-to-set-auto-height-in-phpexcel } } // $colQty = count($line2write); $cellEnd = $cellRange[$colCounter - 1] . $startingRow; $startingRow++; } // Final step $objPHPExcel->setActiveSheetIndex(0); $settings = array(); $settings['Excel2007'] = array('ext' => '.xlsx', 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); $settings['Excel5'] = array('ext' => '.xls', 'Content-Type' => 'application/vnd.ms-excel'); $xlsType = 'Excel5'; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $xlsType); $tmpfname = tempnam(config_get('temp_dir'), "resultsTC.tmp"); $objWriter->save($tmpfname); $content = file_get_contents($tmpfname); unlink($tmpfname); $f2d = 'resultsByStatus_' . $gui->tproject_name . '_' . $gui->tplan_name . $settings[$xlsType]['ext']; downloadContentsToFile($content, $f2d, array('Content-Type' => $settings[$xlsType]['Content-Type'])); exit; }
$tmp_dir = config_get('temp_dir'); // main description $cellRange = range('A', 'Z'); $colors4cell = array('font' => array('color' => PHPExcel_Style_Color::COLOR_RED)); // $styleReportContext = array('font' => array('bold' => true), // 'borders' => array( 'outline' => // array('style' => PHPExcel_Style_Border::BORDER_THICK), // 'horizontal' => // array('style' => PHPExcel_Style_Border::BORDER_THIN), // ), // 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, // 'startcolor' => array( 'argb' => 'FF9999FF')) // ); $styleReportContext = array('font' => array('bold' => true)); $styleDataHeader = array('font' => array('bold' => true), 'borders' => array('outline' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM), 'vertical' => array('style' => PHPExcel_Style_Border::BORDER_THIN)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('argb' => 'FF9999FF'))); $lines2write = array(array($labels['xls_jmexport_testproject'], $gui->tproject_name), array($labels['xls_jmexport_testplan'], $gui->tplan_name), array($labels['xls_jmexport_created'], localize_dateOrTimeStamp(null, $dummy, 'date_format', time())), array($labels['xls_jmexport_author'], $args->author)); $tcaseHeader = array($labels['xls_jmexport_testcase'], $labels['xls_jmexport_testobjectives'], $labels['xls_jmexport_preconditions'], $labels['xls_jmexport_steps'], $labels['xls_jmexport_expected_result'], $labels['xls_jmexport_result'], $labels['xls_jmexport_tester'], $labels['xls_jmexport_result_comment']); // Need to get CF to know how many additional columns need to be added // IMPORTANT NOTICE - cf are ordered by display order - fantastic!!! $cfields = $tcaseMgr->get_linked_cfields_at_design(null, null, null, null, $args->tproject_id); $cfieldsHeader = array(); $colOffSet = 0; if (!is_null($cfields)) { foreach ($cfields as $cfid => $cf) { $cfieldsHeader[] = $cf['label']; } $colOffSet = count($cfieldsHeader); } $statusCellLetter = $cellRange[$colOffSet + array_search($labels['xls_jmexport_result'], $tcaseHeader)]; $dataHeaders = array_merge($cfieldsHeader, $tcaseHeader); $fp = null;
/** * Builds $executionsMap map. * $executionsMap contains all execution information for suites and test cases. * * * $executionsMap = [testsuite_id_1_array, test_suite_id_2_array, ...] * * testsuite_id_1_array = [] * all test cases are included, even cases that have not been executed yet * * @internal Revisions: * * 20100518 - franciscom - BUGID 3474: Link to test case in Query Metrics Report is broken if using platforms * 20090302 - amitkhullar - added a parameter $all_results to get latest results (0) only otherwise * all results are displayed in reports (1). * 20080928 - franciscom - seems that adding a control to avoid call to buildBugString() * reduces dramatically memory usage(); * IMPORTANT: * we need to refactor this method, because if we had to call buildBugsString() * probably will crash again. * We need to think about function that got bug for all test cases, with one * call, may be is the solution. * * 20070916 - franciscom - removed session coupling * added node_order */ private function buildExecutionsMap($builds_to_query, $lastResult = 'a', $keyword = 0, $owner = null, $startTime, $endTime, $executor, $search_notes_string, $executeLinkBuild, $all_results = 1) { $searchBugs = config_get('bugInterfaceOn'); // first make sure we initialize the executionsMap // otherwise duplicate executions will be added to suites $executionsMap = null; // map for adding SuiteName directly to every TC $allSuites = $this->getAllSuites(); // for execution link $canExecute = has_rights($this->db, "tp_execute"); // Build Sql additional filters $sqlFilters = ''; if (!is_null($startTime)) { $sqlFilters .= " AND execution_ts > '{$startTime}'"; } if (!is_null($endTime)) { $sqlFilters .= " AND execution_ts < '{$endTime}' "; } if ($lastResult == $this->map_tc_status['passed'] || $lastResult == $this->map_tc_status['failed'] || $lastResult == $this->map_tc_status['blocked']) { $sqlFilters .= " AND status = '" . $lastResult . "' "; } if ($builds_to_query != -1 && $builds_to_query != 'a') { $sqlFilters .= " AND build_id IN ({$builds_to_query}) "; } // BUGID 2023 if (!is_null($executor) && $executor != '' && $executor != TL_USER_ANYBODY) { $sqlFilters .= " AND tester_id = {$executor} "; } if ($search_notes_string != null) { $sqlFilters .= " AND notes LIKE '%" . $search_notes_string . "%' "; } $suffixLink = htmlspecialchars($this->testCasePrefix . $this->testCaseCfg->glue_character); foreach ($this->linked_tcversions as $tcase_info) { foreach ($tcase_info as $index => $info) { $testcaseID = $info['tc_id']; $executionExists = true; $currentSuite = null; if (!$executionsMap || !array_key_exists($info['testsuite_id'], $executionsMap)) { $currentSuite = array(); } else { $currentSuite = $executionsMap[$info['testsuite_id']]; } $version = $info['version']; if (isset($info['tcversion_number']) && !is_null($info['tcversion_number'])) { $version = $info['tcversion_number']; } $owner_id = $this->getUserForFeature($info['feature_id']); // BUGID - 2374: Show Assigned User in the Not Run Test Cases Report $infoToSave = array('testcaseID' => $testcaseID, 'platform_id' => $info['platform_id'], 'testcasePrefix' => $this->testCasePrefix . $this->testCaseCfg->glue_character, 'external_id' => $info['external_id'], 'tcversion_id' => $info['tcversion_id'], 'version' => $version, 'build_id' => '', 'tester_id' => $owner_id, 'execution_ts' => '', 'status' => $this->map_tc_status['not_run'], 'executions_id' => '', 'notes' => '', 'bugString' => '', 'name' => $info['name'], 'suiteName' => $allSuites[$info['testsuite_id']], 'assigner_id' => $info['assigner_id'], 'feature_id' => $info['feature_id'], 'execute_link' => ''); if ($info['tcversion_id'] != $info['executed']) { $executionExists = false; if ($lastResult == 'a' || $lastResult == $this->map_tc_status['not_run']) { // Initialize information on testcaseID to be "not run" // echo 'NOTRUN - DEBUG- Added Not Run info <br>'; array_push($currentSuite, $infoToSave); } } if ($executionExists) { // TO-DO - this is where we can include the searching of results // over multiple test plans - by modifying this select statement slightly // to include multiple test plan ids $sql = "SELECT * FROM {$this->tables['executions']} executions " . "WHERE tcversion_id = " . $info['executed'] . " AND testplan_id = {$this->testPlanID} " . "AND platform_id = " . $info['platform_id']; $sql .= $sqlFilters; // mht: fix 966 // mike_h - 20070806 - when ordering executions by the timestamp, // the results are represented correctly in the report "Test Report". // amitkhullar - BUGID 2156 - added option to get latest/all results in Query metrics report. if ($all_results == 0) { $sql .= " ORDER BY execution_ts DESC limit 1"; } else { $sql .= " ORDER BY execution_ts ASC "; } //echo "<br>debug - <b><i>" . __FUNCTION__ . "</i></b><br><b>" . $sql . "</b><br>"; $execQuery = $this->db->fetchArrayRowsIntoMap($sql, 'id'); if ($execQuery) { if ($lastResult != $this->map_tc_status['not_run']) { foreach ($execQuery as $executions_id => $execInfo) { $exec_row = $execInfo[0]; $infoToSave['version'] = $exec_row['tcversion_number']; $infoToSave['build_id'] = $exec_row['build_id']; $infoToSave['platform_id'] = $exec_row['platform_id']; $infoToSave['tester_id'] = $exec_row['tester_id']; $infoToSave['status'] = $exec_row['status']; $infoToSave['notes'] = $exec_row['notes']; $infoToSave['executions_id'] = $executions_id; //@todo: Refactor for this code - BUGID 2242 $infoToSave['bugString'] = $searchBugs ? $this->buildBugString($this->db, $executions_id) : ''; $dummy = null; $infoToSave['execution_ts'] = localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $exec_row['execution_ts']); //-amitkhullar - BugID:2267 $prefixLink = '<a href="lib/execute/execSetResults.php?level=testcase&build_id=' . $infoToSave['build_id']; // 20100518 - franciscom - BUGID 3474: Link to test case in Query Metrics Report is broken if using platforms $prefixLink .= '&platform_id=' . $exec_row['platform_id']; $infoToSave['execute_link'] = $prefixLink . "&id={$testcaseID}&version_id=" . $info['tcversion_id'] . "&tplan_id=" . $this->testPlanID . '">' . $suffixLink . $info['external_id'] . ": <b>" . htmlspecialchars($info['name']) . "</b></a>"; array_push($currentSuite, $infoToSave); } // end foreach } } elseif ($lastResult == 'a' || $lastResult == $this->map_tc_status['not_run']) { // HANDLE scenario where execution does not exist array_push($currentSuite, $infoToSave); } } // end if($executionExists) $executionsMap[$info['testsuite_id']] = $currentSuite; } // foreach platform } // end foreach unset($infoToSave); return $executionsMap; }
$version_revison = sprintf($labels['version_revision_tag'], $version['version'], $version['revision']); $padded_data = sprintf("%05d%05d", $version['version'], $version['revision']); // use html comment to sort properly by this columns (extjs) $result[] = "<!-- {$padded_data} -->{$version_revison}"; // $dummy necessary to avoid warnings on event viewer because localize_dateOrTimeStamp expects // second parameter to be passed by reference $dummy = null; // use html comment to sort properly by this columns (extjs) $result[] = "<!--{$version['creation_ts']}-->" . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $version['creation_ts']) . " ({$version['author']})"; // on requirement creation motification timestamp is set to default value "0000-00-00 00:00:00" $never_modified = "0000-00-00 00:00:00"; // use html comment to sort properly by this columns (extjs) $modification_ts = "<!-- 0 -->" . lang_get('never'); if ($version['modification_ts'] != $never_modified) { // use html comment to sort properly by this columns (extjs) $modification_ts = "<!--{$version['modification_ts']}-->" . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $version['modification_ts']) . " ({$version['modifier']})"; } $result[] = $modification_ts; // is it frozen? $result[] = $version['is_open'] ? $labels['no'] : $labels['yes']; // coverage if ($coverage_enabled) { $expected = $version['expected_coverage']; // use html comment to sort properly by this columns (extjs) $coverage_string = "<!-- -1 -->" . $labels['not_aplicable'] . " ({$tc_coverage}/0)"; if ($expected > 0) { $percentage = round(100 / $expected * $tc_coverage, 2); $padded_data = sprintf("%010d", $percentage); //bring all percentages to same length // use html comment to sort properly by this columns (extjs) $coverage_string = "<!-- {$padded_data} --> {$percentage}% ({$tc_coverage}/{$expected})";
$rowData = array(); // Get test suite path $dummy = $tcase_mgr->getPathLayered(array($item['tcase_id'])); $dummy = end($dummy); $rowData[] = $dummy['value']; $rowData[] = '<a href="lib/testcases/archiveData.php?edit=testcase&id=' . $item['tcase_id'] . '">' . buildExternalIdString($gui->tcasePrefix, $item['tc_external_id']) . ' : ' . $item['tcase_name'] . '</a>'; $rowData[] = $item['tcversion_number']; if ($args->showPlatforms) { $rowData[] = $item['platform_name']; } $rowData[] = $item['build_name']; $rowData[] = $item['tester']; // use html comment to be able to sort table by timestamp and not by link // only link is visible in table but comment is used for sorting $dummy = null; $rowData[] = "<!--{$item['execution_ts']}--><a href=\"lib/execute/execSetResults.php?" . "level=testcase&build_id={$item['builds_id']}&id={$item['tcase_id']}" . "&version_id={$item['tcversion_id']}&tplan_id={$gui->tplan_id}\">" . localize_dateOrTimeStamp(null, $dummy, 'timestamp_format', $item['execution_ts']) . '</a>'; // Use array for status to get correct rendering and sorting $rowData[] = array('value' => $item['exec_status'], 'text' => $gui->status_code_labels[$item['exec_status']], 'cssClass' => $gui->code_status[$item['exec_status']] . '_text'); $hasValue = false; foreach ($item['cfields'] as $cf_value) { $rowData[] = $cf_value; if ($cf_value) { $hasValue = true; } } if ($hasValue) { $matrixData[] = $rowData; } } // create unique table id for each test plan $table_id = 'tl_' . $args->tplan_id . '_table_tc_with_cf';