/** * 执行新增操作 */ public function doAdd() { $plan = D("Plan"); $data = M("Plan")->create(); if (!empty($data['data'])) { $result = $plan->parseParam($data['data']); if (!$result) { $this->ajaxReturn(null, '您定义了私有参数,但是定义的格式有误!', 'success:false'); } $ret = $plan->checkParam($result); if ($ret['status'] === false) { $this->ajaxReturn(null, "有部分参数定义无效[" . $ret['data'] . "]", 'success:false'); } } if (empty($data['caseIds'])) { $this->ajaxReturn(null, "请添加测试用例", "success:false"); } $data['caseIds'] = implode(',', $data['caseIds']); $data['appId'] = getAppId(); $data['userId'] = getUserId(); $data['updateTime'] = getCurrentTime(); $ret = $plan->add($data); if (empty($ret)) { $this->ajaxReturn(null, '新增测试计划失败', 'success:false'); } $this->ajaxReturn($ret, '成功', 'success:true'); }
public function modules() { $where['status'] = C("VALID"); $where['appId'] = getAppId(); $modules = D("Module")->getModule($where); $this->assign("datas", $modules); $this->ajaxReturn($this->fetch(), "成功", 'success:true'); }
public function getApis($condition) { $condition['status'] = C('VALID'); $condition['appId'] = getAppId(); $apis = M('Api')->where($condition)->order('createTime desc')->limit(9)->select(); if (empty($apis)) { return false; } return $apis; }
/** * merge 查询条件 * @param 原生查询条件 $old * @return merge之后的查询条件 */ public function merge($old = null) { $condition['appId'] = getAppId(); $condition['status'] = C('VALID'); if (empty($old)) { return $condition; } else { return array_merge($old, $condition); } }
public function keyExist($data) { $key = $data['key']; $where['appId'] = getAppId(); $where['key'] = $key; $ret = $this->where($where)->select(); if (empty($ret)) { return true; } return false; }
public function index() { $where['appId'] = getAppId(); $users = D('UserApp')->where($where)->select(); $where['status'] = C('VALID'); $totalApi = D('Api')->where($where)->count(); $totalCase = D('Case')->where($where)->count(); $data = array(); foreach ($users as $user) { $where['userId'] = $user['userId']; $temp['username'] = getUserName($user['userId']); $temp['apiCount'] = D('Api')->where($where)->count(); $temp['caseCount'] = D('Case')->where($where)->count(); $data[] = $temp; } $this->assign('totalApi', $totalApi); $this->assign('totalCase', $totalCase); $this->assign("data", $data); $this->display(); }
/** * 获取与输入key相关的推荐 */ public function keys() { $key = $this->_get("key"); $condition['key'] = array('like', '%' . $key . '%'); $condition['appId'] = getAppId(); $keys = M("Data")->where($condition)->field('key')->select(); $temp = array(); foreach ($keys as $key) { $temp[] = $key['key']; } $this->ajaxReturn(json_encode($temp), '成功', 'success:true'); }
} else { $response = addApplication($email, $password, $dbName, $appId); } if (isOK($response)) { printResult($response, "CONNECTING APPLICATION TO CVS DB FAILED", " Application {$appId} has been connected to the database {$dbName}." . PHP_EOL . " ---- CONNECTING APPLICATION TO CVS DB SUCCESSFULLY COMPLETED ----"); } else { echo $response->getMessage(); } break; case "deleteApplication": $msg = "Deleting Application ..." . PHP_EOL; echo PHP_EOL . "{$msg}"; $email = getEMail(); $password = getPassword(); $dbName = getDbName(); $appId = getAppId(); if (is_numeric($appId)) { $response = deleteChannel($email, $password, $dbName, $appId); } else { $response = deleteApplication($email, $password, $dbName, $appId); } if (isOK($response)) { printResult($response, "DELETING APPLICATION FROM CVS FAILED", " Application {$appId} has been deleted from the database {$dbName}." . PHP_EOL . " ---- DELETING APPLICATION FROM CVS SUCCESSFULLY COMPLETED ----"); } else { echo $response->getMessage(); } break; case "addItem": echo "Adding item..." . PHP_EOL; $email = getEMail(); $password = getPassword();
function getUserApp() { return array('appId' => getAppId(), 'userId' => getUserId()); }
/** * 根据ID获取case */ public function getCase() { $id = $this->_get('id'); $desc = $this->_get('desc'); if (!empty($id)) { $where['id'] = $id; } if (!empty($desc)) { $where['desc'] = array('like', "%{$desc}%"); } if (empty($where)) { $this->ajaxReturn(null, '请输入查询条件', 'success:false'); } $where['status'] = C("VALID"); $where['type'] = array('neq', 2); //排除异常类型的用例 $where['appId'] = getAppId(); $case = D('Case')->where($where)->field('id,desc')->limit(10)->select(); if (empty($case)) { $this->ajaxReturn(null, "没有找到id={$id的测试用例}", 'success:false'); } $this->ajaxReturn(json_encode($case), '查询成功', 'success:true'); }
/** * 获取与输入api-path相关的推荐 */ public function apis() { $path = $this->_get("path"); $condition['path'] = array('like', '%' . $path . '%'); $condition['appId'] = getAppId(); $apis = D("Api")->where($condition)->field('path')->select(); $temp = array(); foreach ($apis as $api) { $temp[] = $api['path']; } $this->ajaxReturn(json_encode($temp), '成功', 'success:true'); }
/** * 检查某一个case是否被其他plan引用 */ public function planUsing($caseId) { $where['appId'] = getAppId(); $plans = D("Plan")->where($where)->select(); if (empty($plans)) { return null; } $pids = array(); foreach ($plans as $plan) { if (in_array($caseId, explode(',', $plan['caseIds']))) { $pids[] = $plan['id']; } } return implode(',', array_unique($pids)); }