/** * Get test case executions by BuildId and RequirementId and PlatformId * * @param struct $args * @param string $args["devKey"] * @param int $args["testprojectid"] * @param int $args["buildid"] * @param int $args["requirementid"] * @param int $args["platformid"] * @return mixed * @access public */ public function getTestCasesExecutionsByBuildAndPlatformAndRequirement($args) { $this->_setArgs($args); if (!$this->authenticate()) { return $this->errors; } $projectId = $this->args[self::$testProjectIDParamName]; $buildId = $this->args[self::$buildIDParamName]; $requirementId = $this->args[self::$requirementIDParamName]; $platformId = $this->args[self::$platformIDParamName]; $testProject = $this->tprojectMgr->get_by_id($projectId); $build = $this->buildMgr->get_by_id($buildId); $requirement = $this->reqMgr->get_by_id($requirementId); $platformMgr = new tlPlatform($this->dbObj, $projectId); $platform = $platformMgr->getById($platformId); $hasError = false; if (is_null($testProject)) { $this->errors[] = new IXR_ERROR(100007, 'Project does not exists'); $hasError = true; } else { if (is_null($build['id'])) { $this->errors[] = new IXR_ERROR(100100, 'Build does not exists'); $hasError = true; } else { if (is_null($requirement)) { $this->errors[] = new IXR_ERROR(100200, 'Requirement does not exists'); $hasError = true; } else { if (is_null($platform)) { $this->errors[] = new IXR_ERROR(100300, 'Platform does not exists'); $hasError = true; } } } } if ($hasError) { return $this->errors; } $sql = "SELECT NHTCV.parent_id AS tcase_id, E.status AS exec_status FROM testplan_tcversions TPTCV JOIN nodes_hierarchy NHTCV ON NHTCV.id = TPTCV.tcversion_id LEFT OUTER JOIN executions E ON E.testplan_id = TPTCV.testplan_id AND E.platform_id = TPTCV.platform_id AND E.tcversion_id = TPTCV.tcversion_id AND E.build_id = {$build['id']} WHERE TPTCV.testplan_id = {$build['testplan_id']} AND TPTCV.platform_id = {$platform['id']}"; $test_cases_executions = $this->dbObj->fetchRowsIntoMap($sql, 'tcase_id'); $testcase_ids = array_keys($test_cases_executions); if (empty($testcase_ids)) { return array_values(array()); } $in_clause = implode(",", (array) $testcase_ids); $sql = "SELECT testcase_id FROM req_coverage WHERE req_id IN ({$requirementId}) AND testcase_id IN ({$in_clause})"; $reqTestCasesIds = array_keys($this->dbObj->fetchRowsIntoMap($sql, 'testcase_id')); return $this->convert_test_cases($reqTestCasesIds, $test_cases_executions); }