/**
 * get linked versions filtered by Keyword ID
 * Filter is done ONLY on attributes THAT ARE COMMON to ALL test case versions,
 * because (till now) while adding/removing test cases user works on Test Spec Tree
 * and filter applied to this tree acts on:
 *
 * 1. attributes COMMON to all versions
 * 2. attributes present ON LAST ACTIVE version.
 *  
 * But do no make considerations regarding versions linked to test plan
 * DEV NOTE: may be this has to be changed in future ?  
 *
 * @param ref $dbHandler:
 * @param ref $argsObj: stdClass object with information about filters
 * @param ref $tplanMgr: test plan manager object
 * @param ref $tcaseMgr: test case manager object
 * @param map $options:  default null   (at today 20110820 seems not be used).
 *  
 * 
 *
 * @internal revisions
 * @since 1.9.14
 * 
 */
function getFilteredLinkedVersions(&$dbHandler, &$argsObj, &$tplanMgr, &$tcaseMgr, $options = null)
{
    static $tsuite_mgr;
    $doFilterByKeyword = !is_null($argsObj->keyword_id) && $argsObj->keyword_id > 0 ? true : false;
    // Multiple step algoritm to apply keyword filter on type=AND
    // get_*_tcversions filters by keyword ALWAYS in OR mode.
    //
    $filters = array('keyword_id' => $argsObj->keyword_id, 'platform_id' => null);
    if (property_exists($argsObj, 'control_panel') && intval($argsObj->control_panel['setting_platform']) > 0) {
        $filters['platform_id'] = intval($argsObj->control_panel['setting_platform']);
    }
    if (isset($options['assigned_on_build']) && $options['assigned_on_build'] > 0) {
        $filters['assigned_on_build'] = $options['assigned_on_build'];
    }
    // get test suites in branch to limit search
    $itemID = property_exists($argsObj, 'object_id') ? $argsObj->object_id : $argsObj->id;
    if (!is_null($itemID)) {
        // will get all test suites in this branch, in order to limit amount of data returned by
        // get_*_tcversions
        if (!$tsuite_mgr) {
            $tsuite_mgr = new testsuite($dbHandler);
        }
        $xx = $tsuite_mgr->get_branch($itemID);
        $xx .= $xx == '' ? $itemID : ',' . $itemID;
        $filters['tsuites_id'] = explode(',', $xx);
    }
    // $opx = array('addExecInfo' => true, 'specViewFields' => true) + (array)$options;
    $opx = array_merge(array('addExecInfo' => true, 'specViewFields' => true, 'tlFeature' => 'none'), (array) $options);
    switch ($opx['tlFeature']) {
        case 'testCaseExecTaskAssignment':
            $method2call = 'getLinkedTCVXmen';
            break;
        case 'testCaseTestPlanAssignment':
        default:
            $method2call = 'getLTCVNewGeneration';
            break;
    }
    if (isset($argsObj->testcases_to_show) && !is_null($argsObj->testcases_to_show)) {
        $filters['tcase_id'] = $argsObj->testcases_to_show;
    }
    if (isset($argsObj->platform_id) && $argsObj->platform_id > 0) {
        $filters['platform_id'] = $argsObj->platform_id;
    }
    $tplan_tcases = $tplanMgr->{$method2call}($argsObj->tplan_id, $filters, $opx);
    if (!is_null($tplan_tcases) && $doFilterByKeyword && $argsObj->keywordsFilterType == 'AND') {
        $filteredSet = $tcaseMgr->filterByKeyword(array_keys($tplan_tcases), $argsObj->keyword_id, $argsObj->keywordsFilterType);
        $filters = array('tcase_id' => array_keys($filteredSet));
        // HERE WE CAN HAVE AN ISSUE
        $tplan_tcases = $tplanMgr->getLTCVNewGeneration($argsObj->tplan_id, $filters, $opx);
    }
    return $tplan_tcases;
}
Example #2
0
/**
 * get linked versions filtered by Keyword ID
 * Filter is done ONLY on attributes THAT ARE COMMON to ALL test case versions,
 * because (till now) while adding/removing test cases user works on Test Spec Tree
 * and filter applied to this tree acts on:
 *
 * 1. attributes COMMON to all versions
 * 2. attributes present ON LAST ACTIVE version.
 *  
 * But do no make considerations regarding versions linked to test plan
 * DEV NOTE: may be this has to be changed in future ?  
 *
 * @param ref $dbHandler:
 * @param ref $argsObj: stdClass object with information about filters
 * @param ref $tplanMgr: test plan manager object
 * @param ref $tcaseMgr: test case manager object
 * @param map $options:  default null   (at today 20110820 seems not be used).
 *  
 * 
 *
 * @internal revisions
 * @since 1.9.8
 * 
 */
function getFilteredLinkedVersions(&$dbHandler, &$argsObj, &$tplanMgr, &$tcaseMgr, $options = null)
{
    static $tsuite_mgr;
    $doFilterByKeyword = !is_null($argsObj->keyword_id) && $argsObj->keyword_id > 0 ? true : false;
    // Multiple step algoritm to apply keyword filter on type=AND
    // get_*_tcversions filters by keyword ALWAYS in OR mode.
    //
    $filters = array('keyword_id' => $argsObj->keyword_id, 'platform_id' => null);
    if (property_exists($argsObj, 'control_panel') && intval($argsObj->control_panel['setting_platform']) > 0) {
        $filters['platform_id'] = intval($argsObj->control_panel['setting_platform']);
    }
    if (isset($options['assigned_on_build']) && $options['assigned_on_build'] > 0) {
        $filters['assigned_on_build'] = $options['assigned_on_build'];
    }
    // get test suites in branch to limit search
    $itemID = property_exists($argsObj, 'object_id') ? $argsObj->object_id : $argsObj->id;
    if (!is_null($itemID)) {
        // will get all test suites in this branch, in order to limit amount of data returned by
        // get_*_tcversions
        if (!$tsuite_mgr) {
            $tsuite_mgr = new testsuite($dbHandler);
        }
        $xx = $tsuite_mgr->get_branch($itemID);
        $xx .= $xx == '' ? $itemID : ',' . $itemID;
        $filters['tsuites_id'] = explode(',', $xx);
    }
    // $opx = array('addExecInfo' => true, 'specViewFields' => true,'addPriority' => true) +   (array)$options;
    // $opx = array('addExecInfo' => true, 'specViewFields' => true, 'orderBy' => ' execution_order ') +   (array)$options;
    $opx = array('addExecInfo' => true, 'specViewFields' => true) + (array) $options;
    $tplan_tcases = $tplanMgr->getLTCVNewGeneration($argsObj->tplan_id, $filters, $opx);
    if (!is_null($tplan_tcases) && $doFilterByKeyword && $argsObj->keywordsFilterType == 'AND') {
        $filteredSet = $tcaseMgr->filterByKeyword(array_keys($tplan_tcases), $argsObj->keyword_id, $argsObj->keywordsFilterType);
        $filters = array('tcase_id' => array_keys($filteredSet));
        $tplan_tcases = $tplanMgr->getLTCVNewGeneration($argsObj->tplan_id, $filters, $opx);
    }
    return $tplan_tcases;
}