예제 #1
0
/**
 * Create the string representation suitable to create a graphic visualization
 * of a node, for the type of menu selected.
 *
 * @internal Revisions
 * 20100611 - franciscom - removed useless $getArguments
 */
function renderTreeNode($level, &$node, $hash_id_descr, $tc_action_enabled, $linkto, $testCasePrefix, $bForPrinting = 0, $showTestCaseID)
{
    $menustring = '';
    $node_type = $hash_id_descr[$node['node_type_id']];
    extjs_renderTestSpecTreeNodeOnOpen($node, $node_type, $tc_action_enabled, $bForPrinting, $showTestCaseID, $testCasePrefix);
    if (isset($node['childNodes']) && $node['childNodes']) {
        // 20090118 - franciscom - need to work always original object
        //                         in order to change it's values using reference .
        // Can not assign anymore to intermediate variables.
        //
        $nChildren = sizeof($node['childNodes']);
        for ($idx = 0; $idx < $nChildren; $idx++) {
            // asimon - replaced is_null by !isset because of warnings in event log
            if (!isset($node['childNodes'][$idx])) {
                continue;
            }
            $menustring .= renderTreeNode($level + 1, $node['childNodes'][$idx], $hash_id_descr, $tc_action_enabled, $linkto, $testCasePrefix, $bForPrinting, $showTestCaseID);
        }
    }
    return $menustring;
}
예제 #2
0
/**
 * 
 * @internal revisions
 *  20121010 - asimon - TICKET 4353: added active/inactive filter
 */
function generateTestSpecTreeNew(&$db, $tproject_id, $tproject_name, $linkto, $filters = null, $options = null)
{
    $chronos[] = microtime(true);
    $tables = tlObjectWithDB::getDBTables(array('tcversions', 'nodes_hierarchy'));
    $my = array();
    $my['options'] = array('forPrinting' => 0, 'hideTestCases' => 0, 'tc_action_enabled' => 1, 'viewType' => 'testSpecTree');
    $my['filters'] = array('keywords' => null, 'testplan' => null);
    $my['options'] = array_merge($my['options'], (array) $options);
    $my['options']['showTestCaseID'] = config_get('treemenu_show_testcase_id');
    $my['filters'] = array_merge($my['filters'], (array) $filters);
    $treeMenu = new stdClass();
    $treeMenu->rootnode = null;
    $treeMenu->menustring = '';
    $resultsCfg = config_get('results');
    $glueChar = config_get('testcase_cfg')->glue_character;
    $menustring = null;
    $tproject_mgr = new testproject($db);
    $tree_manager =& $tproject_mgr->tree_manager;
    $hash_descr_id = $tree_manager->get_available_node_types();
    $hash_id_descr = array_flip($hash_descr_id);
    $status_descr_code = $resultsCfg['status_code'];
    $status_code_descr = $resultsCfg['code_status'];
    $decoding_hash = array('node_id_descr' => $hash_id_descr, 'status_descr_code' => $status_descr_code, 'status_code_descr' => $status_code_descr);
    $tcase_prefix = $tproject_mgr->getTestCasePrefix($tproject_id) . $glueChar;
    $test_spec = getTestSpecTree($tproject_id, $tproject_mgr, $filters);
    // Added root node for test specification -> testproject
    $test_spec['name'] = $tproject_name;
    $test_spec['id'] = $tproject_id;
    $test_spec['node_type_id'] = $hash_descr_id['testproject'];
    $map_node_tccount = array();
    $tc2show = null;
    if ($test_spec) {
        if (isset($my['filters']['filter_custom_fields']) && isset($test_spec['childNodes'])) {
            $test_spec['childNodes'] = filter_by_cf_values($db, $test_spec['childNodes'], $my['filters']['filter_custom_fields'], $hash_descr_id);
        }
        $pnFilters = array('keywords' => $my['filters']['filter_keywords'], 'keywords_filter_type' => $my['filters']['filter_keywords_filter_type']);
        $pnOptions = array('hideTestCases' => $my['options']['hideTestCases'], 'ignoreInactiveTestCases' => $my['options']['ignore_inactive_testcases'], 'ignoreActiveTestCases' => $my['options']['ignore_active_testcases']);
        // Important/CRITIC:
        // prepareTestSpecNode() will make changes to $test_spec like filtering by test case keywords.
        $testcase_counters = prepareTestSpecNode($db, $tproject_mgr, $tproject_id, $test_spec, $map_node_tccount, $pnFilters, $pnOptions);
        if (is_null($test_spec)) {
            $test_spec['name'] = $tproject_name;
            $test_spec['id'] = $tproject_id;
            $test_spec['node_type_id'] = $hash_descr_id['testproject'];
        }
        foreach ($testcase_counters as $key => $value) {
            $test_spec[$key] = $testcase_counters[$key];
        }
        $tc2show = renderTreeNode(1, $test_spec, $hash_id_descr, $linkto, $tcase_prefix, $my['options']);
    }
    $menustring = '';
    $treeMenu->rootnode = new stdClass();
    $treeMenu->rootnode->name = $test_spec['text'];
    $treeMenu->rootnode->id = $test_spec['id'];
    $treeMenu->rootnode->leaf = isset($test_spec['leaf']) ? $test_spec['leaf'] : false;
    $treeMenu->rootnode->text = $test_spec['text'];
    $treeMenu->rootnode->position = $test_spec['position'];
    $treeMenu->rootnode->href = $test_spec['href'];
    // 20090328 - franciscom - BUGID 2299
    // More details about problem found on 20090308 and fixed IN WRONG WAY
    // TPROJECT
    //    |______ TSA
    //            |__ TC1
    //            |__ TC2
    //    |
    //    |______ TSB
    //            |______ TSC
    //
    // Define Keyword K1,K2
    //
    // NO TEST CASE HAS KEYWORD ASSIGNED
    // Filter by K1
    // Tree will show root that spins Forever
    // menustring before str_ireplace : [null,null]
    // menustring AFTER [null]
    //
    // Now fixed.
    //
    // Some minor fix to do
    // Il would be important exclude Top Level Test suites.
    //
    //
    // 20090308 - franciscom
    // Changed because found problem on:
    // Test Specification tree when applying Keyword filter using a keyword NOT PRESENT
    // in test cases => Tree root shows loading icon and spin never stops.
    //
    // Attention: do not know if in other situation this will generate a different bug
    //
    //
    // Change key ('childNodes')  to the one required by Ext JS tree.
    if (isset($test_spec['childNodes'])) {
        $menustring = str_ireplace('childNodes', 'children', json_encode($test_spec['childNodes']));
    }
    if (!is_null($menustring)) {
        // Remove null elements (Ext JS tree do not like it ).
        // :null happens on -> "children":null,"text" that must become "children":[],"text"
        // $menustring = str_ireplace(array(':null',',null','null,'),array(':[]','',''), $menustring);
        $menustring = str_ireplace(array(':null', ',null', 'null,', 'null'), array(':[]', '', '', ''), $menustring);
    }
    $treeMenu->menustring = $menustring;
    $tc2show = !is_null($tc2show) ? explode(",", trim($tc2show, ",")) : null;
    return array('menu' => $treeMenu, 'leaves' => $tc2show, 'tree' => $test_spec);
}
예제 #3
0
 function generateTestSpecTreeNew($env, $linkto, $filters = null, $options = null)
 {
     $chronos[] = microtime(true);
     $my = array();
     $my['options'] = array('forPrinting' => 0, 'hideTestCases' => 0, 'tc_action_enabled' => 1, 'viewType' => 'testSpecTree');
     $my['filters'] = array('keywords' => null, 'testplan' => null);
     $my['options'] = array_merge($my['options'], (array) $options);
     $my['filters'] = array_merge($my['filters'], (array) $filters);
     $treeMenu = new stdClass();
     $treeMenu->rootnode = null;
     $treeMenu->menustring = '';
     $menustring = null;
     $tproject_mgr = new testproject($db);
     $tree_manager =& $tproject_mgr->tree_manager;
     $hash_descr_id = $tree_manager->get_available_node_types();
     $hash_id_descr = array_flip($hash_descr_id);
     $status_descr_code = $this->cfg->results['status_code'];
     $status_code_descr = $this->cfg->results['code_status'];
     $decoding_hash = array('node_id_descr' => $hash_id_descr, 'status_descr_code' => $status_descr_code, 'status_code_descr' => $status_code_descr);
     $tcase_prefix = $tproject_mgr->getTestCasePrefix($tproject_id) . $this->cfg->glueChar;
     $test_spec = getTestSpecTree($tproject_id, $tproject_mgr, $filters);
     //$chronos[] = microtime(true);$tnow = end($chronos);$tprev = prev($chronos);
     //$t_elapsed = number_format( $tnow - $tprev, 4);
     //echo '<br> ' . __FUNCTION__ . ' Elapsed (sec) (get_subtree()):' . $t_elapsed .'<br>';
     //reset($chronos);
     // Added root node for test specification -> testproject
     $test_spec['name'] = $tproject_name;
     $test_spec['id'] = $tproject_id;
     $test_spec['node_type_id'] = $hash_descr_id['testproject'];
     $map_node_tccount = array();
     $tplan_tcs = null;
     if ($test_spec) {
         if (isset($my['filters']['filter_custom_fields']) && isset($test_spec['childNodes'])) {
             $test_spec['childNodes'] = $this->tprojectMgr->filterByCFValues($test_spec['childNodes'], $my['filters']['filter_custom_fields']);
         }
         $pnFilters = array('keywords' => $my['filters']['filter_keywords'], 'keywords_filter_type' => $my['filters']['filter_keywords_filter_type']);
         // TICKET 4353 - added active/inactive filter
         $pnOptions = array('hideTestCases' => $my['options']['hideTestCases'], 'ignoreInactiveTestCases' => $my['options']['ignore_inactive_testcases'], 'ignoreActiveTestCases' => $my['options']['ignore_active_testcases']);
         // Important/CRITIC:
         // prepareTestSpecNode() will make changes to $test_spec like filtering by test case keywords.
         $testcase_counters = prepareTestSpecNode($db, $tproject_mgr, $tproject_id, $test_spec, $map_node_tccount, $pnFilters, $pnOptions);
         //$chronos[] = microtime(true);$tnow = end($chronos);$tprev = prev($chronos);
         //$t_elapsed = number_format( $tnow - $tprev, 4);
         //echo '<br> ' . __FUNCTION__ . ' Elapsed (sec) (get_subtree()):' . $t_elapsed .'<br>';
         //reset($chronos);
         if (is_null($test_spec)) {
             $test_spec['name'] = $tproject_name;
             $test_spec['id'] = $tproject_id;
             $test_spec['node_type_id'] = $hash_descr_id['testproject'];
         }
         foreach ($testcase_counters as $key => $value) {
             $test_spec[$key] = $testcase_counters[$key];
         }
         $showTestCaseID = config_get('treemenu_show_testcase_id');
         $menustring = renderTreeNode(1, $test_spec, $hash_id_descr, $my['options']['tc_action_enabled'], $linkto, $tcase_prefix, $my['options']['forPrinting'], $showTestCaseID);
     }
     $menustring = '';
     $treeMenu->rootnode = new stdClass();
     $treeMenu->rootnode->name = $test_spec['text'];
     $treeMenu->rootnode->id = $test_spec['id'];
     $treeMenu->rootnode->leaf = isset($test_spec['leaf']) ? $test_spec['leaf'] : false;
     $treeMenu->rootnode->text = $test_spec['text'];
     $treeMenu->rootnode->position = $test_spec['position'];
     $treeMenu->rootnode->href = $test_spec['href'];
     // Change key ('childNodes')  to the one required by Ext JS tree.
     if (isset($test_spec['childNodes'])) {
         $menustring = str_ireplace('childNodes', 'children', json_encode($test_spec['childNodes']));
     }
     if (!is_null($menustring)) {
         // Remove null elements (Ext JS tree do not like it ).
         // :null happens on -> "children":null,"text" that must become "children":[],"text"
         $menustring = str_ireplace(array(':null', ',null', 'null,', 'null'), array(':[]', '', '', ''), $menustring);
     }
     $treeMenu->menustring = $menustring;
     return $treeMenu;
 }