Ejemplo n.º 1
0
function renderTestSpecTreeForPrinting(&$db, &$node, $item_type, &$options, $tocPrefix, $tcCnt, $level, $user_id, $tplan_id = 0, $tcPrefix = null, $tprojectID = 0, $platform_id = 0)
{
    static $tree_mgr;
    static $map_id_descr;
    static $tplan_mgr;
    $code = null;
    if (!$tree_mgr) {
        $tplan_mgr = new testplan($db);
        $tree_mgr = new tree($db);
        $map_id_descr = $tree_mgr->node_types;
    }
    $verbose_node_type = $map_id_descr[intval($node['node_type_id'])];
    switch ($verbose_node_type) {
        case 'testproject':
            if ($tplan_id != 0) {
                // we are printing a test plan, get it's custom fields
                $cfieldFormatting = array('table_css_style' => 'class="cf"');
                if ($options['cfields']) {
                    $cfields = $tplan_mgr->html_table_of_custom_field_values($tplan_id, 'design', null, $cfieldFormatting);
                    $code .= '<p>' . $cfields . '</p>';
                }
            }
            // platform changes - $code .= renderTOC($options);
            break;
        case 'testsuite':
            $tocPrefix .= (!is_null($tocPrefix) ? "." : '') . $tcCnt;
            $code .= renderTestSuiteNodeForPrinting($db, $node, $options, $tocPrefix, $level, $tplan_id, $tprojectID);
            break;
        case 'testcase':
            $context = new stdClass();
            $context->tproject_id = $tprojectID;
            $context->tplan_id = $tplan_id;
            $context->platform_id = $platform_id;
            $context->tcase_prefix = $tcPrefix;
            $code .= renderTestCaseForPrinting($db, $node, $options, $level, $context);
            break;
    }
    if (isset($node['childNodes']) && $node['childNodes']) {
        $childNodes = $node['childNodes'];
        $tsCnt = 0;
        $children_qty = sizeof($childNodes);
        for ($i = 0; $i < $children_qty; $i++) {
            $current = $childNodes[$i];
            if (is_null($current)) {
                continue;
            }
            if (isset($current['node_type_id']) && $map_id_descr[$current['node_type_id']] == 'testsuite') {
                $tsCnt++;
            }
            // BUGID 3459 - added $platform_id
            $code .= renderTestSpecTreeForPrinting($db, $current, $item_type, $options, $tocPrefix, $tsCnt, $level + 1, $user_id, $tplan_id, $tcPrefix, $tprojectID, $platform_id);
        }
    }
    if ($verbose_node_type == 'testproject') {
        if ($options['toc']) {
            // remove for platforms feature
            // $options['tocCode'] .= '</div><hr />';
            $code = str_replace("{{INSERT_TOC}}", $options['tocCode'], $code);
        }
    }
    return $code;
}