Beispiel #1
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);
}
 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;
 }