function renderTestSpecTreeForPrinting(&$db, &$node, &$options, $env, $context, $tocPrefix, $indentLevel)
{
    static $tree_mgr;
    static $id_descr;
    static $tplan_mgr;
    $code = null;
    if (!$tree_mgr) {
        $tplan_mgr = new testplan($db);
        $tree_mgr = new tree($db);
        $id_descr = $tree_mgr->node_types;
        $k2i = array('tproject_id' => 0, 'tplan_id' => 0, 'platform_id' => 0, 'build_id' => 0, 'prefix' => null);
        $context = array_merge($k2i, $context);
    }
    $node_type = $id_descr[intval($node['node_type_id'])];
    switch ($node_type) {
        case 'testproject':
            break;
        case 'testsuite':
            $tocPrefix .= (!is_null($tocPrefix) ? "." : '') . $env->tocCounter;
            $code .= renderTestSuiteNodeForPrinting($db, $node, $env, $options, $context, $tocPrefix, $indentLevel);
            break;
        case 'testcase':
            $code .= renderTestCaseForPrinting($db, $node, $options, $env, $context, $indentLevel);
            break;
    }
    if (isset($node['childNodes']) && $node['childNodes']) {
        // Need to be a LOCAL COUNTER for each PARENT
        $TOCCounter = 0;
        $childNodes = $node['childNodes'];
        $children_qty = sizeof($childNodes);
        for ($idx = 0; $idx < $children_qty; $idx++) {
            $current = $childNodes[$idx];
            if (is_null($current) || $current == REMOVEME) {
                continue;
            }
            if (isset($current['node_type_id']) && $id_descr[$current['node_type_id']] == 'testsuite') {
                // Each time I found a contained Test Suite need to add a .x.x. to TOC
                $TOCCounter++;
            }
            $env->tocCounter = $TOCCounter;
            $code .= renderTestSpecTreeForPrinting($db, $current, $options, $env, $context, $tocPrefix, $indentLevel + 1);
        }
    }
    if ($node_type == 'testproject' && $options['toc']) {
        $code = str_replace("{{INSERT_TOC}}", $options['tocCode'], $code);
    }
    return $code;
}
示例#2
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;
}
示例#3
0
function renderTestSpecTreeForPrinting(&$db, &$node, &$options, $env, $context)
{
    static $tree_mgr;
    static $id_descr;
    static $tplan_mgr;
    $code = null;
    if (!$tree_mgr) {
        $tplan_mgr = new testplan($db);
        $tree_mgr = new tree($db);
        $id_descr = $tree_mgr->node_types;
        $k2i = array('tproject_id' => 0, 'tplan_id' => 0, 'platform_id' => 0, 'build_id' => 0, 'prefix' => null);
        $context = array_merge($k2i, $context);
    }
    $node_type = $id_descr[intval($node['node_type_id'])];
    switch ($node_type) {
        case 'testproject':
            break;
        case 'testsuite':
            $env->tocPrefix .= (!is_null($env->tocPrefix) ? "." : '') . $env->testCounter;
            $code .= renderTestSuiteNodeForPrinting($db, $node, $env, $options, $context);
            break;
        case 'testcase':
            $code .= renderTestCaseForPrinting($db, $node, $options, $env, $context);
            break;
    }
    if (isset($node['childNodes']) && $node['childNodes']) {
        $childNodes = $node['childNodes'];
        $env->testCounter = 0;
        $children_qty = sizeof($childNodes);
        for ($idx = 0; $idx < $children_qty; $idx++) {
            $current = $childNodes[$idx];
            if (is_null($current)) {
                continue;
            }
            if (isset($current['node_type_id']) && $id_descr[$current['node_type_id']] == 'testsuite') {
                $env->testCounter++;
            }
            $context['level']++;
            $code .= renderTestSpecTreeForPrinting($db, $current, $options, $env, $context);
        }
    }
    if ($node_type == 'testproject' && $options['toc']) {
        $code = str_replace("{{INSERT_TOC}}", $options['tocCode'], $code);
    }
    return $code;
}