function initializeGui(&$dbHandler, $args) { $gui = new stdClass(); $tplan_mgr = new testplan($dbHandler); $gui_open = config_get('gui_separator_open'); $gui_close = config_get('gui_separator_close'); $gui->str_option_any = $gui_open . lang_get('any') . $gui_close; $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close; $gui->tplan_id = $args->tplan_id; $gui->tproject_id = $args->tproject_id; $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id); $gui->tplan_name = $tplan_info['name']; unset($tplan_info); $ni = $tplan_mgr->tree_manager->get_node_hierarchy_info($gui->tproject_id); $gui->tproject_name = $ni['name']; unset($ni); $gui->assigned_users = new stdClass(); $gui->keywords = new stdClass(); $gui->builds = new stdClass(); $gui->platforms = new stdClass(); $gui->testsuites = new stdClass(); // 20090107 - franciscom // Show only users that are able to execute test cases ? // What happens if a user that has loose right to execute, but // before loosing this right has been assigned some tests, or have executed it? // // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION); // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, // array(TL_USER_ANYBODY => $gui->str_option_any, // TL_USER_NOBODY => $gui->str_option_none) ); // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any)); $gui->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS); $gui->platforms->items = $tplan_mgr->getPlatforms($gui->tplan_id); $gui->testsuites->items = $tplan_mgr->getRootTestSuites($gui->tplan_id, $gui->tproject_id, array('output' => 'plain')); $gui->keywords->items[0] = $gui->str_option_any; if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) { $gui->keywords->items += $tplan_keywords_map; } $key2loop = array('keywords', 'builds', 'platforms', 'testsuites', 'assigned_users'); foreach ($key2loop as $kx) { $gui->{$kx}->qty = count($gui->{$kx}->items); } $gui->status_code_label = get_status_for_reports_html_options(); $gui->report_type = $args->format; $reports_cfg = config_get('reportsCfg'); $ldf = config_get('locales_date_format'); $date_format = $ldf[isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB']; $gui->selected_start_date = strftime($date_format, time() - $reports_cfg->start_date_offset); $gui->selected_start_time = $reports_cfg->start_time; $gui->selected_end_date = strftime($date_format, time()); $gui->selected_end_time = null; return $gui; }
$tInfo['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null; $treeForPlatform[0]['childNodes'] = array($tInfo); $doc_info->title = htmlspecialchars(isset($tInfo['name']) ? $args->tproject_name . $tlCfg->gui_title_separator_2 . $tInfo['name'] : $args->tproject_name); break; } break; case DOC_TEST_PLAN_DESIGN: $printingOptions['metrics'] = true; // FORCE // FORCE case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $tplan_mgr = new testplan($db); $tplan_info = $tplan_mgr->get_by_id($args->tplan_id); if ($args->build_id > 0) { $xx = $tplan_mgr->get_builds($args->tplan_id, null, null, array('buildID' => $args->build_id)); $doc_info->build_name = htmlspecialchars($xx[$args->build_id]['name']); } $doc_info->testplan_name = htmlspecialchars($tplan_info['name']); $doc_info->testplan_scope = $tplan_info['notes']; $doc_info->title = $doc_info->testplan_name; // Changed to get ALL platform attributes. $getOpt = array('outputFormat' => 'mapAccessByID', 'addIfNull' => true); $platforms = $tplan_mgr->getPlatforms($args->tplan_id, $getOpt); $platformIDSet = array_keys($platforms); $printingOptions['priority'] = $doc_info->test_priority_enabled; $items2use = (object) array('estimatedExecTime' => null, 'realExecTime' => null); $treeForPlatform = array(); $filters = null; switch ($doc_info->content_range) { case 'testproject':
if ($build_count == 0) { // Test plan without builds can have execution data $gui->do_report['status_ok'] = 0; $gui->do_report['msg'] = lang_get('report_tplan_has_no_build'); } // ----------------------------------------------------------------------------- // get navigation data $gui->menuItems = array(); if ($gui->do_report['status_ok']) { // create a list or reports $context = new stdClass(); $context->tproject_id = $args->tproject_id; $context->tplan_id = $args->tplan_id; $tplan_mgr = new testplan($db); $dmy = $tplan_mgr->get_by_id($context->tplan_id); $gui->buildInfoSet = $tplan_mgr->get_builds($gui->tplan_id); $report_plans = $tplan_mgr->report_get_plans($args->tproject_id); $report_suites = $tplan_mgr->report_get_suites($args->tproject_id); $report_builds = $tplan_mgr->report_get_builds(); $report_build_total = count($report_builds); $report_devices = $tplan_mgr->report_get_devices($args->tproject_id); $report_device_total = count($report_devices); unset($tplan_mgr); $context->apikey = $dmy['api_key']; // $context->apikey = $_SESSION['currentUser']->userApiKey; $context->imgSet = $smarty->getImages(); $gui->menuItems = $reports_mgr->get_list_reports($context, $gui->btsEnabled, $args->optReqs, $tlCfg->reports_formats[$args->format]); } $smarty->assign('gui', $gui); $smarty->assign('report_plans', $report_plans); $smarty->assign('report_suites', $report_suites);
$templateCfg = templateConfiguration(); $args = init_args(); $gui = initializeGui($db, $args); if ($args->tproject_id) { $tproject_mgr = new testproject($db); $gui->tplans = $args->user->getAccessibleTestPlans($db, $args->tproject_id, null, array('output' => 'mapfull', 'active' => null)); $gui->drawPlatformQtyColumn = false; if (!is_null($gui->tplans) && count($gui->tplans) > 0) { // do this test project has platform definitions ? $tplan_mgr = new testplan($db); $tplan_mgr->platform_mgr->setTestProjectID($args->tproject_id); $dummy = $tplan_mgr->platform_mgr->testProjectCount(); $gui->drawPlatformQtyColumn = $dummy[$args->tproject_id]['platform_qty'] > 0; $tplanSet = array_keys($gui->tplans); $dummy = $tplan_mgr->count_testcases($tplanSet, null, array('output' => 'groupByTestPlan')); $buildQty = $tplan_mgr->get_builds($tplanSet, null, null, array('getCount' => true)); foreach ($tplanSet as $idk) { $gui->tplans[$idk]['tcase_qty'] = isset($dummy[$idk]['qty']) ? intval($dummy[$idk]['qty']) : 0; $gui->tplans[$idk]['build_qty'] = isset($buildQty[$idk]['build_qty']) ? intval($buildQty[$idk]['build_qty']) : 0; if ($gui->drawPlatformQtyColumn) { $plat = $tplan_mgr->getPlatforms($idk); $gui->tplans[$idk]['platform_qty'] = is_null($plat) ? 0 : count($plat); } } unset($tplan_mgr); } unset($tproject_mgr); } $smarty = new TLSmarty(); $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/** * * */ private function init_setting_testplan() { if (is_null($this->testplan_mgr)) { $this->testplan_mgr = new testplan($this->db); } $key = 'setting_testplan'; $testplans = $this->user->getAccessibleTestPlans($this->db, $this->args->testproject_id); if (isset($_SESSION['testplanID']) && $_SESSION['testplanID'] != $this->args->{$key}) { // testplan was changed, we need to reset all filters // --> they were chosen for another testplan, not this one! $this->args->reset_filters = true; // check if user is allowed to set chosen testplan before changing foreach ($testplans as $plan) { if ($plan['id'] == $this->args->{$key}) { setSessionTestPlan($plan); } } } // now load info from session $info = $this->testplan_mgr->get_by_id($_SESSION['testplanID']); $this->args->testplan_name = $info['name']; $this->args->testplan_id = $info['id']; $this->args->{$key} = $info['id']; $this->settings[$key]['selected'] = $info['id']; // Final filtering based on mode: // Now get all selectable testplans for the user to display. // For execution: // For assign test case execution feature: // don't take testplans into selection which have no (active/open) builds! // // For plan add mode: // add every plan no matter if he has builds or not. foreach ($testplans as $plan) { $add_plan = $this->mode == 'plan_add_mode' || $this->mode == 'plan_mode' && $this->args->feature != 'tc_exec_assignment'; if (!$add_plan) { $builds = $this->testplan_mgr->get_builds($plan['id'], testplan::GET_ACTIVE_BUILD, testplan::GET_OPEN_BUILD); $add_plan = is_array($builds) && count($builds); } if ($add_plan) { $this->settings[$key]['items'][$plan['id']] = $plan['name']; } } }
/** * only active builds has to be used * * @internal revisions * * */ function getMetrics(&$db, $userObj, $args, $result_cfg, $labels) { $user_id = $args->currentUserID; $tproject_id = $args->tproject_id; $linked_tcversions = array(); $metrics = array(); $tplan_mgr = new testplan($db); $show_platforms = false; $platforms = array(); // get all tesplans accessibles for user, for $tproject_id $options = array('output' => 'map'); $options['active'] = $args->show_only_active ? ACTIVE : TP_ALL_STATUS; $test_plans = $userObj->getAccessibleTestPlans($db, $tproject_id, null, $options); // Get count of testcases linked to every testplan // Hmm Count active and inactive ? $linkedItemsQty = $tplan_mgr->count_testcases(array_keys($test_plans), null, array('output' => 'groupByTestPlan')); $metricsMgr = new tlTestPlanMetrics($db); $show_platforms = false; $metrics = array('testplans' => null, 'total' => null); $mm =& $metrics['testplans']; $metrics['total'] = array('active' => 0, 'total' => 0, 'executed' => 0); foreach ($result_cfg['status_label_for_exec_ui'] as $status_code => &$dummy) { $metrics['total'][$status_code] = 0; } $codeStatusVerbose = array_flip($result_cfg['status_code']); foreach ($test_plans as $key => &$dummy) { // We need to know if test plan has builds, if not we can not call any method // that try to get exec info, because you can only execute if you have builds. // // 20130909 - added active filter $buildSet = $tplan_mgr->get_builds($key, testplan::ACTIVE_BUILDS); if (is_null($buildSet)) { continue; } $platformSet = $tplan_mgr->getPlatforms($key); if (isset($platformSet)) { $platforms = array_merge($platforms, $platformSet); } $show_platforms_for_tplan = !is_null($platformSet); $show_platforms = $show_platforms || $show_platforms_for_tplan; if (!is_null($platformSet)) { $neurus = $metricsMgr->getExecCountersByPlatformExecStatus($key, null, array('getPlatformSet' => true, 'getOnlyActiveTCVersions' => true)); $mm[$key]['overall']['active'] = $mm[$key]['overall']['executed'] = 0; foreach ($neurus['with_tester'] as $platform_id => &$pinfo) { $xd =& $mm[$key]['platforms'][$platform_id]; $xd['tplan_name'] = $dummy['name']; $xd['platform_name'] = $neurus['platforms'][$platform_id]; $xd['total'] = $xd['active'] = $neurus['total'][$platform_id]['qty']; $xd['executed'] = 0; foreach ($pinfo as $code => &$elem) { $xd[$codeStatusVerbose[$code]] = $elem['exec_qty']; if ($codeStatusVerbose[$code] != 'not_run') { $xd['executed'] += $elem['exec_qty']; } if (!isset($mm[$key]['overall'][$codeStatusVerbose[$code]])) { $mm[$key]['overall'][$codeStatusVerbose[$code]] = 0; } $mm[$key]['overall'][$codeStatusVerbose[$code]] += $elem['exec_qty']; $metrics['total'][$codeStatusVerbose[$code]] += $elem['exec_qty']; } $mm[$key]['overall']['executed'] += $xd['executed']; $mm[$key]['overall']['active'] += $xd['active']; } unset($neurus); $mm[$key]['overall']['total'] = $mm[$key]['overall']['active']; $metrics['total']['executed'] += $mm[$key]['overall']['executed']; $metrics['total']['active'] += $mm[$key]['overall']['active']; } else { $mm[$key]['overall'] = $metricsMgr->getExecCountersByExecStatus($key, null, array('getOnlyActiveTCVersions' => true)); $mm[$key]['overall']['active'] = $mm[$key]['overall']['total']; // compute executed $mm[$key]['overall']['executed'] = 0; foreach ($mm[$key]['overall'] as $status_code => $qty) { if ($status_code != 'not_run' && $status_code != 'total' && $status_code != 'active') { $mm[$key]['overall']['executed'] += $qty; } if ($status_code != 'total' && $status_code != 'active') { if (!isset($metrics['total'][$status_code])) { $metrics['total'][$status_code] = 0; } $metrics['total'][$status_code] += $qty; } } $metrics['total']['executed'] += $mm[$key]['overall']['executed']; $metrics['total']['active'] += $mm[$key]['overall']['active']; $mm[$key]['platforms'][0] = $mm[$key]['overall']; $mm[$key]['platforms'][0]['tplan_name'] = $dummy['name']; $mm[$key]['platforms'][0]['platform_name'] = $labels['not_aplicable']; } } // remove duplicate platform names $platformsUnique = array(); foreach ($platforms as $platform) { if (!in_array($platform['name'], $platformsUnique)) { $platformsUnique[] = $platform['name']; } } return array($metrics, $show_platforms, $platformsUnique); }
function initializeGui(&$dbHandler, $args) { // BUGID 3930 global $g_locales_date_format; $locale = isset($_SESSION['locale']) ? $_SESSION['locale'] : 'en_GB'; $date_format = $g_locales_date_format[$locale]; $gui = new stdClass(); $tplan_mgr = new testplan($dbHandler); $tproject_mgr = new testproject($dbHandler); $gui_open = config_get('gui_separator_open'); $gui_close = config_get('gui_separator_close'); $gui->str_option_any = $gui_open . lang_get('any') . $gui_close; $gui->str_option_none = $gui_open . lang_get('nobody') . $gui_close; $gui->tplan_id = $args->tplan_id; $gui->tproject_id = $args->tproject_id; $tplan_info = $tplan_mgr->get_by_id($gui->tplan_id); $gui->tplan_name = $tplan_info['name']; $tproject_info = $tproject_mgr->get_by_id($gui->tproject_id); $gui->tproject_name = $tproject_info['name']; $re = new results($dbHandler, $tplan_mgr, $tproject_info, $tplan_info); $gui->assigned_users = new stdClass(); $gui->keywords = new stdClass(); $gui->builds = new stdClass(); $gui->platforms = new stdClass(); $gui->testsuites = new stdClass(); // 20090107 - franciscom // Show only users that are able to execute test cases ? // What happens if a user that has loose right to execute, but // before loosing this right has been assigned some tests, or have executed it? // // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, ADD_BLANK_OPTION); // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, // array(TL_USER_ANYBODY => $gui->str_option_any, // TL_USER_NOBODY => $gui->str_option_none) ); // $gui->assigned_users->items = getUsersForHtmlOptions($dbHandler, ALL_USERS_FILTER, array(TL_USER_ANYBODY => $gui->str_option_any)); $gui->assigned_users->qty = count($gui->assigned_users->items); // BUGID 2012 - franciscom $gui->keywords->items[0] = $gui->str_option_any; if (!is_null($tplan_keywords_map = $tplan_mgr->get_keywords_map($gui->tplan_id))) { $gui->keywords->items += $tplan_keywords_map; } $gui->builds->items = $tplan_mgr->get_builds($gui->tplan_id, testplan::ACTIVE_BUILDS); $gui->platforms->items = $tplan_mgr->getPlatforms($gui->tplan_id); $gui->testsuites->items = $re->getTopLevelSuites(); $gui->keywords->qty = count($gui->keywords->items); $gui->builds->qty = count($gui->builds->items); $gui->platforms->qty = count($gui->platforms->items); $gui->testsuites->qty = count($gui->testsuites->items); $gui->status_code_label = get_status_for_reports_html_options(); $gui->report_type = $args->format; $reports_cfg = config_get('reportsCfg'); // BUGID 3716 $startDate = strftime($date_format, time() - $reports_cfg->start_date_offset); $gui->selected_start_date = $startDate; $gui->selected_start_time = $reports_cfg->start_time; // BUGID 3716 $gui->selected_end_date = strftime($date_format, time()); $gui->selected_end_time = null; return $gui; }
/** * * */ private function init_setting_testplan() { if (is_null($this->testplan_mgr)) { $this->testplan_mgr = new testplan($this->db); } $key = 'setting_testplan'; $testplans = $this->user->getAccessibleTestPlans($this->db, $this->args->testproject_id); // On 2.0 and UP WE DO NOT USE SESSION ANY MORE if ($this->args->useHasChangedTestPlan) { $this->args->reset_filters = true; } // now load info from session $info = $this->testplan_mgr->get_by_id($this->args->testplan_id); $this->args->testplan_name = $info['name']; $this->args->testplan_id = $info['id']; $this->args->{$key} = $info['id']; $this->settings[$key]['selected'] = $info['id']; // Now get all selectable testplans for the user to display. // For execution, don't take testplans into selection which have no (active/open) builds! // For plan add mode, add every plan no matter if he has builds or not. foreach ($testplans as $plan) { // List also test plans without builds for "plan_mode" $add_plan = $this->mode == 'plan_add_mode' || $this->mode == 'plan_mode'; if (!$add_plan) { $builds = $this->testplan_mgr->get_builds($plan['id'], testplan::GET_ACTIVE_BUILD, testplan::GET_OPEN_BUILD); $add_plan = is_array($builds) && count($builds); } if ($add_plan) { $this->settings[$key]['items'][$plan['id']] = $plan['name']; } } }
$build->name = 'Build Code Testing'; $build->notes = 'Build created running Code Testing code by TestLink Development Team'; echo "<pre> {$object_class} - create(\$tplan_id,\$name,\$notes = '',\$active=1,\$open=1)"; echo "</pre>"; echo "<pre> {$object_class} - create({$testplan->id},'{$build->name}','{$build->notes}')"; echo "</pre>"; $build->id = $obj_mgr->create($testplan->id, $build->name, $build->notes); $info = $obj_mgr->get_by_id($build->id); new dBug($info); echo "<pre> Check Build existence using testplan manager method 'get_builds()'"; echo "</pre>"; echo "<pre> testplan - get_builds(\$testplan_id,\$active=null,\$open=null)"; echo "</pre>"; echo "<pre> get_builds({$testplan->id})"; echo "</pre>"; $all_builds = $tplan_mgr->get_builds($testplan->id); new dBug($all_builds); // Final Clean-Up $tproject_mgr->delete($testproject_id); die; // OLD CODE MUST BE REFACTORED echo "<pre> testplan - get_all()"; echo "</pre>"; $all_testplans_on_tl = $tplan_mgr->get_all(); new dBug($all_testplans_on_tl); $tplan_id = -1; if (!is_null($all_testplans_on_tl)) { $tplan_id = $all_testplans_on_tl[0]['id']; } echo "<pre> testplan - get_by_id(\$id)"; echo "</pre>";