コード例 #1
0
ファイル: specview.php プロジェクト: viglesiasce/tl_RC1
/**
 * get Test Specification data within a Node
 *  
 *	using nodeId (that normally is a test suite id) as starting point
 *	will return subtree that start at nodeId.
 *	If filters are given, the subtree returned is filtered.
 * 
 *	Important Notice regaring keyword filtering
 *	Keyword filter logic inside this function seems to work ONLY on OR mode.
 *	Then how the AND mode is implemented ?
 *	Filter for test case id is used, and the test case set has been generated
 *	applying AND or OR logic (following user's choice).
 *	Then seems that logic regarding keywords here, may be can be removed
 *
 * @param integer $masterContainerId can be a Test Project Id, or a Test Plan id.
 *                is used only if keyword id filter has been specified
 *                to get all keyword defined on masterContainer.
 *
 * @param integer $nodeId node that will be root of the view we want to build.
 * 
 * @param string $specViewType: type of view requested
 *
 * @param array $filters
 *	  			filters['keyword_id']: array of keywords 
 *
 * 
 * @return array map with view (test cases subtree)
 * 
 * @internal revisions
 * 20100417 - franciscom - BUGID 2498 - added logic to filter by importance (defined on test case spec)
 * 20100411 - franciscom - added logic to filter by execution type
 */
function getTestSpecFromNode(&$dbHandler, &$tcaseMgr, &$linkedItems, $masterContainerId, $nodeId, $specViewType, $filters)
{
    $applyFilters = false;
    $testCaseSet = null;
    $tck_map = null;
    $tobj_mgr = new testproject($dbHandler);
    $test_spec = $tobj_mgr->get_subtree($nodeId);
    $key2loop = null;
    $useAllowed = false;
    // 20100411 - BUGID 2797 - filter by test case execution type
    $useFilter = array('keyword_id' => false, 'tcase_id' => false, 'exec_type' => false);
    // BUGID 3768
    if (!is_array($filters['keyword_id'])) {
        $filters['keyword_id'] = array($filters['keyword_id']);
    }
    if ($useFilter['keyword_id'] = $filters['keyword_id'][0] > 0) {
        $applyFilters = true;
        switch ($specViewType) {
            case 'testplan':
                $tobj_mgr = new testplan($dbHandler);
                break;
        }
        $tck_map = $tobj_mgr->get_keywords_tcases($masterContainerId, $filters['keyword_id']);
    }
    if ($useFilter['tcase_id'] = !is_null($filters['tcase_id'])) {
        $applyFilters = true;
        $testCaseSet = is_array($filters['tcase_id']) ? $filters['tcase_id'] : array($filters['tcase_id']);
    }
    if ($useFilter['execution_type'] = !is_null($filters['execution_type'])) {
        $applyFilters = true;
    }
    // BUGID
    if ($useFilter['importance'] = !is_null($filters['importance'])) {
        $applyFilters = true;
    }
    if ($applyFilters) {
        $key2loop = array_keys($test_spec);
        // first step: generate list of TEST CASE NODES
        $itemSet = null;
        foreach ($key2loop as $key) {
            if ($test_spec[$key]['node_type_id'] == $filters['tcase_node_type_id']) {
                $itemSet[$test_spec[$key]['id']] = $key;
            }
        }
        $itemKeys = $itemSet;
        foreach ($itemKeys as $key => $tspecKey) {
            if ($useFilter['keyword_id'] && !isset($tck_map[$test_spec[$tspecKey]['id']]) || $useFilter['tcase_id'] && !in_array($test_spec[$tspecKey]['id'], $testCaseSet)) {
                $test_spec[$tspecKey] = null;
                unset($itemSet[$key]);
            }
        }
        if (count($itemSet) > 0 && ($useFilter['execution_type'] || $useFilter['importance'])) {
            $targetSet = array_keys($itemSet);
            $options = $specViewType == 'testPlanLinking' ? array('access_key' => 'testcase_id') : null;
            $tcversionSet = $tcaseMgr->get_last_active_version($targetSet, $options);
            switch ($specViewType) {
                case 'testPlanLinking':
                    // We need to analise linked items and spec
                    foreach ($targetSet as $idx => $key) {
                        $targetTestCase = $tcversionSet[$key]['testcase_id'];
                        if (isset($linkedItems[$targetTestCase])) {
                            $item = current($linkedItems[$targetTestCase]);
                        } else {
                            $item = null;
                            if (isset($test_spec[$itemSet[$targetTestCase]])) {
                                $item = $tcversionSet[$targetTestCase];
                            }
                        }
                        if (!is_null($item)) {
                            if ($useFilter['exec_type'] && $item['execution_type'] != $filters['exec_type'] || $useFilter['importance'] && $item['importance'] != $filters['importance']) {
                                $tspecKey = $itemSet[$targetTestCase];
                                $test_spec[$tspecKey] = null;
                            }
                        }
                    }
                    break;
                default:
                    $tcvidSet = array_keys($tcversionSet);
                    // $options = array('access_key' => 'testcase_id');
                    $options = null;
                    // $allowedSet = $tcaseMgr->filter_tcversions_by_exec_type($tcvidSet,$filters['exec_type'],$options);
                    $allowedSet = $tcaseMgr->filter_tcversions_by_exec_type($tcvidSet, $filters, $options);
                    if (!is_null($allowedSet) && count($allowedSet) > 0) {
                        $useAllowed = true;
                        foreach ($allowedSet as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey]['version'] = $value['version'];
                        }
                        reset($allowedSet);
                    }
                    $setToRemove = array_diff_key($tcversionSet, $allowedSet);
                    if (!is_null($setToRemove) && count($setToRemove) > 0) {
                        foreach ($setToRemove as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey] = null;
                        }
                    }
                    break;
            }
            // end switch
        }
    }
    // if apply filters
    unset($tobj_mgr);
    return $test_spec;
}
コード例 #2
0
ファイル: treeMenu.inc.php プロジェクト: viglesiasce/tl_RC1
/**
 * @return array a map:
 *         key    => node_id
 *         values => node test case count considering test cases presents
 *                   in the nodes of the subtree that starts on node_id
 *                   Means test case can not be sons/daughters of node_id.
 * 
 *                   node name (useful only for debug purpouses).
 */
function get_testplan_nodes_testcount(&$db, $tproject_id, $tproject_name, $tplan_id, $tplan_name, $keywordsFilter = null)
{
    $tplan_mgr = new testplan($db);
    $tproject_mgr = new testproject($db);
    $tree_manager = $tplan_mgr->tree_manager;
    $tcase_node_type = $tree_manager->node_descr_id['testcase'];
    $hash_descr_id = $tree_manager->get_available_node_types();
    $hash_id_descr = array_flip($hash_descr_id);
    $resultsCfg = config_get('results');
    $decoding_hash = array('node_id_descr' => $hash_id_descr, 'status_descr_code' => $resultsCfg['status_code'], 'status_code_descr' => $resultsCfg['code_status']);
    $test_spec = $tproject_mgr->get_subtree($tproject_id, RECURSIVE_MODE);
    $linkedFilters = array('keyword_id' => $keywordsFilter->items);
    $tplan_tcases = $tplan_mgr->get_linked_tcversions($tplan_id, $linkedFilters);
    if (is_null($tplan_tcases)) {
        $tplan_tcases = array();
    }
    $test_spec['name'] = $tproject_name;
    $test_spec['id'] = $tproject_id;
    $test_spec['node_type_id'] = $hash_descr_id['testproject'];
    $map_node_tccount = array();
    if ($test_spec) {
        $tck_map = null;
        if (!is_null($keywordsFilter)) {
            $tck_map = $tproject_mgr->get_keywords_tcases($tproject_id, $keywordsFilter->items, $keywordsFilter->type);
        }
        //@TODO: schlundus, can we speed up with NO_EXTERNAL?
        $filters = null;
        $options = array('hideTestCases' => 0, 'viewType' => 'executionTree');
        $testcase_counters = prepareNode($db, $test_spec, $decoding_hash, $map_node_tccount, $tck_map, $tplan_tcases, $filters, $options);
        $test_spec['testcase_count'] = $testcase_counters['testcase_count'];
    }
    return $map_node_tccount;
}
コード例 #3
0
 /**
  * initializes linked_tcversions object
  *
  * Builds a multi-dimentional array which represents the tree structure.
  * Specifically an array is returned in the following pattern
  * every 3rd index is null if suite does not contain other suites
  * or array of same pattern if it does contain suites
  *
  * KL took this code from menuTree.inc.php.
  * Builds both $this->flatArray and $this->suiteStructure
  *
  * @param resource &$db reference to database handler
  * 
  * @return array structured map
  * 
  *  suite[0] = suite id
  *	suite[1] = suite name
  *	suite[2] = array() of child suites or null
  *	suite[3] = suite id
  *	suite[4] = suite name
  *	suite[5] = array() of child suites or null
  *
  */
 private function generateExecTree(&$db, $keyword_id = 0, $owner = null)
 {
     $RECURSIVE_MODE = true;
     $tplan_mgr = $this->tplanMgr;
     $tproject_mgr = new testproject($this->db);
     $tree_manager = $tplan_mgr->tree_manager;
     $hash_descr_id = $tree_manager->get_available_node_types();
     $test_spec = $tproject_mgr->get_subtree($this->tprojectID, $RECURSIVE_MODE);
     $filters = array('keyword_id' => $keyword_id, 'assigned_to' => $owner);
     // $options = array('output' => 'mapOfArray'); // needed to have platform info
     $options = array('output' => 'mapOfMap');
     // needed to have platform info
     $tplan_tcversions = $tplan_mgr->get_linked_tcversions($this->testPlanID, $filters, $options);
     // $this->linked_tcversions = &$tp_tcs;
     if (is_null($tplan_tcversions)) {
         $tplan_tcversions = array();
     }
     $test_spec['name'] = $this->tplanName;
     $test_spec['id'] = $this->tprojectID;
     $test_spec['node_type_id'] = $hash_descr_id['testproject'];
     $suiteStructure = null;
     $tck_map = null;
     if ($keyword_id) {
         $tck_map = $tproject_mgr->get_keywords_tcases($this->tprojectID, $keyword_id);
     }
     $hash_id_descr = array_flip($hash_descr_id);
     $testcase_count = $this->removeEmptySuites($test_spec, $hash_id_descr, $tck_map, $tplan_tcversions, $owner);
     // $mem[]=self::memory_status(__CLASS__,__FILE__,__FUNCTION__,__LINE__);
     // $xmem=current($mem);
     // echo "<pre>debug 20080928 - \ - " . __FUNCTION__ . " --- "; print_r($xmem['msg']); echo "</pre>";
     // ob_flush();flush();
     $suiteStructure = $this->processExecTreeNode(1, $test_spec, $hash_id_descr);
     return array($suiteStructure, $tplan_tcversions);
 }
コード例 #4
0
/**
 * get Test Specification data within a Node
 *  
 *  using nodeId (that normally is a test suite id) as starting point
 *  will return subtree that start at nodeId.
 *  If filters are given, the subtree returned is filtered.
 * 
 *  Important Notice regaring keyword filtering
 *  Keyword filter logic inside this function seems to work ONLY on OR mode.
 *  Then how the AND mode is implemented ?
 *  Filter for test case id is used, and the test case set has been generated
 *  applying AND or OR logic (following user's choice).
 *  Then seems that logic regarding keywords here, may be can be removed
 *
 * @param integer $masterContainerId can be a Test Project Id, or a Test Plan id.
 *                is used only if keyword id filter has been specified
 *                to get all keyword defined on masterContainer.
 *
 * @param integer $nodeId node that will be root of the view we want to build.
 * 
 * @param string $specViewType: type of view requested
 *
 * @param array $filters
 *          filters['keyword_id']: array of keywords  
 *          filters['tcase_id']: 
 *          filters['execution_type']: 
 *          filters['importance']: 
 *          filters['cfields']: 
 *          filters['tcase_name']: 
 *
 * 
 * @return array map with view (test cases subtree)
 * 
 * @internal revisions
 *
 */
function getTestSpecFromNode(&$dbHandler, &$tcaseMgr, &$linkedItems, $masterContainerId, $nodeId, $specViewType, $filters)
{
    $applyFilters = false;
    $testCaseSet = null;
    $tck_map = null;
    $tobj_mgr = new testproject($dbHandler);
    $opt = null;
    if ($specViewType == 'testplan') {
        $opt['order_cfg'] = array("type" => 'exec_order', 'tplan_id' => $masterContainerId);
    }
    $test_spec = $tobj_mgr->get_subtree($nodeId, null, $opt);
    $key2loop = null;
    $useAllowed = false;
    $nullCheckFilter = array('tcase_id' => false, 'importance' => false, 'tcase_name' => false, 'cfields' => false, 'status' => false);
    $zeroNullCheckFilter = array('execution_type' => false);
    $useFilter = array('keyword_id' => false) + $nullCheckFilter + $zeroNullCheckFilter;
    $applyFilters = false;
    foreach ($nullCheckFilter as $key => $value) {
        $useFilter[$key] = !is_null($filters[$key]);
        $applyFilters = $applyFilters || $useFilter[$key];
    }
    // more specif analisys
    if ($useFilter['status'] = $filters['status'][0] > 0) {
        $applyFilters = true;
        $filtersByValue['status'] = array_flip((array) $filters['status']);
    }
    if ($useFilter['importance'] = $filters['importance'][0] > 0) {
        $applyFilters = true;
        $filtersByValue['importance'] = array_flip((array) $filters['importance']);
    }
    foreach ($zeroNullCheckFilter as $key => $value) {
        // need to check for > 0, because for some items 0 has same meaning that null -> no filter
        $useFilter[$key] = !is_null($filters[$key]) && $filters[$key] > 0;
        $applyFilters = $applyFilters || $useFilter[$key];
    }
    if ($useFilter['tcase_id']) {
        $testCaseSet = is_array($filters['tcase_id']) ? $filters['tcase_id'] : array($filters['tcase_id']);
    }
    if (!is_array($filters['keyword_id'])) {
        $filters['keyword_id'] = array($filters['keyword_id']);
    }
    if ($useFilter['keyword_id'] = $filters['keyword_id'][0] > 0) {
        $applyFilters = true;
        switch ($specViewType) {
            case 'testplan':
                $tobj_mgr = new testplan($dbHandler);
                break;
        }
        $tck_map = $tobj_mgr->get_keywords_tcases($masterContainerId, $filters['keyword_id']);
    }
    if ($applyFilters) {
        $key2loop = array_keys($test_spec);
        // first step: generate list of TEST CASE NODES
        $itemSet = null;
        foreach ($key2loop as $key) {
            if ($test_spec[$key]['node_type_id'] == $filters['tcase_node_type_id']) {
                $itemSet[$test_spec[$key]['id']] = $key;
            }
        }
        $itemKeys = $itemSet;
        foreach ($itemKeys as $key => $tspecKey) {
            // case insensitive search
            if ($useFilter['keyword_id'] && !isset($tck_map[$test_spec[$tspecKey]['id']]) || $useFilter['tcase_id'] && !in_array($test_spec[$tspecKey]['id'], $testCaseSet) || $useFilter['tcase_name'] && stripos($test_spec[$tspecKey]['name'], $filters['tcase_name']) === false) {
                $test_spec[$tspecKey] = null;
                unset($itemSet[$key]);
            }
        }
        if (count($itemSet) > 0 && ($useFilter['execution_type'] || $useFilter['importance'] || $useFilter['cfields'] || $useFilter['status'])) {
            // This logic can have some Potential Performance ISSUE - 20120619 - fman
            $targetSet = array_keys($itemSet);
            $options = $specViewType == 'testPlanLinking' ? array('access_key' => 'testcase_id') : null;
            $getFilters = $useFilter['cfields'] ? array('cfields' => $filters['cfields']) : null;
            $s2h = config_get('tplanDesign')->hideTestCaseWithStatusIn;
            if (!is_null($s2h)) {
                $getFilters['status'] = array('not_in' => array_keys($s2h));
            }
            $tcversionSet = $tcaseMgr->get_last_active_version($targetSet, $getFilters, $options);
            switch ($specViewType) {
                case 'testPlanLinking':
                    // We need to analise linked items and spec
                    foreach ($targetSet as $idx => $key) {
                        $targetTestCase = isset($tcversionSet[$key]) ? $tcversionSet[$key]['testcase_id'] : null;
                        if (is_null($targetTestCase)) {
                            $test_spec[$itemSet[$key]] = null;
                            $item = null;
                        } else {
                            if (isset($linkedItems[$targetTestCase])) {
                                $item = current($linkedItems[$targetTestCase]);
                            } else {
                                // hmmm, does not understand this logic.
                                $item = null;
                                if (isset($test_spec[$itemSet[$targetTestCase]])) {
                                    $item = $tcversionSet[$targetTestCase];
                                }
                            }
                        }
                        if (!is_null($item)) {
                            if ($useFilter['execution_type'] && $item['execution_type'] != $filters['execution_type'] || $useFilter['importance'] && !isset($filtersByValue['importance'][$item['importance']]) || $useFilter['status'] && !isset($filtersByValue['status'][$item['status']])) {
                                $tspecKey = $itemSet[$targetTestCase];
                                $test_spec[$tspecKey] = null;
                            }
                        }
                    }
                    break;
                default:
                    $tcvidSet = array_keys($tcversionSet);
                    foreach ($tcvidSet as $zx) {
                        $tcidSet[$tcversionSet[$zx]['testcase_id']] = $zx;
                    }
                    $options = null;
                    $doFilter = true;
                    $allowedSet = null;
                    // a first clean will not be bad, ok may be we are going to do more
                    // loops that needed, but think logic will be more clear
                    // (at least @20130426 is a little bit confusing ;) )
                    foreach ($targetSet as $idx => $key) {
                        if (!isset($tcidSet[$key])) {
                            $test_spec[$itemSet[$key]] = null;
                        }
                    }
                    if ($useFilter['execution_type']) {
                        // Potential Performance ISSUE
                        $allowedSet = $tcaseMgr->filter_tcversions_by_exec_type($tcvidSet, $filters['execution_type'], $options);
                        $doFilter = !is_null($allowedSet) && count($allowedSet) > 0;
                    }
                    if ($doFilter) {
                        // Add another filter on cascade mode
                        // @20130426 - seems we are applying TWICE the Custom Fields Filter
                        // because we have applied it before on:
                        // $tcversionSet = $tcaseMgr->get_last_active_version()
                        if ($useFilter['cfields']) {
                            $filteredSet = !is_null($allowedSet) && count($allowedSet) > 0 ? array_keys($allowedSet) : $tcvidSet;
                            $dummySet = $tcaseMgr->filter_tcversions_by_cfields($filteredSet, $filters['cfields'], $options);
                            // transform to make compatible with filter_tcversions_by_exec_type() return type
                            if (!is_null($dummySet) && count($dummySet) > 0) {
                                $allowedSet = null;
                                $work2do = array_keys($dummySet);
                                foreach ($work2do as $wkey) {
                                    $allowedSet[$wkey] = $dummySet[$wkey][0];
                                }
                                unset($dummySet);
                            }
                        }
                    }
                    if (!is_null($allowedSet) && count($allowedSet) > 0) {
                        $useAllowed = true;
                        foreach ($allowedSet as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey]['version'] = $value['version'];
                        }
                        reset($allowedSet);
                    }
                    $setToRemove = array_diff_key($tcversionSet, $allowedSet);
                    if (!is_null($setToRemove) && count($setToRemove) > 0) {
                        foreach ($setToRemove as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey] = null;
                        }
                    }
                    break;
            }
            // end switch
        }
    }
    // if apply filters
    unset($tobj_mgr);
    return $test_spec;
}
コード例 #5
0
ファイル: specview.php プロジェクト: moraesmv/testlink-code
/**
 * get Test Specification data within a Node
 *  
 *	using nodeId (that normally is a test suite id) as starting point
 *	will return subtree that start at nodeId.
 *	If filters are given, the subtree returned is filtered.
 * 
 *	Important Notice regaring keyword filtering
 *	Keyword filter logic inside this function seems to work ONLY on OR mode.
 *	Then how the AND mode is implemented ?
 *	Filter for test case id is used, and the test case set has been generated
 *	applying AND or OR logic (following user's choice).
 *	Then seems that logic regarding keywords here, may be can be removed
 *
 * @param integer $masterContainerId can be a Test Project Id, or a Test Plan id.
 *                is used only if keyword id filter has been specified
 *                to get all keyword defined on masterContainer.
 *
 * @param integer $nodeId node that will be root of the view we want to build.
 * 
 * @param string $specViewType: type of view requested
 *
 * @param array $filters
 *	  			filters['keyword_id']: array of keywords  
 *	  			filters['tcase_id']: 
 *	  			filters['execution_type']: 
 *	  			filters['importance']: 
 *	  			filters['cfields']: 
 *	  			filters['tcase_name']: 
 *
 * 
 * @return array map with view (test cases subtree)
 * 
 * @internal revisions
 * 20101024 - franciscom - BUGID 3932: Add test case to test plan - Execution type filter does not affect right pane
 *						   BUGID 3936: Assign Test Case Execution - Right pane does not reflect custom field filter.
 *
 * 20100417 - franciscom - BUGID 2498 - added logic to filter by importance (defined on test case spec)
 * 20100411 - franciscom - added logic to filter by execution type
 */
function getTestSpecFromNode(&$dbHandler, &$tcaseMgr, &$linkedItems, $masterContainerId, $nodeId, $specViewType, $filters)
{
    $applyFilters = false;
    $testCaseSet = null;
    $tck_map = null;
    $tobj_mgr = new testproject($dbHandler);
    $test_spec = $tobj_mgr->get_subtree($nodeId);
    $key2loop = null;
    $useAllowed = false;
    // 20100411 - BUGID 2797 - filter by test case execution type
    $nullCheckFilter = array('tcase_id' => false, 'importance' => false, 'tcase_name' => false, 'cfields' => false);
    $zeroNullCheckFilter = array('execution_type' => false);
    $useFilter = array('keyword_id' => false) + $nullCheckFilter + $zeroNullCheckFilter;
    foreach ($nullCheckFilter as $key => $value) {
        $useFilter[$key] = !is_null($filters[$key]);
        $applyFilters = $applyFilters || $useFilter[$key];
    }
    foreach ($zeroNullCheckFilter as $key => $value) {
        // need to check for > 0, because for some items 0 has same meaning that null -> no filter
        $useFilter[$key] = !is_null($filters[$key]) && $filters[$key] > 0;
        $applyFilters = $applyFilters || $useFilter[$key];
    }
    if ($useFilter['tcase_id']) {
        $testCaseSet = is_array($filters['tcase_id']) ? $filters['tcase_id'] : array($filters['tcase_id']);
    }
    // BUGID 3768
    if (!is_array($filters['keyword_id'])) {
        $filters['keyword_id'] = array($filters['keyword_id']);
    }
    if ($useFilter['keyword_id'] = $filters['keyword_id'][0] > 0) {
        $applyFilters = true;
        switch ($specViewType) {
            case 'testplan':
                $tobj_mgr = new testplan($dbHandler);
                break;
        }
        $tck_map = $tobj_mgr->get_keywords_tcases($masterContainerId, $filters['keyword_id']);
    }
    if ($applyFilters) {
        $key2loop = array_keys($test_spec);
        // first step: generate list of TEST CASE NODES
        $itemSet = null;
        foreach ($key2loop as $key) {
            if ($test_spec[$key]['node_type_id'] == $filters['tcase_node_type_id']) {
                $itemSet[$test_spec[$key]['id']] = $key;
            }
        }
        $itemKeys = $itemSet;
        foreach ($itemKeys as $key => $tspecKey) {
            // 20101209 - asimon - exchanged strpos by stripos to make search case insensitive
            if ($useFilter['keyword_id'] && !isset($tck_map[$test_spec[$tspecKey]['id']]) || $useFilter['tcase_id'] && !in_array($test_spec[$tspecKey]['id'], $testCaseSet) || $useFilter['tcase_name'] && stripos($test_spec[$tspecKey]['name'], $filters['tcase_name']) === false) {
                $test_spec[$tspecKey] = null;
                unset($itemSet[$key]);
            }
        }
        if (count($itemSet) > 0 && ($useFilter['execution_type'] || $useFilter['importance'] || $useFilter['cfields'])) {
            $targetSet = array_keys($itemSet);
            $options = $specViewType == 'testPlanLinking' ? array('access_key' => 'testcase_id') : null;
            // BUGID 3889: Add Test Cases to Test plan - Right pane does not honor custom field filter
            $getFilters = $useFilter['cfields'] ? array('cfields' => $filters['cfields']) : null;
            // BUGID 4025 - add test case (specification) status filter
            $tcstatus = config_get('tplanDesign')->hideTestCaseWithStatusIn;
            if (!is_null($tcstatus)) {
                $getFilters['status'] = array('not_in' => array_keys($tcstatus));
            }
            $tcversionSet = $tcaseMgr->get_last_active_version($targetSet, $getFilters, $options);
            switch ($specViewType) {
                case 'testPlanLinking':
                    // We need to analise linked items and spec
                    foreach ($targetSet as $idx => $key) {
                        $targetTestCase = isset($tcversionSet[$key]) ? $tcversionSet[$key]['testcase_id'] : null;
                        // BUGID 3936 - Design Time Custom Field Filter
                        if (is_null($targetTestCase)) {
                            $test_spec[$itemSet[$key]] = null;
                            //BUGID 4024
                            $item = null;
                        } else {
                            if (isset($linkedItems[$targetTestCase])) {
                                $item = current($linkedItems[$targetTestCase]);
                            } else {
                                // hmmm, does not understand this logic.
                                $item = null;
                                if (isset($test_spec[$itemSet[$targetTestCase]])) {
                                    $item = $tcversionSet[$targetTestCase];
                                }
                            }
                        }
                        if (!is_null($item)) {
                            if ($useFilter['execution_type'] && $item['execution_type'] != $filters['execution_type'] || $useFilter['importance'] && $item['importance'] != $filters['importance']) {
                                $tspecKey = $itemSet[$targetTestCase];
                                $test_spec[$tspecKey] = null;
                            }
                        }
                    }
                    break;
                default:
                    $tcvidSet = array_keys($tcversionSet);
                    $options = null;
                    // BUGID 3934
                    $doFilter = true;
                    $allowedSet = null;
                    if ($useFilter['execution_type']) {
                        $allowedSet = $tcaseMgr->filter_tcversions_by_exec_type($tcvidSet, $filters['execution_type'], $options);
                        $doFilter = !is_null($allowedSet) && count($allowedSet) > 0;
                    }
                    if ($doFilter) {
                        // Add another filter on cascade mode
                        // BUGID 3936: Assign Test Case Execution - Right pane does not reflect custom field filter.
                        if ($useFilter['cfields']) {
                            $filteredSet = !is_null($allowedSet) && count($allowedSet) > 0 ? array_keys($allowedSet) : $tcvidSet;
                            $dummySet = $tcaseMgr->filter_tcversions_by_cfields($filteredSet, $filters['cfields'], $options);
                            // transform to make compatible with filter_tcversions_by_exec_type() return type
                            if (!is_null($dummySet) && count($dummySet) > 0) {
                                $allowedSet = null;
                                $work2do = array_keys($dummySet);
                                foreach ($work2do as $wkey) {
                                    $allowedSet[$wkey] = $dummySet[$wkey][0];
                                }
                                unset($dummySet);
                            }
                        }
                    }
                    if (!is_null($allowedSet) && count($allowedSet) > 0) {
                        $useAllowed = true;
                        foreach ($allowedSet as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey]['version'] = $value['version'];
                        }
                        reset($allowedSet);
                    }
                    $setToRemove = array_diff_key($tcversionSet, $allowedSet);
                    if (!is_null($setToRemove) && count($setToRemove) > 0) {
                        foreach ($setToRemove as $key => $value) {
                            $tspecKey = $itemSet[$value['testcase_id']];
                            $test_spec[$tspecKey] = null;
                        }
                    }
                    break;
            }
            // end switch
        }
    }
    // if apply filters
    unset($tobj_mgr);
    return $test_spec;
}
コード例 #6
0
 /**
  * Returns all test suites inside target 
  * test project with target name
  *
  * @param
  * @param struct $args
  * @param string $args["devKey"]
  * @param int $args["testsuitename"]
  * @param string $args["prefix"]
  * @return mixed $resultInfo
  * 
  * @access public
  */
 public function getTestSuite($args)
 {
     $ope = __FUNCTION__;
     $msg_prefix = "({$ope}) - ";
     $this->_setArgs($args);
     $status_ok = $this->_runChecks(array('authenticate'), $msg_prefix);
     if ($status_ok) {
         // Check for mandatory parameters
         $k2s = array(self::$testSuiteNameParamName, self::$prefixParamName);
         foreach ($k2s as $target) {
             $ok = $this->_isParamPresent($target, $msg_prefix, self::SET_ERROR);
             $status_ok = $status_ok && $ok;
         }
     }
     if ($status_ok) {
         // optionals
         //$details='simple';
         //$k2s=self::$detailsParamName;
         //if( $this->_isParamPresent($k2s) )
         //{
         //  $details = $this->args[$k2s];
         //}
     }
     if ($status_ok) {
         $tprojectMgr = new testproject($this->dbObj);
         $pfx = $this->args[self::$prefixParamName];
         $tproj = $tprojectMgr->get_by_prefix($pfx);
         if (is_null($tproj)) {
             $status_ok = false;
             $msg = $msg_prefix . sprintf(TPROJECT_PREFIX_DOESNOT_EXIST_STR, $pfx);
             $this->errors[] = new IXR_Error(TPROJECT_PREFIX_DOESNOT_EXIST, $msg);
         } else {
             $ctx[self::$testProjectIDParamName] = $dummy['id'];
         }
     }
     if ($status_ok && $this->userHasRight("mgt_view_tc", self::CHECK_PUBLIC_PRIVATE_ATTR, $ctx)) {
         $opt = array('recursive' => false, 'exclude_testcases' => true);
         // $target = $this->dbObj->prepare_string($tg);
         // $filters['additionalWhereClause'] =
         // " AND name = '{$target}' ";
         $filters = null;
         $items = $tprojectMgr->get_subtree($tproj['id'], $filters, $opt);
         $ni = array();
         if (!is_null($items) && ($l2d = count($items)) > 0) {
             $tg = $this->args[self::$testSuiteNameParamName];
             for ($ydx = 0; $ydx <= $l2d; $ydx++) {
                 if (strcmp($items[$ydx]['name'], $tg) == 0) {
                     unset($items[$ydx]['tcversion_id']);
                     $ni[] = $items[$ydx];
                 }
             }
         } else {
             $ni = $items;
         }
     }
     return $status_ok ? $ni : $this->errors;
 }