本文整理汇总了PHP中testproject::get_by_prefix方法的典型用法代码示例。如果您正苦于以下问题:PHP testproject::get_by_prefix方法的具体用法?PHP testproject::get_by_prefix怎么用?PHP testproject::get_by_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testproject
的用法示例。
在下文中一共展示了testproject::get_by_prefix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$mustKeys = array('tprojectPrefix' => 'testproject_not_set', 'item' => 'item_not_set', 'id' => 'id_not_set');
foreach ($mustKeys as $key => $labelID) {
$op['status_ok'] = isset($_GET[$key]);
if (!$op['status_ok']) {
$op['msg'] = lang_get($labelID);
break;
}
}
$anchor = isset($_GET['anchor']) ? $_GET['anchor'] : null;
$version = isset($_GET['version']) ? $_GET['version'] : null;
$tprojectPrefix = isset($_GET['tprojectPrefix']) ? $_GET['tprojectPrefix'] : null;
$item = isset($_GET['item']) ? $_GET['item'] : null;
$id = isset($_GET['id']) ? $_GET['id'] : null;
if ($op['status_ok']) {
$tproject = new testproject($db);
$tproject_data = $tproject->get_by_prefix($tprojectPrefix);
if ($op['status_ok'] = !is_null($tproject_data)) {
$tproject->setCurrentProject($tproject_data['id']);
$op['status_ok'] = isset($itemCode[$item]);
$op['msg'] = sprintf(lang_get('invalid_item'), $item);
} else {
$op['msg'] = sprintf(lang_get('testproject_not_found'), $tprojectPrefix);
}
}
if ($op['status_ok']) {
// Build name of function to call for doing the job.
$pfn = 'process_' . $item;
$jump_to = $pfn($db, $id, $tproject_data['id'], $tprojectPrefix, $version);
$op['status_ok'] = !is_null($jump_to['url']);
$op['msg'] = $jump_to['msg'];
}
示例2: req_link_replace
//.........这里部分代码省略.........
} else {
$title[$key] = lang_get($elem['default_lbl']) . ": ";
}
}
}
}
$prefix = $tproject_mgr->getTestCasePrefix($tprojectID);
$string2replace = array();
// configure target in which link shall open
// use a reasonable default value if nothing is set in config
$cfg->target = isset($cfg->target) ? $cfg->target : 'popup';
switch ($cfg->target) {
case 'popup':
// use javascript to open popup window
$string2replace['req'] = '<a href="javascript:openLinkedReqVersionWindow(%s,%s,\'%s\')">%s%s%s</a>';
$string2replace['req_spec'] = '<a href="javascript:openLinkedReqSpecWindow(%s,\'%s\')">%s%s</a>';
break;
case 'window':
case 'frame':
// open in same frame
$target = $cfg->target == 'window' ? 'target="_blank"' : 'target="_self"';
$string2replace['req'] = '<a ' . $target . ' href="lib/requirements/reqView.php?' . 'item=requirement&requirement_id=%s&req_version_id=%s#%s">%s%s%s</a>';
$string2replace['req_spec'] = '<a ' . $target . ' href="lib/requirements/reqSpecView.php?' . 'item=req_spec&req_spec_id=%s#%s">%s%s</a>';
break;
}
// now the actual replacing
$patterns2search = array();
$patterns2search['req'] = "#\\[req(.*)\\](.*)\\[/req\\]#iU";
$patterns2search['req_spec'] = "#\\[req_spec(.*)\\](.*)\\[/req_spec\\]#iU";
$patternPositions = array('complete_string' => 0, 'attributes' => 1, 'doc_id' => 2);
$items2search['req'] = array('tproj', 'anchor', 'version');
$items2search['req_spec'] = array('tproj', 'anchor');
$itemPositions = array('item' => 0, 'item_value' => 1);
$sql2exec = array();
$sql2exec['req'] = " SELECT id, req_doc_id AS doc_id " . " FROM {$tables['requirements']} WHERE req_doc_id=";
$sql2exec['req_spec'] = " SELECT id, doc_id FROM {$tables['req_specs']} " . " WHERE doc_id=";
foreach ($patterns2search as $accessKey => $pattern) {
$matches = array();
preg_match_all($pattern, $scope, $matches);
// if no req_doc_id is set skip loop
if (count($matches[$patternPositions['doc_id']]) == 0) {
continue;
}
foreach ($matches[$patternPositions['complete_string']] as $key => $matched_string) {
$matched = array();
$matched['tproj'] = '';
$matched['anchor'] = '';
$matched['version'] = '';
// only look for attributes if any found
if ($matches[$patternPositions['attributes']][$key] != '') {
foreach ($items2search[$accessKey] as $item) {
$matched_item = array();
preg_match('/' . $item . '=([\\w]+)/', $matched_string, $matched_item);
$matched[$item] = isset($matched_item[$itemPositions['item_value']]) ? $matched_item[$itemPositions['item_value']] : '';
}
}
// set tproj to current project if tproj is not specified in attributes
if (!isset($matched['tproj']) || $matched['tproj'] == '') {
$matched['tproj'] = $prefix;
}
// get all reqs / req specs with the specified doc_id
$sql = $sql2exec[$accessKey] . "'{$matches[$patternPositions['doc_id']][$key]}'";
$rs = $dbHandler->get_recordset($sql);
if (count($rs) > 0) {
foreach ($rs as $key => $value) {
// get root of linked node and check
$real_root = $tree_mgr->getTreeRoot($value['id']);
$matched_root_info = $tproject_mgr->get_by_prefix($matched['tproj']);
// do only continue if project with the specified project exists and
// if the requirement really belongs to the specified project (requirements
// with the same doc_id may exist within different projects)
if ($real_root == $matched_root_info['id']) {
if ($accessKey == 'req') {
// add version to link title if set
$version = '';
$req_version_id = 'null';
if ($matched['version'] != '') {
// get requirement version_id of the specified version
$req_version = $req_mgr->get_by_id($value['id'], null, $matched['version']);
// if version is not set or wrong version was set
// -> show latest version by setting version_id to null
$req_version_id = isset($req_version[0]['version_id']) ? $req_version[0]['version_id'] : 'null';
// if req_version_id exists set the version to show on hyperlink text
if ($req_version_id != 'null') {
$version = sprintf($l18n['version'], $matched['version']);
}
}
$urlString = sprintf($string2replace[$accessKey], $value['id'], $req_version_id, $matched['anchor'], $title[$accessKey], $value['doc_id'], $version);
} else {
// build urlString for req specs which do not have a version
$urlString = sprintf($string2replace[$accessKey], $value['id'], $matched['anchor'], $title[$accessKey], $value['doc_id']);
}
$scope = str_replace($matched_string, $urlString, $scope);
}
}
}
}
}
return $scope;
}
示例3: systemWideTestCaseSearch
/**
*
*
*/
function systemWideTestCaseSearch(&$dbHandler, &$argsObj, $glue)
{
// Attention:
// this algorithm has potential flaw (IMHO) because we can find the glue character
// in situation where it's role is not this.
// Anyway i will work on this in the future (if I've time)
//
if (strpos($argsObj->targetTestCase, $glue) === false) {
// We suppose user was lazy enough to do not provide prefix,
// then we will try to help him/her
$argsObj->targetTestCase = $argsObj->tcasePrefix . $argsObj->targetTestCase;
}
if (!is_null($argsObj->targetTestCase)) {
// parse to get JUST prefix, find the last glue char.
// This useful because from navBar, user can request search of test cases that belongs
// to test project DIFFERENT to test project setted in environment
if (($gluePos = strrpos($argsObj->targetTestCase, $glue)) !== false) {
$tcasePrefix = substr($argsObj->targetTestCase, 0, $gluePos);
}
$tprojectMgr = new testproject($dbHandler);
$argsObj->tcaseTestProject = $tprojectMgr->get_by_prefix($tcasePrefix);
$tcaseMgr = new testcase($dbHandler);
$argsObj->tcase_id = $tcaseMgr->getInternalID($argsObj->targetTestCase);
$dummy = $tcaseMgr->get_basic_info($argsObj->tcase_id, array('number' => $argsObj->tcaseVersionNumber));
if (!is_null($dummy)) {
$argsObj->tcversion_id = $dummy[0]['tcversion_id'];
}
}
}
示例4: req_link_replace
/**
* replace BBCode-link tagged links in req/reqspec scope with actual links
*
* @internal revisions:
* 20100301 - asimon - added anchor and tproj parameters to tags
*
* @param resource $dbHandler database handle
* @param string $scope text in which to replace tags with links
* @param integer $tprojectID ID of testproject to which req/reqspec belongs
* @return string $scope text with generated links
*/
function req_link_replace($dbHandler, $scope, $tprojectID)
{
$tree_mgr = new tree($dbHandler);
$tproject_mgr = new testproject($dbHandler);
$prefix = $tproject_mgr->getTestCasePrefix($tprojectID);
$tables = tlObjectWithDB::getDBTables(array('requirements', 'req_specs'));
$cfg = config_get('internal_links');
$string2replace = array();
$title = array();
// configure target in which link shall open
// use a reasonable default value if nothing is set in config
$cfg->target = isset($cfg->target) ? $cfg->target : 'popup';
switch ($cfg->target) {
case 'popup':
// use javascript to open popup window
$string2replace['req'] = '<a href="javascript:openLinkedReqWindow(%s,\'%s\')">%s%s</a>';
$string2replace['req_spec'] = '<a href="javascript:openLinkedReqSpecWindow(%s,\'%s\')">%s%s</a>';
break;
case 'window':
case 'frame':
// open in same frame
$target = $cfg->target == 'window' ? 'target="_blank"' : 'target="_self"';
$string2replace['req'] = '<a ' . $target . ' href="lib/requirements/reqView.php?' . 'item=requirement&requirement_id=%s#%s">%s%s</a>';
$string2replace['req_spec'] = '<a ' . $target . ' href="lib/requirements/reqSpecView.php?' . 'item=req_spec&req_spec_id=%s#%s">%s%s</a>';
break;
}
// configure link title (first part of the generated link)
// default: use item type as name (localized name for req)
$title['req'] = lang_get('requirement') . ": ";
// default: use short item type as name (localized name for req spec)
$title['req_spec'] = lang_get('req_spec_short') . ": ";
if ($cfg->req_link_title->type == 'string' && $cfg->req_link_title->value != '') {
$title['req'] = lang_get($cfg->req_link_title->value);
} else {
if ($cfg->req_link_title->type == 'none') {
$title['req'] = '';
}
}
// now for the req specs
if ($cfg->req_spec_link_title->type == 'string' && $cfg->req_spec_link_title->value != '') {
// use user-configured string as link title
$title['req_spec'] = lang_get($cfg->req_spec_link_title->value);
} else {
if ($cfg->req_spec_link_title->type == 'none') {
$title['req_spec'] = '';
}
}
// now the actual replacing
$patterns2search = array();
$patterns2search['req'] = "#\\[req[\\s]*(tproj=([\\w]+))*[\\s]*(anchor=([\\w]+))*[\\s]*(tproj=([\\w]+))*\\](.*)\\[/req\\]#iU";
$patterns2search['req_spec'] = "#\\[req_spec[\\s]*(tproj=([\\w]+))*[\\s]*(anchor=([\\w]+))*[\\s]*(tproj=([\\w]+))*\\](.*)\\[/req_spec\\]#iU";
$sql2exec = array();
$sql2exec['req'] = " SELECT id, req_doc_id AS doc_id " . " FROM {$tables['requirements']} WHERE req_doc_id=";
$sql2exec['req_spec'] = " SELECT id, doc_id FROM {$tables['req_specs']} " . " WHERE doc_id=";
foreach ($patterns2search as $accessKey => $pattern) {
$matches = array();
preg_match_all($pattern, $scope, $matches);
if (count($matches[7]) == 0) {
continue;
}
foreach ($matches[0] as $key => $matched_string) {
// get testproject prefix, if that was found with regex
// if not, get prefix of current project
if ($matches[2][$key] != '') {
$matched_prefix = $matches[2][$key];
} else {
if ($matches[6][$key] != '') {
$matched_prefix = $matches[6][$key];
} else {
$matched_prefix = $prefix;
}
}
$matched_anchor = $matches[4][$key];
$matched_doc_id = $matches[7][$key];
$sql = $sql2exec[$accessKey] . "'{$matched_doc_id}'";
$rs = $dbHandler->get_recordset($sql);
if (count($rs)) {
//20100818 - Julian - fixed error if same doc_id exists in multiple projects
foreach ($rs as $key => $value) {
// get root of linked node and check
$real_root = $tree_mgr->getTreeRoot($value['id']);
$matched_root_info = $tproject_mgr->get_by_prefix($matched_prefix);
if ($real_root == $matched_root_info['id']) {
$urlString = sprintf($string2replace[$accessKey], $value['id'], $matched_anchor, $title[$accessKey], $value['doc_id']);
$scope = str_replace($matched_string, $urlString, $scope);
}
}
}
}
//.........这里部分代码省略.........
示例5: init_args
/**
*
*
*/
function init_args(&$dbHandler)
{
$_REQUEST = strings_stripSlashes($_REQUEST);
$iParams = array("edit" => array(tlInputParameter::STRING_N, 0, 50), "id" => array(tlInputParameter::INT_N), "show_path" => array(tlInputParameter::INT_N), "show_mode" => array(tlInputParameter::STRING_N, 0, 50), "tcase_id" => array(tlInputParameter::INT_N), "tcversion_id" => array(tlInputParameter::INT_N), "tproject_id" => array(tlInputParameter::INT_N), "targetTestCase" => array(tlInputParameter::STRING_N, 0, 24), "tcasePrefix" => array(tlInputParameter::STRING_N, 0, 16), "tcaseExternalID" => array(tlInputParameter::STRING_N, 0, 16), "tcaseVersionNumber" => array(tlInputParameter::INT_N));
$args = new stdClass();
R_PARAMS($iParams, $args);
// For more information about the data accessed in session here, see the comment
// in the file header of lib/functions/tlTestCaseFilterControl.class.php.
$form_token = isset($_REQUEST['form_token']) ? $_REQUEST['form_token'] : 0;
$mode = 'edit_mode';
$cfg = config_get('testcase_cfg');
$session_data = isset($_SESSION[$mode]) && isset($_SESSION[$mode][$form_token]) ? $_SESSION[$mode][$form_token] : null;
$args->refreshTree = isset($session_data['setting_refresh_tree_on_action']) ? $session_data['setting_refresh_tree_on_action'] : 0;
$args->user_id = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0;
$args->feature = $args->edit;
$args->opt_requirements = null;
$args->automationEnabled = 0;
$args->requirementsEnabled = 0;
$args->testPriorityEnabled = 0;
$args->tcasePrefix = trim($args->tcasePrefix);
$tprojectMgr = new testproject($dbHandler);
if ($args->tproject_id <= 0 && strlen($args->tcaseExternalID) > 0) {
// parse to get JUST prefix
$gluePos = strrpos($args->tcaseExternalID, $cfg->glue_character);
// Find the last glue char
$status_ok = $gluePos !== false;
if ($status_ok) {
$tcasePrefix = substr($args->tcaseExternalID, 0, $gluePos);
}
$dummy = $tprojectMgr->get_by_prefix($tcasePrefix);
$tcaseMgr = new testcase($dbHandler);
$args->tcase_id = $tcaseMgr->getInternalID($args->tcaseExternalID);
$tcinfo = $tcaseMgr->get_basic_info($args->tcase_id, array('number' => $args->tcaseVersionNumber));
if (!is_null($tcinfo)) {
$args->tcversion_id = $tcinfo[0]['tcversion_id'];
}
unset($tcaseMgr);
} else {
$dummy = $tprojectMgr->get_by_id($args->tproject_id);
}
if (!is_null($dummy)) {
$args->tproject_id = $dummy['id'];
}
$args->opt_requirements = $dummy['opt']->requirementsEnabled;
$args->requirementsEnabled = $dummy['opt']->requirementsEnabled;
$args->automationEnabled = $dummy['opt']->automationEnabled;
$args->testPriorityEnabled = $dummy['opt']->testPriorityEnabled;
if (!$args->tcversion_id) {
$args->tcversion_id = testcase::ALL_VERSIONS;
}
// used to manage goback
if (intval($args->tcase_id) > 0) {
$args->feature = 'testcase';
$args->id = intval($args->tcase_id);
}
$args->id = is_null($args->id) ? 0 : $args->id;
switch ($args->feature) {
case 'testsuite':
$_SESSION['setting_refresh_tree_on_action'] = $args->refreshTree ? 1 : 0;
break;
case 'testproject':
$args->id = $args->tproject_id;
break;
}
if (strpos($args->targetTestCase, $cfg->glue_character) === false) {
$args->targetTestCase = $args->tcasePrefix . $args->targetTestCase;
}
return $args;
}
示例6: getTestSuite
/**
* 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;
}
示例7: checkTestProject
/**
*
*
*/
function checkTestProject(&$db, &$user, &$args)
{
$hasRight = false;
$tproject_mgr = new testproject($db);
$item_info = $tproject_mgr->get_by_prefix($args->tprojectPrefix);
if ($op['status_ok'] = !is_null($item_info)) {
$args->tproject_id = intval($item_info['id']);
switch ($args->item) {
case 'testcase':
case 'testsuite':
$hasRight = $user->hasRight($db, 'mgt_view_tc', $args->tproject_id);
break;
case 'req':
case 'reqspec':
$hasRight = $user->hasRight($db, 'mgt_view_req', $args->tproject_id);
break;
default:
// need to fail!!
break;
}
}
return $hasRight;
}