diff --git a/test/class/action.class.php b/test/class/action.class.php deleted file mode 100644 index a66ca41e98..0000000000 --- a/test/class/action.class.php +++ /dev/null @@ -1,590 +0,0 @@ -objectModel = $tester->loadModel('action'); - $tester->dao->delete()->from(TABLE_ACTION)->where('action')->eq('login')->exec(); - } - - /** - * Test create a action. - * - * @param string $objectType - * @param int $objectID - * @param string $actionType - * @param string $comment - * @param string $extra - * @param string $actor - * @param bool $autoDelete - * @access public - * @return object - */ - public function createTest($objectType, $objectID, $actionType, $comment = '', $extra = '', $actor = '', $autoDelete = true) - { - $_SERVER['HTTP_HOST'] = 'pms.zentao.com'; - $_POST['uid'] = ''; - $objectID = $this->objectModel->create($objectType, $objectID, $actionType, $comment, $extra, $actor, $autoDelete); - - unset($_POST); - if(dao::isError()) return dao::getError(); - - return $objectID ? $this->objectModel->getById($objectID) : 0; - } - - /** - * Test update read field of action when view a task/bug. - * - * @param string $objectType - * @param int $objectID - * @access public - * @return array - */ - public function readTest($objectType, $objectID) - { - $this->objectModel->read($objectType, $objectID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->fetchAll(); - return $objects; - } - - /** - * Get the unread actions. - * - * @param int $actionID - * @access public - * @return object - */ - public function getUnreadActionsTest($actionID = 0) - { - $objects = $this->objectModel->getUnreadActions($actionID); - $objects = json_decode($objects); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get product, project, execution of the object. - * - * @param String $objectType - * @param Int $objectID - * @param String $actionType - * @param String $extra - * @access public - * @return array - */ - public function getRelatedFieldsTest($objectType, $objectID, $actionType = '', $extra = '') - { - $objects = $this->objectModel->getRelatedFields($objectType, $objectID, $actionType = '', $extra = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get actions of an object. - * - * @param string $objectType - * @param int $objectID - * @access public - * @return object - */ - public function getListTest($objectType, $objectID) - { - $objects = $this->objectModel->getList($objectType, $objectID); - - if(dao::isError()) return dao::getError(); - - $dirname = dirname(__DIR__) . DS; - - $objects[$objectID]->extra = str_replace($dirname, '', $objects[$objectID]->extra); - $objects[$objectID]->extra = trim($objects[$objectID]->extra, "\n"); - if(strpos($objects[$objectID]->extra, 'href') !== false) $objects[$objectID]->extra = 'a'; - - return $objects[$objectID]; - } - - /** - * Test process Project Actions change actionStype. - * - * @param array $actions - * @access public - * @return string - */ - public function processProjectActionsTest($actions) - { - global $tester; - $actions = $tester->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id'); - - $objects = $this->objectModel->processProjectActions($actions); - - if(dao::isError()) return dao::getError(); - - $IDs = array_keys($objects); - return implode(',', $IDs); - } - - /** - * Test get action by id. - * - * @param int $actionID - * @access public - * @return object - */ - public function getByIdTest($actionID) - { - $object = $this->objectModel->getById($actionID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * getTrashesBySearchTest - * - * @param string $objectType - * @param string $type all|hidden - * @param int $queryID - * @param string $orderBy - * @param object $pager - * @access public - * @return void - */ - public function getTrashesBySearchTest($objectType, $type, $queryID, $orderBy, $pager = null) - { - $objects = $this->objectModel->getTrashesBySearch($objectType, $type, $queryID, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get deleted objects. - * - * @param string $objectType - * @param string $type - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getTrashesTest($objectType, $type, $orderBy, $pager) - { - $objects = $this->objectModel->getTrashes($objectType, $type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get object type list of trashes. - * - * @param string $type - * @access public - * @return array - */ - public function getTrashObjectTypesTest($type) - { - $objects = $this->objectModel->getTrashObjectTypes($type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get histories of an action. - * - * @param int $actionID - * @access public - * @return array - */ - public function getHistoryTest($actionID) - { - $objects = $this->objectModel->getHistory($actionID); - - if(dao::isError()) return dao::getError(); - - return $objects[$actionID]; - } - - /** - * Test log histories for an action. - * - * @param int $actionID - * @param array $changes - * @access public - * @return array - */ - public function logHistoryTest($actionID, $changes) - { - $this->objectModel->logHistory($actionID, $changes); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_HISTORY)->where('action')->eq($actionID)->fetchAll(); - return $objects; - } - - /** - * Get dynamic show action. - * - * @access public - * @return string - */ - public function getActionConditionTest() - { - $objects = $this->objectModel->getActionCondition(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get dynamic by search. - * - * @param array $products - * @param array $projects - * @param array $executions - * @param int $queryID - * @param string $orderBy - * @param object $pager - * @param string $date - * @param string $direction - * @access public - * @return array - */ - public function getDynamicBySearchTest($products, $projects, $executions, $queryID, $orderBy = 'date_desc', $pager = null, $date = '', $direction = 'next') - { - $objects = $this->objectModel->getDynamicBySearch($products, $projects, $executions, $queryID, $orderBy, $pager, $date, $direction); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get actions as dynamic. - * - * @param string $account - * @param string $period - * @param string $productID - * @param string $projectID - * @param string $executionID - * @param string $date - * @param string $direction - * @access public - * @return int - */ - public function getDynamicTest($account = 'all', $period = 'all', $productID = 'all', $projectID = 'all', $executionID = 'all', $date = '', $direction = 'next') - { - $date = $date == 'today' ? date('Y-m-d', time()) : $date; - $objects = $this->objectModel->getDynamic($account, $period, 'date_desc', null, $productID, $projectID, $executionID, $date, $direction); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get actions by SQL. - * - * @param string $sql - * @param string $orderBy - * @param object $pager - * @access public - * @return int - */ - public function getBySQLTest($sql, $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getBySQL($sql, $orderBy, $pager = null); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test transform the actions for display. - * - * @param array $actions - * @access public - * @return array - */ - public function transformActionsTest($actions) - { - global $tester; - $actions = $tester->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id'); - - $objects = $this->objectModel->transformActions($actions); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get related data by actions. - * - * @param array $actions - * @param string $field - * @access public - * @return array - */ - public function getRelatedDataByActionsTest($actions, $field) - { - global $tester; - $actions = $tester->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id'); - - $objects = $this->objectModel->getRelatedDataByActions($actions); - - if(dao::isError()) return dao::getError(); - - return $objects[$field]; - } - - /** - * Test get object label. - * - * @param string $objectType - * @param int $objectID - * @param string $actionType - * @param array $requirements - * @access public - * @return string - */ - public function getObjectLabelTest($objectType, $objectID, $actionType, $requirements) - { - $object = $this->objectModel->getObjectLabel($objectType, $objectID, $actionType, $requirements); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test compute the begin date and end date of a period. - * - * @param string $period - * @access public - * @return array - */ - public function computeBeginAndEndTest($period) - { - $date = $this->objectModel->computeBeginAndEnd($period); - - $today = date('Y-m-d'); - $tomorrow = date::tomorrow(); - $yesterday = date::yesterday(); - $twoDaysAgo = date::twoDaysAgo(); - - if($period == 'all') return $date['begin'] == '1970-1-1' and $date['end'] == '2109-1-1'; - if($period == 'today') return $date['begin'] == $today and $date['end'] == $tomorrow; - if($period == 'yesterday') return $date['begin'] == $yesterday and $date['end'] == $today; - if($period == 'twodaysago') return $date['begin'] == $twoDaysAgo and $date['end'] == $yesterday; - if($period == 'latest3days') return $date['begin'] == $twoDaysAgo and $date['end'] == $tomorrow; - if($period == 'thismonth') return $date == date::getThisMonth(); - if($period == 'lastmonth') return $date == date::getLastMonth(); - $func = "get$period"; - extract(date::$func()); - if($period == 'thisweek') return $date['begin'] == $begin and $date['end'] == $end . ' 23:59:59'; - if($period == 'lastweek') return $date['begin'] == $begin and $date['end'] == $end . ' 23:59:59'; - } - - /** - * Delete action by objectType. - * - * @param string $objectType - * @access public - * @return bool - */ - public function deleteByTypeTest($objectType) - { - $this->objectModel->deleteByType($objectType); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('objectType')->eq($objectType)->fetchAll(); - - return empty($objects); - } - - /** - * Test undelete a record. - * - * @param int $actionID - * @access public - * @return object - */ - public function undeleteTest($actionID) - { - $this->objectModel->undelete($actionID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($actionID); - return $object; - } - - /** - * Test hide an object. - * - * @param int $actionID - * @access public - * @return object - */ - public function hideOneTest($actionID) - { - $this->objectModel->hideOne($actionID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($actionID); - return $object; - } - - /** - * Test hide all deleted objects. - * - * @access public - * @return array - */ - public function hideAllTest() - { - $this->objectModel->hideAll(); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('action')->eq('deleted')->fetchAll(); - return $objects; - } - - /** - * Test update comment of a action. - * - * @param int $actionID - * @param string $comment - * @access public - * @return object - */ - public function updateCommentTest($actionID, $comment) - { - $_POST['lastComment'] = $comment; - - $this->objectModel->updateComment($actionID); - - unset($_POST); - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($actionID); - return $object; - } - - /** - * Check Has pre or next. - * - * @param string $date - * @param string $direction - * @access public - * @return bool - */ - public function hasPreOrNextTest($date, $direction = 'next') - { - global $tester; - $tester->session->set('actionQueryCondition', '1=1'); - $result = $this->objectModel->hasPreOrNext($date, $direction); - - if(dao::isError()) return dao::getError(); - - return $result; - } - - /** - * Save global search object index information. - * - * @param string $objectType - * @param int $objectID - * @param string $actionType - * @access public - * @return bool - */ - public function saveIndexTest($objectType, $objectID, $actionType) - { - $result = $this->objectModel->saveIndex($objectType, $objectID, $actionType); - - if(dao::isError()) return dao::getError(); - - return $result; - } - - /** - * Process dynamic for API. - * - * @param array $dynamics - * @access public - * @return array - */ - public function processDynamicForAPITest($dynamics) - { - $objects = $this->objectModel->processDynamicForAPI($dynamics); - - if(dao::isError()) return dao::getError(); - - return empty($objects) ? $objects : $objects[0]; - } - - /** - * Test build date group by actions. - * - * @param string $direction - * @param string $type - * @param string $orderBy - * @access public - * @return int - */ - public function buildDateGroupTest($direction = 'next', $type = 'today', $orderBy = 'date_desc') - { - $actions = $this->objectModel->getDynamic('all', $type); - $objects = $this->objectModel->buildDateGroup($actions, $direction, $type, $orderBy); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - return $count; - } - - /** - * Test restore stages. - * - * @param array $stageList - * @param array $actionIdList - * @access public - * @return object - */ - public function restoreStagesTest($stageList, $actionIdList) - { - $this->objectModel->restoreStages($stageList); - - if(dao::isError()) return dao::getError(); - - $actionList = array(); - foreach($actionIdList as $actionID) $actionList[$actionID] = $this->objectModel->getByID($actionID); - - return $actionList; - } -} diff --git a/test/class/admin.class.php b/test/class/admin.class.php deleted file mode 100644 index 75ca2cbee2..0000000000 --- a/test/class/admin.class.php +++ /dev/null @@ -1,226 +0,0 @@ -objectModel = $tester->loadModel('admin'); - $this->user = $tester->loadModel('user'); - $this->communityConfig = $app->loadConfig('community'); - $this->adminConfig = $config->admin; - } - - /** - * Post data form API. - * - * @param string $url - * @param string $formvars - * @access public - * @return void - */ - public function postAPITest() - { - $apiConfig = $this->objectModel->getApiConfig(); - $apiURL = $this->adminConfig->apiRoot . "/user-apiRegister.json?HTTP_X_REQUESTED_WITH=XMLHttpRequest&{$apiConfig->sessionVar}={$apiConfig->sessionID}"; - - $objects = $this->objectModel->postAPI($apiURL); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - - /** - * Get status of zentaopms. - * @access public - * @return void - */ - public function getStatOfPMSTest() - { - $objects = $this->objectModel->getStatOfPMS(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getStatOfCompanyTest($companyID) - { - $objects = $this->objectModel->getStatOfCompany($companyID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getStatOfSysTest() - { - $objects = $this->objectModel->getStatOfSys(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function registerByAPITest() - { - $objects = $this->objectModel->registerByAPI(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Login zentao by API. - * - * @access public - * @return void - */ - public function bindByAPITest($param) - { - $_POST = $param; - $objects = $this->objectModel->bindByAPI(); - $objects = json_decode($objects); - unset($_POST); - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getSecretKeyTest() - { - $objects = $this->objectModel->getSecretKey(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function sendCodeByAPITest($type) - { - $objects = $this->objectModel->sendCodeByAPI($type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function certifyByAPITest($type) - { - $objects = $this->objectModel->certifyByAPI($type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setCompanyByAPITest() - { - $objects = $this->objectModel->setCompanyByAPI(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get signature. - * - * @param array $params - * @access public - * @return string - */ - public function getSignatureTest() - { - $params['u'] = $this->communityConfig; - $params['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequet'; - - $apiConfig = $this->objectModel->getApiConfig(); - $params[$apiConfig->sessionVar] = $apiConfig->sessionID; - - $objects = $this->objectModel->getSignature($params); - - if(dao::isError()) return dao::getError(); - - if($objects){ - return true; - }else{ - return false; - } - } - - - public function getApiConfigTest() - { - $objects = $this->objectModel->getApiConfig(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get register information. - * - * @access public - * @return object - */ - public function getRegisterInfoTest() - { - $objects = $this->objectModel->getRegisterInfo(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Check weak. - * - * @param object $user - * @access public - * @return bool - */ - public function checkWeakTest($account) - { - $user = $this->user->getById($account); - $objects = $this->objectModel->checkWeak($user); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getMenuKeyTest($moduleName, $methodName, $params = array()) - { - global $app; - $app->rawModule = $moduleName; - $app->rawMethod = $methodName; - $app->rawParams = $params; - - $menuKey = $this->objectModel->getMenuKey(); - return empty($menuKey) ? 'null' : $menuKey; - } - - /** - * Get the authorized link - * - * @param mixed $menuKey - * @access public - * @return array - */ - public function getHasPrivLinkTest($menuKey) - { - global $lang; - $subMenuList = $lang->admin->menuList->$menuKey['subMenu']; - $link = array(); - foreach($subMenuList as $subMenu) - { - $link = $this->objectModel->getHasPrivLink($subMenu); - if(!empty($link)) return $link; - } - return $link; - } -} diff --git a/test/class/api.class.php b/test/class/api.class.php deleted file mode 100644 index 29e8a21340..0000000000 --- a/test/class/api.class.php +++ /dev/null @@ -1,300 +0,0 @@ -objectModel = $tester->loadModel('api'); - } - - /** - * Test publish a lib. - * - * @param object $data - * @param bool $confirm - * @access public - * @return object - */ - public function publishLibTest($data, $confirm = true) - { - $objectID = $this->objectModel->publishLib($data); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getRelease($data->lib); - - if($confirm) $this->objectModel->deleteRelease($objectID); - - return $objects; - } - - /** - * Test delete a release. - * - * @param int $id - * @param int $libID - * @access public - * @return object - */ - public function deleteReleaseTest($id, $libID = 0) - { - $this->objectModel->deleteRelease($id); - - $objects = $this->objectModel->getRelease($libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test create a api. - * - * @param array $params - * @param bool $confirm - * @access public - * @return object - */ - public function createTest($params, $confirm = true) - { - global $tester; - - $_POST = $params; - $objects = $this->objectModel->create($params['lib']); - - if(dao::isError()) return dao::getError(); - - if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($objects->id)->exec(); - - return $objects; - } - - /** - * Test create a data struct. - * - * @param object $data - * @param bool $confirm - * @access public - * @return object - */ - public function createStructTest($data, $confirm = true) - { - global $tester; - - $objectID = $this->objectModel->createStruct($data); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getStructByID($objectID); - - if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects->id)->exec(); - - return $objects; - } - - /** - * Test update a data struct. - * - * @param int $id - * @param array $params - * @param bool $confirm - * @access public - * @return object - */ - public function updateStructTest($id, $params, $confirm = true) - { - global $tester; - - $_POST = $params; - $objects = $this->objectModel->updateStruct($id); - - if(dao::isError()) return dao::getError(); - - if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($id)->exec(); - - return $objects; - } - - /** - * Test update a api. - * - * @param int $apiID - * @param array $params - * @param bool $confirm - * @access public - * @return object - */ - public function updateTest($apiID, $params, $confirm = true) - { - global $tester; - $_POST = $params; - - $objects = $this->objectModel->update($apiID); - - if(dao::isError()) return dao::getError(); - - if($confirm) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($apiID)->exec(); - - return $objects; - } - - /** - * Test get data struct list by libID. - * - * @param int $id - * @param bool $confirm - * @access public - * @return object - */ - public function getStructListByLibIDTest($id, $confirm = true) - { - global $tester; - - $objects = $this->objectModel->getStructListByLibID($id); - - if(dao::isError()) return dao::getError(); - - if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects['0']->id)->exec(); - - return $objects; - } - - /** - * Test get a data struct by ID. - * - * @param int $id - * @param bool $confirm - * @access public - * @return object - */ - public function getStructByIDTest($id, $confirm = true) - { - global $tester; - - $objects = $this->objectModel->getStructByID($id); - - if(dao::isError()) return dao::getError(); - - if($confirm) $tester->dao->delete()->from(TABLE_APISTRUCT)->where('id')->eq($objects->id)->exec(); - - return $objects; - } - - /** - * Test get release by libID. - * - * @param int $libID - * @param string $type - * @param int $params - * @param bool $confirm - * @access public - * @return object - */ - public function getReleaseTest($libID = 0, $type = '', $param = 0, $confirm = true) - { - $objects = $this->objectModel->getRelease($libID = 0, $type = '', $param = 0); - - if(dao::isError()) return dao::getError(); - - if($confirm) $this->objectModel->deleteRelease($objects->id); - - return $objects; - } - - /** - * Test get release list by api. - * - * @param int $libID - * @param int $id - * @param bool $confirm - * @access public - * @return object - */ - public function getReleaseListByApiTest($libID, $id = 0, $confirm = true) - { - $objects = $this->objectModel->getReleaseListByApi($libID); - - if(dao::isError()) return dao::getError(); - - if($confirm) $this->objectModel->deleteRelease($objects[$id]->id); - - return $objects[$id]; - } - - /** - * Test get lib by ID. - * - * @param int $id - * @param int $version - * @param int $release - * @access public - * @return object - */ - public function getLibByIdTest($id, $version = 0, $release = 0) - { - $objects = $this->objectModel->getLibById($id, $version = 0, $release = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get lib by ID. - * - * @param int $id - * @param int $version - * @param int $release - * @access public - * @return object - */ - public function getApiListByReleaseTest($release, $where = '1 = 1 ') - { - global $tester; - - $objects = $this->objectModel->getApiListByRelease($release, $where = '1 = 1 '); - - if(dao::isError()) return dao::getError(); - - foreach($release->snap['apis'] as $api) $tester->dao->delete()->from(TABLE_API)->where('id')->eq($api['id'])->exec(); - $this->objectModel->deleteRelease($release->id); - - return $objects; - } - - /** - * Test get list by module ID. - * - * @param int $libID - * @param int $moduleID - * @param int $release - * @access public - * @return void - */ - public function getListByModuleIdTest($libID = 0, $moduleID = 0, $release = 0) - { - $objects = $this->objectModel->getListByModuleId($libID, $moduleID, $release); - - if(dao::isError()) return dao::getError(); - - return current($objects); - } - - /** - * Test get struct list by release. - * - * @param object $release - * @param string $where - * @param string $orderBy - * @access public - * @return object - */ - public function getStructListByReleaseTest($release, $where = '1 = 1 ', $orderBy = 'id') - { - $objects = $this->objectModel->getStructListByRelease($release, $where = '1 = 1 ', $orderBy = 'id'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/block.class.php b/test/class/block.class.php deleted file mode 100644 index e0f555367a..0000000000 --- a/test/class/block.class.php +++ /dev/null @@ -1,759 +0,0 @@ -objectModel = $tester->loadModel('block'); - } - - /** - * Test save params. - * - * @param object $block - * @param int $id - * @param string $source - * @param string $type - * @param string $module - * @access public - * @return object - */ - public function saveTest($block, $id, $source, $type, $module = 'my') - { - foreach($block as $key => $value) $_POST[$key] = $value; - - $this->objectModel->save($id, $source, $type, $module); - - unset($_POST); - - if(dao::isError()) a(dao::getError()); - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($id); - return $object; - } - - /** - * Get block by ID. - * - * @param int $blockID - * @access public - * @return void - */ - public function getByIDTest($blockID) - { - $objects = $this->objectModel->getByID($blockID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get saved block config. - * - * @param int $id - * @access public - * @return object - */ - public function getBlockTest($id) - { - $objects = $this->objectModel->getBlock($id); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get last key. - * - * @param string $appName - * @access public - * @return int - */ - public function getLastKeyTest($module = 'my') - { - $objects = $this->objectModel->getLastKey($module); - - $objects[$module] = $objects; - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get block list for account. - * - * @param string $appName - * @access public - * @return void - */ - public function getBlockListTest($module = 'my', $type = '') - { - $objects = $this->objectModel->getBlockList($module, $type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get hidden blocks - * - * @access public - * @return array - */ - public function getHiddenBlocksTest($module = 'my') - { - $objects = $this->objectModel->getHiddenBlocks($module); - - if(dao::isError()) return dao::getError(); - - if(empty($objects)) - { - $objects['code'] = 'fail'; - $objects['message'] = '未获取到隐藏的区块'; - } - - return $objects; - } - - /** - * Test get data of welcome block. - * - * @access public - * @return string - */ - public function getWelcomeBlockDataTest() - { - $objects = $this->objectModel->getWelcomeBlockData(); - - if(dao::isError()) return dao::getError(); - - return json_encode($objects); - } - - /** - * Init block when account use first. - * - * @param string $module project|product|execution|qa|my - * @param string $type scrum|waterfall|kanban - * @access public - * @return bool - */ - public function initBlockTest($module, $type = '') - { - global $tester; - $this->objectModel->initBlock($module, $type); - - if(dao::isError()) return dao::getError(); - - $object = new stdclass(); - $account = $tester->app->user->account; - $section = $module == 'project' ? $type . 'common' : 'common'; - - $object->blockInited = $tester->loadModel('setting')->getItem("owner=$account&module=$module§ion=$section&key=blockInited"); - $object->blockversion = $tester->loadModel('setting')->getItem("owner=$account&module=$module§ion=block&key=initVersion"); - - $blockData = $this->objectModel->getBlockList($module, $type); - $object->blockData = empty($module) ? 0 : current($blockData); - - return $object; - } - - /** - * Get block list. - * - * @param string $module - * @param string $dashboard - * @param object $model - * - * @access public - * @return string - */ - public function getAvailableBlocksTest($module = '', $dashboard = '', $model = '') - { - $objects = json_decode($this->objectModel->getAvailableBlocks($module, $dashboard, $model)); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getListParamsTest($module = '') - { - $objects = json_decode($this->objectModel->getListParams($module)); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get todo param. - * - * @param string $module - * @access public - * @return string - */ - public function getTodoParamsTest($module = '') - { - $objects = $this->objectModel->getTodoParams($module = ''); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Test get task params. - * - * @param string $module - * @access public - * @return string - */ - public function getTaskParamsTest($module = '') - { - $objects = $this->objectModel->getTaskParams($module = ''); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Get Bug Params. - * - * @access public - * @return json - */ - public function getBugParamsTest($module = '') - { - $objects = json_decode($this->objectModel->getBugParams($module)); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get case params. - * - * @access public - * @return json - */ - public function getCaseParamsTest($module = '') - { - $objects = json_decode($this->objectModel->getCaseParams($module)); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get testtask params. - * - * @param string $module - * @access public - * @return string - */ - public function getTesttaskParamsTest($module = '') - { - $objects = $this->objectModel->getTesttaskParams($module = ''); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Test get story params. - * - * @param string $module - * @access public - * @return void - */ - public function getStoryParamsTest($module = '') - { - $objects = $this->objectModel->getStoryParams($module); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Get plan params. - * - * @access public - * @return json - */ - public function getPlanParamsTest() - { - $objects = $this->objectModel->getPlanParams(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getReleaseParamsTest() - { - $objects = $this->objectModel->getReleaseParams(); - - if(dao::isError()) return dao::getError(); - - $objects = json_decode($objects); - - return $objects->count; - } - - /** - * Get project params. - * - * @access public - * @return string - */ - public function getProjectParamsTest() - { - $objects = $this->objectModel->getProjectParams(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get project team params. - * - * @access public - * @return string - */ - public function getProjectTeamParamsTest() - { - $objects = $this->objectModel->getProjectTeamParams(); - - if(dao::isError()) return dao::getError(); - - - $objects = json_decode($objects); - $return = ''; - foreach($objects as $type => $params) - { - $return .= "$type:{"; - foreach($params as $param => $paramValue) - { - if(is_object($paramValue)) - { - foreach($paramValue as $key => $value) $return .= "$key=>$value,"; - } - else - { - $return .= "$param:$paramValue,"; - } - } - $return = trim($return, ','); - $return .= '};'; - } - return $return; - } - - /** - * Get Build params. - * - * @access public - * @return json - */ - public function getBuildParamsTest() - { - $objects = json_decode($this->objectModel->getBuildParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get product params. - * - * @access public - * @return string - */ - public function getProductParamsTest() - { - $objects = $this->objectModel->getProductParams(); - if(dao::isError()) return dao::getError(); - - $return = ''; - $objects = json_decode($objects); - foreach($objects as $type => $params) - { - $return .= "$type:{"; - foreach($params as $param => $paramValue) - { - if(is_object($paramValue)) - { - foreach($paramValue as $key => $value) $return .= "$key=>$value,"; - } - else - { - $return .= "$param:$paramValue,"; - } - } - $return = trim($return, ','); - $return .= '};'; - } - return $return; - } - - /** - * Get statistic params. - * - * @param string $module product|project|execution|qa - * @access public - * @return string - */ - public function getStatisticParamsTest($module = 'product') - { - $objects = $this->objectModel->getStatisticParams($module); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Get product statistic params. - * - * @access public - * @return string - */ - public function getProductStatisticParamsTest() - { - $objects = $this->objectModel->getProductStatisticParams(); - if(dao::isError()) return dao::getError(); - - $return = ''; - $objects = json_decode($objects); - foreach($objects as $type => $params) - { - $return .= "$type:{"; - foreach($params as $param => $paramValue) - { - if(is_object($paramValue)) - { - foreach($paramValue as $key => $value) $return .= "$key=>$value,"; - } - else - { - $return .= "$param:$paramValue,"; - } - } - $return = trim($return, ','); - $return .= '};'; - } - return $return; - } - - /** - * Test get project statistic params. - * - * @access public - * @return string - */ - public function getProjectStatisticParamsTest() - { - $objects = $this->objectModel->getProjectStatisticParams(); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Get execution statistic params. - * - * @access public - * @return void - */ - public function getExecutionStatisticParamsTest() - { - $objects = json_decode($this->objectModel->getExecutionStatisticParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get qa statistic params. - * - * @access public - * @return object - */ - public function getQaStatisticParamsTest() - { - $object = $this->objectModel->getQaStatisticParams(); - - if(dao::isError()) return dao::getError(); - - return json_decode($object); - } - - /** - * Test get waterfall issue param. - * - * @param string $module - * @access public - * @return string - */ - public function getWaterfallIssueParamsTest($module = '') - { - $objects = $this->objectModel->getWaterfallIssueParams($module = ''); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Test get waterfall risk param. - * - * @param string $module - * @access public - * @return string - */ - public function getWaterfallRiskParamsTest($module = '') - { - $objects = $this->objectModel->getWaterfallRiskParams($module = ''); - - if(dao::isError()) return dao::getError(); - - return json_encode(json_decode($objects), JSON_UNESCAPED_UNICODE); - } - - /** - * Get execution params. - * - * @access public - * @return json - */ - public function getExecutionParamsTest() - { - $objects = json_decode($this->objectModel->getExecutionParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get assign to me params. - * - * @access public - * @return json - */ - public function getAssignToMeParamsTest() - { - $objects = json_decode($this->objectModel->getAssignToMeParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get closed block pairs. - * - * @param string $closedBlock - * @access public - * @return array - */ - public function getClosedBlockPairsTest($closedBlock) - { - $objects = $this->objectModel->getClosedBlockPairs($closedBlock); - - if(dao::isError()) return dao::getError(); - - if(empty($objects)) - { - $objects['code'] = 'fail'; - $objects['message'] = '未获取到关闭的区域'; - } - - return $objects; - } - - /** - * Test append count params. - * - * @param string|object $params - * @access public - * @return object - */ - public function appendCountParamsTest($params = '') - { - $objects = $this->objectModel->appendCountParams($params); - - if(dao::isError()) return dao::getError(); - - $string = ''; - foreach($objects as $key => $param) - { - if(is_array($param)) - { - $string .= "$key:{"; - foreach($param as $key => $value) $string .= "$key:$value,"; - $string = trim($string, ','); - $string .= '}'; - } - else - { - $string .= "$key:$param"; - } - $string .= ';'; - } - return $string; - } - - /** - * Test check whether long block. - * - * @param object $block - * @access public - * @return bool - */ - public function isLongBlockTest($block) - { - $bool = $this->objectModel->isLongBlock($block); - - if(dao::isError()) return dao::getError(); - - return $bool ? 1 : 2; - } - - /** - * Check API for ranzhi. - * - * @param string $hash - * @access public - * @return bool - */ - public function checkAPITest($hash) - { - $objects = $this->objectModel->checkAPI($hash); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get testtask params. - * - * @access public - * @return string - */ - public function getScrumTestParamsTest() - { - $objects = json_decode($this->objectModel->getScrumTestParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get scrum project list params. - * - * @param string $module - * @access public - * @return string - */ - public function getScrumListParamsTest($module = '') - { - $objects = $this->objectModel->getScrumListParams($module = ''); - - if(dao::isError()) return dao::getError(); - - $objects = json_decode($objects); - - return $objects->type; - } - - /** - * Get scrum roadmap list params. - * - * @access public - * @return string - */ - public function getScrumRoadMapParamsTest() - { - $objects = $this->objectModel->getScrumRoadMapParams(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get scrum product list params. - * - * @access public - * @return string - */ - public function getScrumProductParamsTest() - { - $objects = json_decode($this->objectModel->getScrumProductParams()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getProjectDynamicParamsTest() - { - $objects = $this->objectModel->getProjectDynamicParams(); - if(dao::isError()) return dao::getError(); - - $return = ''; - $objects = json_decode($objects); - foreach($objects as $type => $params) - { - $return .= "$type:{"; - foreach($params as $param => $paramValue) - { - if(is_object($paramValue)) - { - foreach($paramValue as $key => $value) $return .= "$key=>$value,"; - } - else - { - $return .= "$param:$paramValue,"; - } - } - $return = trim($return, ','); - $return .= '};'; - } - return $return; - } - - /** - * Test get the total estimated man hours required. - * - * @param int $storyID - * @access public - * @return string - */ - public function getStorysEstimateHoursTest($storyID) - { - $object = $this->objectModel->getStorysEstimateHours($storyID); - - if(dao::isError()) return dao::getError(); - - return $object; - } -} diff --git a/test/class/branch.class.php b/test/class/branch.class.php deleted file mode 100644 index d5d741bdf9..0000000000 --- a/test/class/branch.class.php +++ /dev/null @@ -1,422 +0,0 @@ -objectModel = $tester->loadModel('branch'); - } - - /** - * Test get name by id. - * - * @param int $branchID - * @param int $productID - * @param string $field - * @access public - * @return object - */ - public function getByIdTest($branchID, $productID = 0, $field = 'name') - { - $object = $this->objectModel->getById($branchID, $productID, $field); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get branch list. - * - * @param int $productID - * @param int $executionID - * @param string $browseType - * @param bool $withMainBranch - * @access public - * @return string - */ - public function getListTest($productID, $executionID = 0, $browseType = 'active', $withMainBranch = true) - { - $objects = $this->objectModel->getList($productID, $executionID, $browseType, 'order', null, $withMainBranch); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test get pairs. - * - * @param int $productID - * @param string $params - * @param int $executionID - * @param string $mergedBranches - * @access public - * @return string - */ - public function getPairsTest($productID, $params = '', $executionID = 0, $mergedBranches = '') - { - $objects = $this->objectModel->getPairs($productID, $params, $executionID, $mergedBranches); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $id => $object) $ids .= ',' . $id; - return $ids; - } - - /** - * Test get all pairs. - * - * @param string $params - * @access public - * @return int - */ - public function getAllPairsTest($params = '') - { - $objects = $this->objectModel->getAllPairs($params); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test create a branch. - * - * @param int $productID - * @param array $param - * @access public - * @return object - */ - public function createTest($productID, $param = array()) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create($productID, $withMerge = false); - - unset($_POST); - - if(dao::isError()) return dao::getError()['name'][0]; - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($objectID)->fetch(); - return $object; - } - - /** - * Test update branch. - * - * @param array $param - * @access public - * @return array - */ - public function updateTest($param) - { - $branchID = 1; - - $branch = $this->objectModel->getByID($branchID, 0, ''); - - $_POST['name'] = $branch->name; - $_POST['status'] = $branch->status; - $_POST['desc'] = $branch->desc; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($branchID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test batch update branch. - * - * @param array $param - * @access public - * @return object - */ - public function batchUpdateTest($param = array()) - { - global $tester; - - $productID = 45; - $branches = $tester->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->fetchAll('id'); - - $_POST['IDList'] = array('0' => 0, '9' => 9, '10' => 10); - $_POST['default'] = 0; - $_POST['name'] = array('9' => $branches['9']->name, '10' => $branches['10']->name); - $_POST['desc'] = array('9' => $branches['9']->desc, '10' => $branches['10']->desc); - $_POST['status'] = array('9' => $branches['9']->status, '10' => $branches['10']->status); - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->batchUpdate($productID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects[9][0]; - } - - /** - * Test close a branch. - * - * @param int $branchID - * @access public - * @return object - */ - public function closeTest($branchID) - { - $this->objectModel->close($branchID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch(); - return $object; - } - - /** - * Test activate a branch. - * - * @param int $branchID - * @access public - * @return object - */ - public function activateTest($branchID) - { - $this->objectModel->activate($branchID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch(); - return $object; - } - - /** - * Test unlink branches for projects when product type is normal. - * - * @param string $productIDList - * @access public - * @return int - */ - public function unlinkBranch4ProjectTest($productIDList) - { - $this->objectModel->unlinkBranch4Project($productIDList); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->in($productIDList)->andWhere('branch')->gt(0)->fetchAll(); - return count($objects); - } - - /** - * Test link branches for projects when product type is not normal. - * - * @param int $productID - * @access public - * @return int - */ - public function linkBranch4ProjectTest($productID) - { - $this->objectModel->linkBranch4Project($productID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->andWhere('branch')->gt(0)->fetchAll(); - return count($objects); - } - - /** - * Test get branch group by products. - * - * @param int $products - * @param string $params - * @param string $appendBranch - * @access public - * @return string - */ - public function getByProductsTest($products, $params = '', $appendBranch = '') - { - $objects = $this->objectModel->getByProducts($products, $params, $appendBranch); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $productID => $branches) - { - $ids .= "$productID:"; - foreach($branches as $branchID => $branchName) $ids .= ",$branchID"; - $ids .= ';'; - } - return $ids; - } - - /** - * Test get product bype by branch. - * - * @param int $branchID - * @access public - * @return string - */ - public function getProductTypeTest($branchID) - { - $type = $this->objectModel->getProductType($branchID); - - if(dao::isError()) return dao::getError(); - - return $type; - } - - /** - * Test sort branch. - * - * @param string $branches - * @param string $order - * @access public - * @return string - */ - public function sortTest($branches, $order = '') - { - $_POST['orderBy'] = $order; - $_POST['branches'] = $branches; - - $this->objectModel->sort(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_BRANCH)->where('id')->in($branches)->orderBy('order asc')->fetchAll('id'); - return implode(',', array_keys($objects)); - } - - /** - * Test check branch data. - * - * @param int $branchID - * @access public - * @return int - */ - public function checkBranchDataTest($branchID) - { - $objects = $this->objectModel->checkBranchData($branchID); - - if(dao::isError()) return dao::getError(); - - return $objects ? 1 : 2; - } - - /** - * Test check branch data. - * - * @param int $branchID - * @access public - * @return int - */ - public function setDefaultTest($productID, $branchID) - { - $this->objectModel->setDefault($productID, $branchID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($branchID, $productID, ''); - - return $object; - } - - /** - * Test get branches of product which linked project. - * - * @param int $projectID - * @param int $productID - * @access public - * @return string - */ - public function getPairsByProjectProductTest($projectID, $productID) - { - $objects = $this->objectModel->getPairsByProjectProduct($projectID, $productID); - - if(dao::isError()) return dao::getError(); - - $names = ''; - foreach($objects as $id => $name) $names .= "$id:$name;"; - return $names; - } - - /** - * Test display of branch label. - * - * @param int $productID - * @param int $moduleID - * @param int $executionID - * @access public - * @return int - */ - public function showBranchTest($productID, $moduleID = 0, $executionID = 0) - { - $show = $this->objectModel->showBranch($productID, $moduleID = 0, $executionID = 0); - - if(dao::isError()) return dao::getError(); - - return $show ? 1 : 2; - } - - /** - * Test change branch language. - * - * @param int $productID - * @access public - * @return string - */ - public function changeBranchLanguageTest($productID) - { - global $tester; - global $lang; - - $filePath = dirname(dirname(dirname(__FILE__))) . DS . 'module' . DS . 'branch' . DS . 'lang' . DS . 'zh-cn.php'; - include $filePath; - - $this->objectModel->changeBranchLanguage($productID); - - $createLang = $tester->lang->branch->create; - - if(dao::isError()) return dao::getError(); - - return $createLang; - } - - /** - * Test merge multiple branches into one branch. - * - * @param int $productID - * @param string $mergedBranches - * @access public - * @return int - */ - public function mergeBranchTest($productID, $mergedBranches, $param) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->mergeBranch($productID, $mergedBranches); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $modules = $tester->dao->select('*')->from(TABLE_MODULE)->where('branch')->eq($objectID)->andWhere('root')->eq($productID)->andWhere('type')->eq('story')->fetchAll(); - return count($modules); - } -} diff --git a/test/class/bug.class.php b/test/class/bug.class.php deleted file mode 100644 index 2f43a440bf..0000000000 --- a/test/class/bug.class.php +++ /dev/null @@ -1,2173 +0,0 @@ -objectModel = $tester->loadModel('bug'); - } - - /** - * Test create a bug. - * - * @param array $param - * @access public - * @return object - */ - public function createObject($param = array()) - { - $createFields['title'] = '测试创建bug'; - $createFields['type'] = 'codeerror'; - $createFields['product'] = 1; - $createFields['execution'] = 101; - $createFields['openedBuild'] = 'trunk'; - $createFields['pri'] = 3; - $createFields['severity'] = 3; - $createFields['status'] = 'active'; - $createFields['deadline'] = '2021-03-19'; - $createFields['openedBy'] = 'admin'; - $createFields['openedDate'] = '2021-03-19'; - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->objectModel->create(); - $objectID = $object['id']; - unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->objectModel->getByID($objectID); - return $object; - } - } - - /** - * Test batch create bugs. - * - * @param int $productID - * @param array $param - * @access public - * @return object - */ - public function batchCreateObject($productID, $param = array()) - { - $modules = array('0', '0', '0'); - $executions = array('101', '101', '0'); - $openedBuilds = array('', '', ''); - $title = array('', '', ''); - $deadlines = array('0000-00-00', '0000-00-00', '0000-00-00'); - $stepses = array('', '', ''); - $types = array('', '', ''); - $severities = array(3, 3, 3); - $oses = array('', '', ''); - $browsers = array('', '', ''); - $pris = array(3, 3, 3); - $color = array('', '', ''); - $keywords = array('', '', ''); - - $createFields['modules'] = $modules; - $createFields['executions'] = $executions; - $createFields['openedBuilds'] = $openedBuilds; - $createFields['title'] = $title; - $createFields['deadlines'] = $deadlines; - $createFields['stepses'] = $stepses; - $createFields['types'] = $types; - $createFields['severities'] = $severities; - $createFields['oses'] = $oses; - $createFields['browsers'] = $browsers; - $createFields['pris'] = $pris; - $createFields['color'] = $color; - $createFields['keywords'] = $keywords; - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->objectModel->batchCreate($productID); - - $bug = array(); - if(is_array($object)) - { - foreach($object as $bugID => $actionID) - { - $bug[] = $this->objectModel->getByID($bugID); - } - } - - unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return empty($bug) ? $object : $bug; - } - } - - /** - * Test create bug from gitlab issue. - * - * @param array $bug - * @param int $executionID - * @access public - * @return object|int - */ - public function createBugFromGitlabIssueTest($bug, $executionID) - { - $objectID = $this->objectModel->createBugFromGitlabIssue($bug, $executionID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $objectID ? $this->objectModel->getById($objectID) : 0; - return $object; - } - } - - /** - * Test get bugs. - * - * @access public - * @return string - */ - public function getBugsTest($product, $branch, $browseType, $module) - { - global $tester; - - /* Load pager. */ - $tester->app->loadClass('pager', $static = true); - $pager = new pager(0, 20 ,1); - - $projectID = 0; - $sort = 'id_desc'; - $queryID = 0; - $executions = $tester->loadModel('execution')->getPairs($projectID, 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getBugs($product, $executions, $branch, $browseType, $module, $queryID, $sort, $pager, $projectID); - - $title = ''; - foreach($bugs as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test check delay bug. - * - * @param object $bug - * @param string $status - * @access public - * @return object - */ - public function checkDelayBugTest($bug, $status) - { - $bug->status = $status; - $bug->deadline = $bug->deadline ? date('Y-m-d',strtotime("$bug->deadline day")) : '0000-00-00'; - $bug->resolvedDate = $bug->resolvedDate ? date('Y-m-d',strtotime("$bug->resolvedDate day")) : '0000-00-00'; - - $object = $this->objectModel->checkDelayBug($bug); - if(!isset($object->delay)) $object->delay = 0; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test check delay bugs. - * - * @param string $productIDList - * @access public - * @return string - */ - public function checkDelayedBugsTest($productID) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - /* Load pager. */ - $tester->app->loadClass('pager', $static = true); - $pager = new pager(0, 20 ,1); - - $bugs = $this->objectModel->getAllBugs($productID, 0, 0, $executions, 'id_asc', $pager, 0); - $bugs = $this->objectModel->checkDelayedBugs($bugs); - - $delay = ''; - foreach($bugs as $bug) - { - $delay .= ',' . (!isset($bug->delay) ? 0 : $bug->delay); - } - $delay = trim($delay, ','); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $delay; - } - } - - /** - * Test get bugs of a module. - * - * @param string $productIDList - * @param string $moduleIDList - * @access public - * @return string - */ - public function getModuleBugsTest($productIDList, $moduleIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getModuleBugs($productIDList, 'all', $moduleIDList, $executions); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get all bugs. - * - * @param string $productIDList - * @param string $moduleIDList - * @access public - * @return string - */ - public function getAllBugsTest($productIDList, $moduleIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getAllBugs($productIDList, 'all', $moduleIDList, $executions, 'id_desc'); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs of assign to me. - * - * @param string $productIDList - * @param string $moduleIDList - * @access public - * @return string - */ - public function getByAssigntomeTest($productIDList, $moduleIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByAssigntome($productIDList, 'all', $moduleIDList, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs of opened by me. - * - * @param string $productIDList - * @param string $moduleIDList - * @access public - * @return string - */ - public function getByOpenedbymeTest($productIDList, $moduleIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByOpenedbyme($productIDList, 'all', $moduleIDList, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs of resolved by me. - * - * @param string $productIDList - * @access public - * @return string - */ - public function getByResolvedbymeTest($productIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByResolvedbyme($productIDList, 'all', '0', $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs of nobody to do. - * - * @param string $productIDList - * @access public - * @return string - */ - public function getByAssigntonullTest($productIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByAssigntonull($productIDList, 'all', '0', $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get unconfirmed bugs. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getUnconfirmedTest($productIDList, $modules) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getUnconfirmed($productIDList, 'all', $modules, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs the overdueBugs is active or unclosed. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getOverdueBugsTest($productIDList, $modules) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getOverdueBugs($productIDList, 'all', $modules, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - - /** - * Test get bugs the status is active or unclosed. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getByStatusTest($productIDList, $modules, $status) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByStatus($productIDList, 'all', $modules, $executions, $status, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get unclosed bugs for long time. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getByLonglifebugsTest($productIDList, $modules) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByLonglifebugs($productIDList, 'all', $modules, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get postponed bugs. - * - * @param string $productIDList - * @access public - * @return string - */ - public function getByPostponedbugsTest($productIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByPostponedbugs($productIDList, 'all', '0', $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs need confirm. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getByNeedconfirmTest($productIDList, $modules) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByNeedconfirm($productIDList, 'all', $modules, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get by Sonarqube id. - * - * @param int $sonarqubeID - * @access public - * @return int - */ - public function getBySonarqubeIDTest($sonarqubeID) - { - $array = $this->objectModel->getBySonarqubeID($sonarqubeID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($array); - } - } - - /** - * Test get bug list of a plan. - * - * @param string $productIDList - * @param string $modules - * @access public - * @return string - */ - public function getPlanBugsTest($planID, $status) - { - $bugs = $this->objectModel->getPlanBugs($planID, $status, 'id_desc', null); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bug by id. - * - * @param int $bugID - * @access public - * @return object - */ - public function getByIdTest($bugID) - { - $object = $this->objectModel->getById($bugID); - if(isset($object->title)) $object->title = str_replace("'", '', $object->title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test get bug by id list. - * - * @param string $bugIDList - * @access public - * @return array - */ - public function getByListTest($bugIDList) - { - $bugs = $this->objectModel->getByList($bugIDList); - - foreach($bugs as $bug) - { - if(isset($bug->title)) $bug->title = str_replace("'", '', $bug->title); - } - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $bugs; - } - } - - /** - * Test get active bugs. - * - * @param string $products - * @param string $excludeBugs - * @access public - * @return string - */ - public function getActiveBugsTest($products, $excludeBugs) - { - $bugs = $this->objectModel->getActiveBugs($products, 'all', '', $excludeBugs); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get active and postponed bugs. - * - * @param string $bugIDList - * @param int $executionID - * @access public - * @return string - */ - public function getActiveAndPostponedBugsTest($products, $executionID) - { - $bugs = $this->objectModel->getActiveAndPostponedBugs($products, $executionID); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get module owner. - * - * @param int $moduleID - * @param int $productID - * @access public - * @return string - */ - public function getModuleOwnerTest($moduleID, $productID) - { - $owner = $this->objectModel->getModuleOwner($moduleID, $productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $owner; - } - } - - /** - * Test update a bug. - * - * @param int $bugID - * @param array $param - * @access public - * @return void - */ - public function updateObject($bugID, $param = array()) - { - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_BUG ." WHERE id = $bugID")->fetch(); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - $_POST['closedDate'] = ''; - - - $change = $this->objectModel->update($bugID); - if($change == array()) $change = '没有数据更新'; - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } - } - - /** - * Test batch update bugs. - * - * @param array $bugIDList - * @param string $title - * @param string $type - * @param int $bugID - * @access public - * @return array - */ - public function batchUpdateObject($bugIDList, $title, $type, $bugID) - { - $titles = array('1' => 'BUG1', '2' => 'BUG2', '3' => 'BUG3'); - $types = array('1' => 'codeerror', '2' => 'config', '3' => 'install'); - $severities = array('1' => '1', '2' => '2', '3' => '3'); - $pris = array('1' => '1', '2' => '2', '3' => '3'); - $colors = array('1' => '#3da7f5', '2' => '#75c941', '3' => '#2dbdb2'); - $module = array('1' => '1821', '2' => '1822', '3' => '1823'); - $plan = array('1' => '1', '2' => '1', '3' => '1'); - $assignedTo = array('1' => 'admin', '2' => 'admin', '3' => 'admin'); - $deadline = array('1' => date('Y-m-d',strtotime('-1 month')), '2' => date('Y-m-d',strtotime('-1 month +1 day')), '3' => date('Y-m-d',strtotime('-1 month +2 day'))); - $os = array('1' => '', '2' => '', '3' => 'all'); - $browser = array('1' => '', '2' => '', '3' => ''); - $keyword = array('1' => '', '2' => '', '3' => ''); - $resolvedBy = array('1' => '', '2' => '', '3' => ''); - $resolution = array('1' => '', '2' => '', '3' => ''); - $duplicateBug = array('1' => '', '2' => '', '3' => ''); - - $titles[$bugID] = $title; - $types[$bugID] = $type; - - - $batchUpdateFields['bugIDList'] = $bugIDList; - $batchUpdateFields['types'] = $types; - $batchUpdateFields['severities'] = $severities; - $batchUpdateFields['pris'] = $pris; - $batchUpdateFields['titles'] = $titles; - $batchUpdateFields['colors'] = $colors; - $batchUpdateFields['modules'] = $module; - $batchUpdateFields['plans'] = $plan; - $batchUpdateFields['assignedTos'] = $assignedTo; - $batchUpdateFields['deadlines'] = $deadline; - $batchUpdateFields['os'] = $os; - $batchUpdateFields['browsers'] = $browser; - $batchUpdateFields['keywords'] = $keyword; - $batchUpdateFields['resolvedBys'] = $resolvedBy; - $batchUpdateFields['resolutions'] = $resolution; - $batchUpdateFields['duplicateBugs'] = $duplicateBug; - - foreach($batchUpdateFields as $field => $value) $_POST[$field] = $value; - - $object = $this->objectModel->batchUpdate(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object[$bugID]; - } - } - - /** - * Test batch activate bugs. - * - * @param array $bugIDList - * @access public - * @return array - */ - public function batchActivateObject($bugIDList) - { - $statusList = array('1' => 'active', '53' => 'resolved', '82' => 'closed'); - $assignedToList = array('1' => 'admin', '53' => 'admin', '82' => 'admin'); - $openedBuildList = array('1' => 'trunk', '53' => 'trunk', '82' => 'trunk'); - $commentList = array('1' => '', '53' => '', '82' => ''); - - $batchActivateFields['bugIDList'] = $bugIDList; - $batchActivateFields['statusList'] = $statusList; - $batchActivateFields['assignedToList'] = $assignedToList; - $batchActivateFields['openedBuildList'] = $openedBuildList; - $batchActivateFields['commentList'] = $commentList; - - foreach($batchActivateFields as $field => $value) $_POST[$field] = $value; - - $object = $this->objectModel->batchActivate(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test assign a bug to a user again. - * - * @param int $bugID - * @param array $param - * @access public - * @return array - */ - public function assignTest($bugID, $param = array()) - { - $createFields = array('assignedTo' => '', 'status' => '', 'comment' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - $object = $this->objectModel->assign($bugID); - unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test confirm a bug. - * - * @param int $bugID - * @param array $param - * @access public - * @return array - */ - public function confirmTest($bugID, $param = array()) - { - $createFields = array('assignedTo' => '', 'status' => '', 'comment' => '', 'pri' => '1'); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - $object = $this->objectModel->confirm($bugID); - unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test batch confirm bugs. - * - * @param array $bugIDList - * @access public - * @return array - */ - public function batchConfirmTest($bugIDList) - { - $this->objectModel->batchConfirm($bugIDList); - - $bugs = $this->objectModel->getByList($bugIDList); - - $confirm = ''; - foreach($bugs as $bug) $confirm .= ',' . $bug->confirmed; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $confirm; - } - } - - /** - * Test confirm a bug. - * - * @param int $bugID - * @param array $param - * @access public - * @return array - */ - public function resolveTest($bugID, $param = array()) - { - $createFields['duplicateBug'] = ''; - $createFields['buildExecution'] = '0'; - $createFields['resolvedBuild'] = 'trunk'; - $createFields['buildName'] = ''; - $createFields['resolvedDate'] = helper::now(); - $createFields['assignedTo'] = ''; - $createFields['status'] = 'resolved'; - $createFields['labels'] = array(''); - $createFields['comment'] = ''; - $createFields['resolution'] = ''; - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->objectModel->resolve($bugID); - - unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test batch change branch. - * - * @param array $bugIDList - * @param int $branchID - * @param int $bugID - * @access public - * @return array - */ - public function batchChangeBranchTest($bugIDList, $branchID, $bugID) - { - $bugs = $this->objectModel->getByList($bugIDList); - - $object = $this->objectModel->batchChangeBranch($bugIDList, $branchID, $bugs); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return !empty($object[$bugID]) ? $object[$bugID] : 0; - } - } - - /** - * Test batch change module. - * - * @param array $bugIDList - * @param int $moduleID - * @param int $bugID - * @access public - * @return array - */ - public function batchChangeModuleTest($bugIDList, $moduleID, $bugID) - { - $bugs = $this->objectModel->getByList($bugIDList); - - $object = $this->objectModel->batchChangeModule($bugIDList, $moduleID, $bugs); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return !empty($object[$bugID]) ? $object[$bugID] : 0; - } - } - - /** - * Test batch change plan. - * - * @param array $bugIDList - * @param int $planID - * @param int $bugID - * @access public - * @return array - */ - public function batchChangePlanTest($bugIDList, $planID, $bugID) - { - $object = $this->objectModel->batchChangePlan($bugIDList, $planID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return !empty($object[$bugID]) ? $object[$bugID] : 0; - } - } - - /** - * Test batch resolve bugs. - * - * @param array $bugIDList - * @param string $resolution - * @param int $bugID - * @access public - * @return array - */ - public function batchResolveTest($bugIDList, $resolution, $bugID) - { - $object = $this->objectModel->batchResolve($bugIDList, $resolution, 'trunk'); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return !empty($object[$bugID]) ? $object[$bugID] : 0; - } - } - - /** - * Test activate a bug. - * - * @param int $bugID - * @access public - * @return array - */ - public function activateObject($bugID) - { - $changes = $this->objectModel->activate($bugID, ''); - - if($changes == array()) $changes = '没有数据更新'; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - foreach($changes as $change) - { - if($change['field'] == 'activatedCount') return $change; - } - } - } - - /** - * Test close a bug. - * - * @param int $bugID - * @access public - * @return array - */ - public function closeObject($bugID) - { - $change = $this->objectModel->close($bugID, ''); - - if($change == array()) $change = '没有数据更新'; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } - } - - /** - * Test process the openedBuild and resolvedBuild fields for bugs. - * - * @param array $bugIDList - * @access public - * @return array - */ - public function processBuildForBugsTest($bugIDList) - { - $bugs = $this->objectModel->getByList($bugIDList); - $array = $this->objectModel->processBuildForBugs($bugs); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test extract accounts from some bugs. - * - * @param array $bugIDList - * @access public - * @return array - */ - public function extractAccountsFromListTest($bugIDList) - { - $bugs = $this->objectModel->getByList($bugIDList); - $array = $this->objectModel->extractAccountsFromList($bugs); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test extract accounts from a bug. - * - * @param int $bugID - * @access public - * @return array - */ - public function extractAccountsFromSingleTest($bugID) - { - $bug = $this->objectModel->getByID($bugID); - $array = $this->objectModel->extractAccountsFromSingle($bug); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get user bugs. - * - * @param string $account - * @param string $type - * @access public - * @return array - */ - public function getUserBugsTest($account, $type = 'assignedTo') - { - $array = $this->objectModel->getUserBugs($account, $type); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($array); - } - } - - /** - * Test get bug pairs of a user. - * - * @param string $account - * @access public - * @return array - */ - public function getUserBugPairsTest($account) - { - $array = $this->objectModel->getUserBugPairs($account); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($array); - } - } - - /** - * Test get bugs of a project. - * - * @param int $projectID - * @access public - * @return array - */ - public function getProjectBugsTest($projectID) - { - $array = $this->objectModel->getProjectBugs($projectID); - - foreach($array as $bug) $bug->title = str_replace("'", '', $bug->title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get bugs of a execution. - * - * @param int $executionID - * @access public - * @return string - */ - public function getExecutionBugsTest($executionID) - { - $array = $this->objectModel->getExecutionBugs($executionID); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get product left bugs. - * - * @param int $buildID - * @param int $productID - * @access public - * @return string - */ - public function getProductLeftBugsTest($buildID, $productID) - { - $array = $this->objectModel->getProductLeftBugs($buildID, $productID); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bug pairs of a product. - * - * @param int $productID - * @param int|string $branch - * @access public - * @return string - */ - public function getProductBugPairsTest($productID, $branch = '') - { - $array = $this->objectModel->getProductBugPairs($productID, $branch); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bug member of a product. - * - * @param int $productID - * @access public - * @return string - */ - public function getProductMemberPairsTest($productID) - { - $array = $this->objectModel->getProductMemberPairs($productID); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs according to buildID and productID. - * - * @param int $buildID - * @param int $productID - * @access public - * @return string - */ - public function getReleaseBugsTest($buildID, $productID) - { - $array = $this->objectModel->getReleaseBugs($buildID, $productID); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get bugs of a story. - * - * @param int $storyID - * @access public - * @return string - */ - public function getStoryBugsTest($storyID) - { - $array = $this->objectModel->getStoryBugs($storyID); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get case bugs. - * - * @param int $runID - * @param int $caseID - * @param int $version - * @access public - * @return string - */ - public function getCaseBugsTest($runID, $caseID = 0, $version = 0) - { - $array = $this->objectModel->getCaseBugs($runID, $caseID, $version); - - $title = ''; - foreach($array as $bug) $title .= ',' . $bug->title; - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get counts of some stories' bugs. - * - * @param array $storyIDList - * @param int $storyID - * @access public - * @return int - */ - public function getStoryBugCountsTest($storyIDList, $storyID) - { - $array = $this->objectModel->getStoryBugCounts($storyIDList); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return isset($array[$storyID]) ? $array[$storyID] : 0; - } - } - - /** - * Test get bug info from a result. - * - * @param int $runID - * @param int $caseID - * @access public - * @return string - */ - public function getBugInfoFromResultTest($resultID, $caseID = 0) - { - $array = $this->objectModel->getBugInfoFromResult($resultID, $caseID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return isset($array['title']) ? $array['title'] : 0; - } - } - - /** - * Test get report data of bugs per execution. - * - * @access public - * @return array - */ - public function getDataOfBugsPerExecutionTest() - { - $array = $this->objectModel->getDataOfBugsPerExecution(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per build. - * - * @access public - * @return array - */ - public function getDataOfBugsPerBuildTest() - { - $array = $this->objectModel->getDataOfBugsPerBuild(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per module. - * - * @access public - * @return array - */ - public function getDataOfBugsPerModuleTest() - { - $array = $this->objectModel->getDataOfBugsPerModule(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of opened bugs per day. - * - * @access public - * @return array - */ - public function getDataOfOpenedBugsPerDayTest() - { - $array = $this->objectModel->getDataOfOpenedBugsPerDay(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of resolved bugs per day. - * - * @access public - * @return array - */ - public function getDataOfResolvedBugsPerDayTest() - { - $array = $this->objectModel->getDataOfResolvedBugsPerDay(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of closed bugs per day. - * - * @access public - * @return array - */ - public function getDataOfClosedBugsPerDayTest() - { - $array = $this->objectModel->getDataOfClosedBugsPerDay(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of openeded bugs per user. - * - * @access public - * @return array - */ - public function getDataOfOpenedBugsPerUserTest() - { - $array = $this->objectModel->getDataOfOpenedBugsPerUser(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of resolved bugs per user. - * - * @access public - * @return array - */ - public function getDataOfResolvedBugsPerUserTest() - { - $array = $this->objectModel->getDataOfResolvedBugsPerUser(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of closed bugs per user. - * - * @access public - * @return array - */ - public function getDataOfClosedBugsPerUserTest() - { - $array = $this->objectModel->getDataOfClosedBugsPerUser(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per severity. - * - * @access public - * @return array - */ - public function getDataOfBugsPerSeverityTest() - { - $array = $this->objectModel->getDataOfBugsPerSeverity(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per resolution. - * - * @access public - * @return array - */ - public function getDataOfBugsPerResolutionTest() - { - $array = $this->objectModel->getDataOfBugsPerResolution(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per status. - * - * @access public - * @return array - */ - public function getDataOfBugsPerStatusTest() - { - $array = $this->objectModel->getDataOfBugsPerStatus(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per pri. - * - * @access public - * @return array - */ - public function getDataOfBugsPerPriTest() - { - $array = $this->objectModel->getDataOfBugsPerPri(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per status. - * - * @access public - * @return array - */ - public function getDataOfBugsPerActivatedCountTest() - { - $array = $this->objectModel->getDataOfBugsPerActivatedCount(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per type. - * - * @access public - * @return array - */ - public function getDataOfBugsPerTypeTest() - { - $array = $this->objectModel->getDataOfBugsPerType(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get report data of bugs per assignedTo. - * - * @access public - * @return array - */ - public function getDataOfBugsPerAssignedToTest() - { - $array = $this->objectModel->getDataOfBugsPerAssignedTo(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test form customed bugs. - * - * @param array $bugIDList - * @access public - * @return array - */ - public function formCustomedBugsTest($bugIDList) - { - $bugs = $this->objectModel->getByList($bugIDList); - $array = $this->objectModel->formCustomedBugs($bugs); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test adjust the action is clickable. - * - * @param object $bug - * @param string $action - * @access public - * @return int - */ - public function isClickableTest($bug, $action) - { - $object = $this->objectModel->isClickable($bug, $action); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object ? 1 : 2; - } - } - - /** - * Test link bug to build and release. - * - * @param array $bugIDList - * @param int $resolvedBuild - * @access public - * @return object - */ - public function linkBugToBuildTest($bugIDList, $resolvedBuild) - { - $this->objectModel->linkBugToBuild($bugIDList, $resolvedBuild); - - global $tester; - $release = $tester->dao->select('id,bugs')->from(TABLE_RELEASE)->where('build')->eq($resolvedBuild)->andWhere('deleted')->eq('0')->fetch(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $release; - } - } - - /** - * Test get toList and ccList. - * - * @param int $bugID - * @access public - * @return string - */ - public function getToAndCcListTest($bugID) - { - $bug = $this->objectModel->getByID($bugID); - $array = $this->objectModel->getToAndCcList($bug); - - $account = ''; - foreach($array as $value) $account .= ',' . $value; - $account = trim($account, ','); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $account; - } - } - - /** - * Test get project list. - * - * @param int $productID - * @access public - * @return string - */ - public function getProjectsTest($productID) - { - $array = $this->objectModel->getProjects($productID); - - $title = ''; - foreach($array as $id => $project) $title .= ',' . $project; - $title = trim($title, ','); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get id list of all projects. - * - * @access public - * @return array - */ - public function getAllProjectIdsTest() - { - $array = $this->objectModel->getAllProjectIds(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get bug query. - * - * @param string $bugQuery - * @access public - * @return array - */ - public function getBugQueryTest($bugQuery) - { - $array = $this->objectModel->getBugQuery($bugQuery); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $array; - } - } - - /** - * Test get bugs of assigned by me. - * - * @param string $productIDList - * @param string $moduleIDList - * @access public - * @return string - */ - public function getByAssignedbymeTest($productIDList, $moduleIDList) - { - global $tester; - $executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete'); - - $bugs = $this->objectModel->getByAssignedbyme($productIDList, 'all', $moduleIDList, $executions, 'id_desc', null, 0); - - $title = ''; - foreach($bugs as $bug) - { - $title .= ',' . $bug->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test get statistic. - * - * @param int $productID - * @access public - * @return string - */ - public function getStatisticTest($productID = 0) - { - $dates = $this->objectModel->getStatistic($productID); - $returns = array(); - $today = date('m/d', time()); - foreach($dates as $dateType => $dateList) - { - $returns[$dateType] = $dateList[$today]; - } - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $returns; - } - } - - /** - * Test get bugs to review. - * - * @param array $productIDList - * @param int|string $branch - * @param array $modules - * @param array $executions - * @param string $orderBy - * @access public - * @return string - */ - public function getReviewBugsTest($productIDList, $branch, $modules, $executions, $orderBy) - { - $bugs = $this->objectModel->getReviewBugs($productIDList, $branch, $modules, $executions, $orderBy); - $ids = ''; - foreach($bugs as $bug) - { - $ids .= ",$bug->id"; - } - $ids = trim($ids, ','); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $ids; - } - } - - /** - * Test get related objects id lists. - * - * @param array $productIDList - * @param int|string $branch - * @param array $modules - * @param array $executions - * @param string $orderBy - * @access public - * @return string - */ - public function getRelatedObjectsTest($object, $pairs) - { - $objects = $this->objectModel->getRelatedObjects($object, $pairs); - $ids = ''; - foreach($objects as $objectID => $object) - { - $ids .= ",$objectID:$object"; - } - $ids = trim($ids, ','); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $ids; - } - } -} diff --git a/test/class/build.class.php b/test/class/build.class.php deleted file mode 100644 index a51cd8ba1f..0000000000 --- a/test/class/build.class.php +++ /dev/null @@ -1,431 +0,0 @@ -objectModel = $tester->loadModel('build'); - } - - /** - * function getByID by test - * - * @param string $buildID - * @param beel $setImgSize - * @access public - * @return object - */ - public function getByIDTest($buildID, $setImgSize = false) - { - $objects = $this->objectModel->getByID($buildID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getByList test by build - * - * @param array $idList - * @param string $count - * @access public - * @return array - */ - public function getByListTest($idList, $count) - { - $objects = $this->objectModel->getByList($idList); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getProjectBuilds test by build - * - * @param int $count - * @param int $projectID - * @param string $type - * @param string $param - * @param string $orderBy - * @param string $pager - * @access public - * @return array - */ - public function getProjectBuildsTest($count, $projectID, $type = 'all', $param = 0, $orderBy = 't1.date_desc,t1.id_desc', $pager = null) - { - $objects = $this->objectModel->getProjectBuilds($projectID, $type, $param, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getProjectBuildsBySearch test by build - * - * @param string $count - * @param string $projectID - * @param string $queryID - * @access public - * @return array - */ - public function getProjectBuildsBySearchTest($count, $projectID, $queryID) - { - $objects = $this->objectModel->getProjectBuildsBySearch($projectID, $queryID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getExecutionBuilds test by build - * - * @param int $count - * @param int $executionID - * @param string $type - * @param string $param - * @param string $orderBy - * @param string $pager - * @access public - * @return array - */ - public function getExecutionBuildsTest($count, $executionID, $type = '', $param = '', $orderBy = 't1.date_desc,t1.id_desc', $pager = null) - { - $objects = $this->objectModel->getExecutionBuilds($executionID, $type, $param, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getExecutionBuildsBySearch test by build - * - * @param int $count - * @param int $executionID - * @param int $queryID - * @access public - * @return arraty - */ - public function getExecutionBuildsBySearchTest($count, $executionID, $queryID) - { - $objects = $this->objectModel->getExecutionBuildsBySearch($executionID, $queryID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - - return $objects; - } - - /** - * Function getBuildPairs test by build - * - * @param int $count - * @param array $products - * @param string $branch - * @param string $params - * @param int $objectID - * @param string $objectType - * @param string $buildIdList - * @param string $replace - * @access public - * @return array - */ - public function getBuildPairsTest($count, $products, $branch = 'all', $params = 'noterminate, nodone', $objectID = 0, $objectType = 'execution', $buildIdList = '', $replace = true) - { - $objects = $this->objectModel->getBuildPairs($products, $branch, $params, $objectID, $objectType, $buildIdList, $replace); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * Function getLast test by build - * - * @param string $executionID - * @access public - * @return array - */ - public function getLastTest($executionID) - { - $objects = $this->objectModel->getLast($executionID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function create test by build - * - * @param int $executionID - * @param array $param - * @access public - * @return array - */ - public function createTest($executionID, $param = array()) - { - $toData = date('Y-m-d'); - $labels = array(); - $files = array(); - - $createFields = array('product' => '', 'name' => '', 'builder' => 'admin', 'date' => $toData, 'scmPath' => '', 'filePath' => '', - 'labels' => $labels, 'files' => $files, 'desc' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create($executionID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($objectID); - return $objects; - } - - /** - * Function update test by build - * - * @param int $buildID - * @param array $param - * @access public - * @return array - */ - public function updateTest($buildID, $param = array()) - { - $toData = date('Y-m-d'); - $labels = array(); - $files = array(); - - $createFields = array('name' => '', 'builder' => 'admin', 'date' => $toData, 'scmPath' => '', 'filePath' => '', - 'labels' => $labels, 'files' => $files, 'desc' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($buildID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function updateLinkedBug test by build - * - * @param int $buildID - * @param array $param - * @access public - * @return array - */ - public function updateLinkedBugTest($buildID, $param = array()) - { - global $tester; - - $build = $this->objectModel->getByID($buildID); - $bugs = array(); - - $createFields = array('bugs' => $bugs); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $build->bugs .= ',' . join(',', $_POST['bugs']); - - $this->objectModel->updateLinkedBug($build); - - $objects = $tester->dao->select('*')->from(TABLE_BUG)->where('id')->in(join(',', $_POST['bugs']))->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function linkStory test by build - * - * @param int $buildID - * @param array $param - * @access public - * @return array - */ - public function linkStoryTest($buildID, $param = array()) - { - global $tester; - - $stories = array(); - - $createFields = array('stories' => $stories); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->linkStory($buildID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function unlinkStory test by build - * - * @param int $buildID - * @param array $stories - * @param int $storyID - * @access public - * @return array - */ - public function unlinkStoryTest($buildID, $stories = array(), $storyID = 0) - { - global $tester; - - $createFields = array('stories' => $stories); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - $this->objectModel->linkStory($buildID); - $this->objectModel->unlinkStory($buildID, $storyID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Functtion batchUnlinkStory test by build - * - * @param int $buildID - * @param array $stories - * @access public - * @return array - */ - public function batchUnlinkStoryTest($buildID, $stories = array()) - { - global $tester; - - $createFields = array('stories' => $stories); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - $this->objectModel->linkStory($buildID); - - unset($_POST); - - $newFields = array('unlinkStories' => $stories); - foreach($newFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - $this->objectModel->batchUnlinkStory($buildID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function linkBug test by build - * - * @param int $buildID - * @param array $param - * @access public - * @return array - */ - public function linkBugTest($buildID, $param = array()) - { - global $tester; - - $bugs = array(); - - $createFields = array('bugs' => $bugs); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->linkBug($buildID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function unlinkBug test by build - * - * @param int $buildID - * @param array $bugs - * @param int $bugID - * @access public - * @return array - */ - public function unlinkBugTest($buildID, $bugs, $bugID) - { - global $tester; - - $createFields = array('bugs' => $bugs); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - $this->objectModel->linkBug($buildID); - $this->objectModel->unlinkBug($buildID, $bugID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function batchUnlinkBugTest($buildID, $bugs) - { - global $tester; - - $createFields = array('bugs' => $bugs); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - $this->objectModel->linkBug($buildID); - - unset($_POST); - - $newFields = array('unlinkBugs' => $bugs); - foreach($newFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - $this->objectModel->batchUnlinkBug($buildID); - - $objects = $tester->dao->select('*')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchAll('id'); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/caselib.class.php b/test/class/caselib.class.php deleted file mode 100644 index 805c9250fb..0000000000 --- a/test/class/caselib.class.php +++ /dev/null @@ -1,185 +0,0 @@ -objectModel = $tester->loadModel('caselib'); - } - - /** - * Save lib state test. - * - * @param int $libID - * @param array $libraries - * @access public - * @return void - */ - public function saveLibStateTest($libID = 0, $libraries = array()) - { - $objects = $this->objectModel->saveLibState($libID, $libraries); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get by ID test. - * - * @param mixed $libID - * @param mixed $setImgSize - * @access public - * @return void - */ - public function getByIdTest($libID, $setImgSize = false) - { - $objects = $this->objectModel->getById($libID, $setImgSize); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Update test. - * - * @param mixed $libID - * @access public - * @return void - */ - public function updateTest($libID) - { - $objects = $this->objectModel->update($libID); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($libID); - - return $objects; - } - - /** - * Delete test. - * - * @param mixed $libID - * @param string $table - * @access public - * @return void - */ - public function deleteTest($libID, $table = '') - { - $objects = $this->objectModel->delete($libID, $table); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($libID); - - return $objects; - } - - /** - * Get libraries test. - * - * @access public - * @return void - */ - public function getLibrariesTest() - { - $objects = $this->objectModel->getLibraries(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get list test. - * - * @param string $orderBy - * @param mixed $pager - * @access public - * @return void - */ - public function getListTest($orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Create test. - * - * @param mixed $param - * @access public - * @return void - */ - public function createTest($param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - $libID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($libID); - - return $objects; - } - - /** - * Get libcases test. - * - * @param mixed $libID - * @param mixed $browseType - * @param int $queryID - * @param int $moduleID - * @param string $sort - * @param mixed $pager - * @access public - * @return void - */ - public function getLibCasesTest($libID, $browseType, $queryID = 0, $moduleID = 0, $sort = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getLibCases($libID, $browseType, $queryID, $moduleID, $sort, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Create from import test. - * - * @param mixed $libID - * @access public - * @return void - */ - public function createFromImportTest($libID) - { - $objects = $this->objectModel->createFromImport($libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Batch create case test. - * - * @param mixed $libID - * @access public - * @return void - */ - public function batchCreateCaseTest($libID) - { - $objects = $this->objectModel->batchCreateCase($libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/ci.class.php b/test/class/ci.class.php deleted file mode 100644 index 25ee9a5114..0000000000 --- a/test/class/ci.class.php +++ /dev/null @@ -1,118 +0,0 @@ -objectModel = $tester->loadModel('ci'); - } - - /** - * Set menu. - * - * @access public - * @return array - */ - public function setMenuTest() - { - $_SESSION['repoID'] = 1; - $this->objectModel->setMenu(); - - global $lang; - return $lang->devops->menu->code; - } - - public function getCompileByID($compileID) - { - global $tester; - return $tester->dao->select('compile.*, job.engine,job.pipeline, pipeline.name as jenkinsName,job.server,pipeline.url,pipeline.account,pipeline.token,pipeline.password') - ->from(TABLE_COMPILE)->alias('compile') - ->leftJoin(TABLE_JOB)->alias('job')->on('compile.job=job.id') - ->leftJoin(TABLE_PIPELINE)->alias('pipeline')->on('job.server=pipeline.id') - ->where('compile.id')->eq($compileID) - ->fetch(); - } - - /** - * Sync compile status. - * - * @param int $jobID - * @access public - * @return string|object - */ - public function syncCompileStatusTest($jobID) - { - global $tester; - $tester->loadModel('job')->exec($jobID); - $compileID = $tester->dao->select('id')->from(TABLE_COMPILE)->orderBy('id_desc')->fetch('id'); - - $notCompileMR = $tester->dao->select('id,jobID') - ->from(TABLE_MR) - ->where('jobID')->gt(0) - ->andWhere('compileStatus')->eq('created') - ->fetchPairs(); - - $compile = $this->getCompileByID($compileID); - - $this->objectModel->syncCompileStatus($compile, $notCompileMR); - $compile = $tester->loadModel('compile')->getByID($compileID); - - if(dao::isError()) return dao::getError(); - return $compile; - } - - /** - * Sync gitlab task status. - * - * @param int $jobID - * @access public - * @return string|bool - */ - public function syncGitlabTaskStatusTest($jobID) - { - global $tester; - $tester->loadModel('job')->exec($jobID); - $compileID = $tester->dao->select('id')->from(TABLE_COMPILE)->orderBy('id_desc')->fetch('id'); - $compile = $this->getCompileByID($compileID); - - $this->objectModel->syncGitlabTaskStatus($compile); - - if(dao::isError()) return dao::getError(); - return true; - } - - /** - * Update build status. - * - * @param int $compileID - * @param string $status - * @access public - * @return string|object - */ - public function updateBuildStatusTest($compileID, $status) - { - $compile = $this->getCompileByID($compileID); - $this->objectModel->updateBuildStatus($compile, $status); - - if(dao::isError()) return dao::getError(); - - global $tester; - $compile = $tester->loadModel('compile')->getByID($compileID); - return $compile; - } - - /** - * Send request. - * - * @param string $url - * @param array $data - * @param string $userPWD - * @access public - * @return string - */ - public function sendRequestTest($url, $data, $userPWD) - { - $return = $this->objectModel->sendRequest($url, $data, $userPWD); - return $return ? 1 : 0; - } -} diff --git a/test/class/company.class.php b/test/class/company.class.php deleted file mode 100644 index 74ecd77654..0000000000 --- a/test/class/company.class.php +++ /dev/null @@ -1,197 +0,0 @@ -objectModel = $tester->loadModel('company'); - } - - /** - * function update test by execution - * - * @param string $objectID - * @param array $param - * @access public - * @return array - */ - public function updateObject($objectID, $param = array()) - { - global $tester; - - $object = $tester->dbh->query("SELECT `name`,`phone`,`fax`,`address`,`zipcode`,`website`,`backyard`,`guest` - FROM zt_company WHERE id = $objectID")->fetch(); - - foreach($object as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->update(); - - $change = $tester->dbh->query("select * from zt_company WHERE id = $objectID")->fetch(); - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } - } - - /** - * function getList test by company - * - * @param string $count - * @access public - * @return array - */ - public function getListTest($count) - { - $object = $this->objectModel->getList(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getFirst test by company - * - * @access public - * @return array - */ - public function getFirstTest() - { - $object = $this->objectModel->getFirst(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function getByID test by company - * - * @param string $companyID - * @access public - * @return array - */ - public function getByIDTest($companyID = '') - { - $object = $this->objectModel->getByID($companyID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function getUsers test by company - * - * @param string $count - * @param string $browseType - * @param string $type - * @param string $queryID - * @param string $deptID - * @param string $sort - * @access public - * @return array - */ - public function getUsersTest($count, $browseType, $type, $queryID, $deptID, $sort = '') - { - $object = $this->objectModel->getUsers($browseType, $type, $queryID, $deptID, $sort); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getOutsideCompanies test by company - * - * @access public - * @return array - */ - public function getOutsideCompaniesTest() - { - $object = $this->objectModel->getOutsideCompanies(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function getCompanyUserPairs test by company - * - * @param string $count - * @access public - * @return array - */ - public function getCompanyUserPairsTest($count) - { - $object = $this->objectModel->getCompanyUserPairs(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - -} diff --git a/test/class/compile.class.php b/test/class/compile.class.php deleted file mode 100644 index 4a0d94dbdf..0000000000 --- a/test/class/compile.class.php +++ /dev/null @@ -1,143 +0,0 @@ -objectModel = $tester->loadModel('compile'); - } - - /** - * Get by id - * - * @param int $buildID - * @access public - * @return object - */ - public function getByIDTest($buildID) - { - $objects = $this->objectModel->getByID($buildID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get build list. - * - * @param int $jobID - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getListTest($jobID, $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($jobID, $orderBy = 'id_desc', $pager = null); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get list by jobID. - * - * @param int $jobID - * @return array - */ - public function getListByJobIDTest($jobID) - { - $objects = $this->objectModel->getListByJobID($jobID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get last result. - * - * @param int $jobID - * @access public - * @return object - */ - public function getLastResultTest($jobID) - { - $objects = $this->objectModel->getLastResult($jobID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get success jobs by job id list. - * - * @param array $jobIDList - * @access public - * @return array - */ - public function getSuccessJobsTest($jobIDList) - { - $objects = $this->objectModel->getSuccessJobs($jobIDList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get build url. - * - * @param object $jenkins - * @access public - * @return object - */ - public function getBuildUrlTest($jenkins) - { - $objects = $this->objectModel->getBuildUrl($jenkins); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Save build by job - * - * @param int $jobID - * @param string $data - * @param string $type - * @access public - * @return void - */ - public function createByJobTest($jobID, $data = '', $type = 'tag') - { - global $tester; - $this->objectModel->createByJob($jobID, $data = '', $type = 'tag'); - - $objects = $tester->dao->select('name')->from(TABLE_COMPILE)->where($type)->eq($data)->fetchAll(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Execute compile - * - * @param object $compile - * @access public - * @return bool - */ - public function execTest($compile) - { - $objects = $this->objectModel->exec($compile); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/cron.class.php b/test/class/cron.class.php deleted file mode 100644 index d65af43a14..0000000000 --- a/test/class/cron.class.php +++ /dev/null @@ -1,253 +0,0 @@ -objectModel = $tester->loadModel('cron'); - } - - /** - * Get by id test. - * - * @param int $cronID - * @access public - * @return object - */ - public function getByIdTest($cronID) - { - $objects = $this->objectModel->getById($cronID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get crons test. - * - * @param string $params - * @access public - * @return array - */ - public function getCronsTest($params = '') - { - $objects = $this->objectModel->getCrons($params); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Parse crons test. - * - * @param array $crons - * @access public - * @return array - */ - public function parseCronTest($crons) - { - $objects = $this->objectModel->parseCron($crons); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Change cron status test. - * - * @param int $cronID - * @param string $status - * @param bool $changeTime - * @access public - * @return bool - */ - public function changeStatusTest($cronID, $status, $changeTime = false) - { - $objects = $this->objectModel->changeStatus($cronID, $status, $changeTime); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Change cron status to running test. - * - * @param int $cronID - * @access public - * @return bool|int - */ - public function changeStatusRunningTest($cronID) - { - $objects = $this->objectModel->changeStatusRunning($cronID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Log cron test. - * - * @param string $log - * @access public - * @return void - */ - public function logCronTest($log) - { - $objects = $this->objectModel->logCron($log); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get last execed time test. - * - * @access public - * @return string - */ - public function getLastTimeTest() - { - $objects = $this->objectModel->getLastTime(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Runable cron test. - * - * @access public - * @return bool - */ - public function runableTest() - { - $objects = $this->objectModel->runable(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Check change cron test. - * - * @access public - * @return bool - */ - public function checkChangeTest() - { - $objects = $this->objectModel->checkChange(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Create cron test. - * - * @param array $param - * @access public - * @return int - */ - public function createTest($param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - $cronID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($cronID); - return $objects; - } - - /** - * Update cron test. - * - * @param int $cronID - * @access public - * @return bool - */ - public function updateTest($cronID, $param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - $objects = $this->objectModel->update($cronID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($cronID); - return $objects; - } - - /** - * Check cron rule test. - * - * @param object $cron - * @access public - * @return string - */ - public function checkRuleTest($cron) - { - $objects = $this->objectModel->checkRule($cron); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Mark cron status test. - * - * @param mixed $status - * @param int $configID - * @access public - * @return void - */ - public function markCronStatusTest($status, $configID = 0) - { - $objects = $this->objectModel->markCronStatus($status, $configID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get config id test. - * - * @access public - * @return void - */ - public function getConfigIDTest() - { - $objects = $this->objectModel->getConfigID(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get current cron status test. - * - * @access public - * @return int - */ - public function getTurnonTest() - { - $objects = $this->objectModel->getTurnon(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/custom.class.php b/test/class/custom.class.php deleted file mode 100644 index 8cdf495085..0000000000 --- a/test/class/custom.class.php +++ /dev/null @@ -1,358 +0,0 @@ -objectModel = $tester->loadModel('custom'); - } - - /** - * Test get all custom lang. - * - * @access public - * @return int - */ - public function getAllLangTest() - { - $objects = $this->objectModel->getAllLang(); - - if(dao::isError()) return dao::getError(); - $counts = count($objects); - - return $counts; - } - - /** - * Test set value of an item. - * - * @param string $path - * @param string $value - * @access public - * @return object|int - */ - public function setItemTest($path, $value = '') - { - $objects = $this->objectModel->setItem($path, $value); - - if(dao::isError()) return dao::getError(); - - $level = substr_count($path, '.'); - if($level > 1) - { - if($level == 2) list($lang, $module, $key) = explode('.', $path); - if($level == 3) list($lang, $module, $section, $key) = explode('.', $path); - if($level == 4) list($lang, $module, $section, $key, $system) = explode('.', $path); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_LANG)->where('`lang`')->eq($lang)->andWhere('`module`')->eq($module)->andWhere('`key`')->eq($key)->fetch(); - } - - return $objects; - } - - /** - * Test get some items - * - * @param string $paramString - * @access public - * @return array - */ - public function getItemsTest($paramString) - { - $objects = $this->objectModel->getItems($paramString); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test delete items. - * - * @param string $paramString - * @access public - * @return int - */ - public function deleteItemsTest($paramString) - { - $objects = $this->objectModel->deleteItems($paramString); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test parse the param string for select or delete items. - * - * @param string $paramString - * @access public - * @return array - */ - public function parseItemParamTest($paramString) - { - $objects = $this->objectModel->parseItemParam($paramString); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test create a DAO object to select or delete one or more records. - * - * @param string $paramString - * @param string $method - * @access public - * @return array|int - */ - public function prepareSQLTest($paramString, $method = 'select') - { - $params = $this->objectModel->parseItemParam($paramString); - if($method == 'delete') - { - $objects = $this->objectModel->prepareSQL($params, $method)->exec(); - } - else - { - $objects = $this->objectModel->prepareSQL($params, $method)->orderBy('lang,id')->fetchAll('key'); - } - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveCustomMenuTest($menu, $module, $method = '') - { - $objects = $this->objectModel->saveCustomMenu($menu, $module, $method); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRequiredFieldsTest($moduleConfig) - { - $objects = $this->objectModel->getRequiredFields($moduleConfig); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get module fields. - * - * @param string $moduleName - * @param string $method - * @access public - * @return array - */ - public function getFormFieldsTest($moduleName, $method = '') - { - global $app; - $app->loadLang($moduleName); - - $objects = $this->objectModel->getFormFields($moduleName, $method); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get UR and SR pairs. - * - * @access public - * @return array - */ - public function getURSRPairsTest() - { - $objects = $this->objectModel->getURSRPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get UR pairs. - * - * @access public - * @return array - */ - public function getURPairsTest() - { - $objects = $this->objectModel->getURPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get SR pairs. - * - * @access public - * @return array - */ - public function getSRPairsTest() - { - $objects = $this->objectModel->getSRPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get UR and SR list. - * - * @access public - * @return array - */ - public function getURSRListTest() - { - $objects = $this->objectModel->getURSRList(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test save required fields. - * - * @param string $moduleName - * @param string $requiredFields - * @param string $fieldsType - * @access public - * @return object - */ - public function saveRequiredFieldsTest($moduleName, $requiredFields, $fieldsType) - { - global $app, $tester; - $app->loadLang($moduleName); - - $_POST = $requiredFields; - $this->objectModel->saveRequiredFields($moduleName); - - $objects = $tester->dao->select('`value`')->from(TABLE_CONFIG) - ->where('`owner`')->eq('system') - ->andWhere('`module`')->eq($moduleName) - ->andWhere('`key`')->eq('requiredFields') - ->andWhere('`section`')->eq($fieldsType) - ->fetch(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test set product and project and sprint concept. - * - * @param int $sprintConcept - * @access public - * @return object - */ - public function setConceptTest($sprintConcept) - { - global $tester; - - $_POST['sprintConcept'] = $sprintConcept; - $this->objectModel->setConcept(); - - if(dao::isError()) return dao::getError(); - $objects = $tester->dao->select('`id`')->from(TABLE_BLOCK)->where('source')->eq('execution')->fetch(); - - unset($_POST); - - return $objects; - } - - /** - * Test set UR and SR concept. - * - * @param array $SRName - * @access public - * @return int - */ - public function setURAndSRTest($SRName) - { - $_POST = $SRName; - $objects = $this->objectModel->setURAndSR(); - - if(dao::isError()) return dao::getError(); - - unset($_POST); - - return $objects; - } - - /** - * Test edit UR and SR concept. - * - * @param int $key - * @param string $SRName - * @access public - * @return object - */ - public function updateURAndSRTest($key = 0, $SRName = '') - { - global $app, $tester; - - $_POST['URName'] = '用户需求'; - $_POST['SRName'] = $SRName; - $this->objectModel->updateURAndSR($key); - - if(dao::isError()) return dao::getError(); - - $lang = $app->getClientLang(); - - $objects = $tester->dao->select('`value`')->from(TABLE_LANG) - ->where('`key`')->eq($key) - ->andWhere('section')->eq('URSRList') - ->andWhere('lang')->eq($lang) - ->andWhere('module')->eq('custom') - ->fetch(); - - unset($_POST); - - return $objects; - } - - public function setStoryRequirementTest() - { - $objects = $this->objectModel->setStoryRequirement(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Check for waterfallplus project data.. - * - * @param string $param deleteproject - * @access public - * @return int - */ - public function hasWaterfallplusDataTest($param = '') - { - if($param == 'deleteproject') - { - global $tester; - $tester->dao->update(TABLE_PROJECT) - ->set('deleted')->eq(1) - ->where('type')->eq('project') - ->andWhere('model')->eq('waterfallplus') - ->exec(); - } - return $this->objectModel->hasWaterfallplusData(); - } -} diff --git a/test/class/datatable.class.php b/test/class/datatable.class.php deleted file mode 100644 index af457d73d5..0000000000 --- a/test/class/datatable.class.php +++ /dev/null @@ -1,74 +0,0 @@ -objectModel = $tester->loadModel('datatable'); - } - - /** - * Test get field list. - * - * @param string $module - * @param string $method - * @access public - * @return void - */ - public function getFieldListTest($module, $method) - { - $module = zget($this->objectModel->config->datatable->moduleAlias, "$module-$method", $module); - $result = $this->objectModel->getFieldList($module); - return $result; - } - - /** - * Test get save setting field. - * - * @param string $module - * @param string $method - * @access public - * @return void - */ - public function getSettingTest($module, $method) - { - $this->objectModel->app->methodName = $method; - $result = $this->objectModel->getSetting($module); - return $result; - } - - /** - * Test print table head. - * - * @param array $data - * @access public - * @return void - */ - public function printHeadTest($data) - { - ob_start(); - $this->objectModel->printHead($data['cols'], $data['orderBy'], $data['vars'], $data['checkBox']); - $head = ob_get_clean(); - - $isTh = strpos($head, 'objectModel->setFixedFieldWidth($setting); - return $result; - } -} diff --git a/test/class/dept.class.php b/test/class/dept.class.php deleted file mode 100644 index f660b61baa..0000000000 --- a/test/class/dept.class.php +++ /dev/null @@ -1,359 +0,0 @@ -objectModel = $tester->loadModel('dept'); - } - - /** - * function getByID test by dept - * - * @param string $deptID - * @access public - * @return array - */ - public function getByIDTest($deptID) - { - $objects = $this->objectModel->getByID($deptID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getDeptPairs test by dept - * - * @param string $deptID - * @param string $count - * @access public - * @return array - */ - public function getDeptPairsTest($deptID, $count) - { - $objects = $this->objectModel->getDeptPairs($deptID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function buildMenuQuery test by dept - * - * @param string $rootDeptID - * @access public - * @return array - */ - public function buildMenuQueryTest($rootDeptID) - { - $objects = $this->objectModel->buildMenuQuery($rootDeptID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getOptionMenu test by dept - * - * @param string $rootDeptID - * @param string $count - * @access public - * @return array - */ - public function getOptionMenuTest($rootDeptID, $count) - { - $objects = $this->objectModel->getOptionMenu($rootDeptID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getTreeMenu test by dept - * - * @param string $rootDeptID - * @param array $userFunc - * @param int $param - * @access public - * @return string - */ - public function getTreeMenuTest($rootDeptID, $userFunc, $param = 0) - { - $objects = $this->objectModel->getTreeMenu($rootDeptID, $userFunc, $param = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function update test by dept - * - * @param string $deptID - * @param array $param - * @access public - * @return array - */ - public function updateTest($deptID, $param = array()) - { - global $tester; - - $createFields = array('parent' => '', 'name' => '', 'manager' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->update($deptID); - - unset($_POST); - - $objects = $tester->dao->select('*')->from(TABLE_DEPT)->where('id')->eq($deptID)->fetchAll('id'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function createManageLink test by dept - * - * @param string $deptID - * @access public - * @return string - */ - public function createManageLinkTest($deptID) - { - $dept = $this->objectModel->getByID($deptID); - $objects = $this->objectModel->createManageLink($dept); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function createMemberLink test by dept - * - * @param string $deptID - * @access public - * @return string - */ - public function createMemberLinkTest($deptID) - { - $dept = $this->objectModel->getByID($deptID); - $objects = $this->objectModel->createMemberLink($dept); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function createGroupManageMemberLink test by dept - * - * @param string $deptID - * @param string $groupID - * @access public - * @return string - */ - public function createGroupManageMemberLinkTest($deptID, $groupID) - { - $dept = $this->objectModel->getByID($deptID); - $objects = $this->objectModel->createGroupManageMemberLink($dept, $groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function createManageProjectAdminLink test by dept - * - * @param string $deptID - * @param string $groupID - * @access public - * @return string - */ - public function createManageProjectAdminLinkTest($deptID, $groupID) - { - $dept = $this->objectModel->getByID($deptID); - $objects = $this->objectModel->createManageProjectAdminLink($dept, $groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getSons test by dept - * - * @param string $deptID - * @param string $count - * @access public - * @return array - */ - public function getSonsTest($deptID, $count) - { - $objects = $this->objectModel->getSons($deptID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getAllChildId test by dept - * - * @param string $deptID - * @param string $count - * @access public - * @return array - */ - public function getAllChildIdTest($deptID, $count) - { - $objects = $this->objectModel->getAllChildId($deptID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getParents test by dept - * - * @param string $deptID - * @param string $count - * @access public - * @return array - */ - public function getParentsTest($deptID, $count) - { - $objects = $this->objectModel->getParents($deptID); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - - return $objects; - } - - /** - * function updateOrder test by dept - * - * @param array $orders - * @access public - * @return array - */ - public function updateOrderTest($orders) - { - global $tester; - - $objects = $this->objectModel->updateOrder($orders); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_DEPT)->where('id')->eq($orders[0])->fetchAll('id'); - - return $objects; - } - - /** - * function manageChild test by dept - * - * @param string $parentDeptID - * @param array $childs - * @param string $count - * @access public - * @return arrray - */ - public function manageChildTest($parentDeptID, $childs, $count) - { - $objects = $this->objectModel->manageChild($parentDeptID, $childs); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getUsers test by dept - * - * @param string $browseType - * @param string $deptID - * @param string $count - * @param string $orderBy - * @param null $pager - * @access public - * @return array - */ - public function getUsersTest($browseType = 'inside', $deptID = 0, $count = 0, $orderBy = 'id', $pager = null) - { - $objects = $this->objectModel->getUsers($browseType, $deptID, $pager, $orderBy); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function getDeptUserPairs test by dept - * - * @param int $deptID - * @param int $count - * @param string $key - * @param string $type - * @param string $params - * @access public - * @return array - */ - public function getDeptUserPairsTest($deptID = 0, $count = 0, $key = 'account', $type = 'inside', $params = '') - { - $objects = $this->objectModel->getDeptUserPairs($deptID, $key, $type, $params); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } - - /** - * function delete test by dept - * - * @param int $deptID - * @access public - * @return int - */ - public function deleteTest($deptID) - { - global $tester; - - $this->objectModel->delete($deptID); - - $objects = $tester->dao->select('*')->from(TABLE_DEPT)->fetchAll(); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - public function getDataStructureTest($count) - { - $objects = $this->objectModel->getDataStructure(); - - if(dao::isError()) return dao::getError(); - if($count == '1') return count($objects); - - return $objects; - } -} diff --git a/test/class/design.class.php b/test/class/design.class.php deleted file mode 100644 index c99db6abd5..0000000000 --- a/test/class/design.class.php +++ /dev/null @@ -1,168 +0,0 @@ -objectModel = $tester->loadModel('design'); - } - - /** - * Function create test by design - * - * @param int $projectID - * @param array $param - * @access public - * @return object - */ - public function createTest($projectID, $param = array()) - { - $labels = array(); - $files = array(); - - $createFields = array('product' => '', 'story' => '', 'type' => '', 'name' => '', 'labels' => $labels, 'files' => $files, 'desc' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create($projectID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($objectID); - - return $objects; - } - - /** - * Function batchCreate test by desgin - * - * @param int $projectID - * @param int $productID - * @param array $param - * @access public - * @return array - */ - public function batchCreateTest($projectID, $productID, $param = array()) - { - global $tester; - - $story = array('', '', '', ''); - $type = array('', '', '', ''); - $name = array('', '', '', ''); - $desc = array('', '', '', ''); - - $createFields = array('story' => $story, 'type' => $type, 'name' => $name, 'desc' => $desc); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->batchCreate($projectID, $productID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_DESIGN)->where('project')->eq($projectID)->andwhere('product')->eq($productID)->fetchAll(); - - return $objects; - } - - /** - * Function update test by desgin - * - * @param int $designID - * @param array $param - * @access public - * @return array - */ - public function updateTest($designID, $param = array()) - { - global $tester; - - $labels = array(); - $files = array(); - - $createFields = $tester->dao->select('`product`,`story`,`type`,`name`,`desc`')->from(TABLE_DESIGN)->where('id')->eq($designID)->fetchAll(); - $createFields[0]->labels = $labels; - $createFields[0]->files = $files; - foreach($createFields[0] as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($designID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function assign test by desgin - * - * @param int $designID - * @param array $param - * @access public - * @return array - */ - public function assignTest($designID, $param = array()) - { - global $tester; - - $createFields = array('assignedTo' => '', 'comment' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->assign($designID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_DESIGN)->where('id')->eq($designID)->fetchAll(); - - return $objects; - } - - public function linkCommitTest($designID, $repoID, $param = array()) - { - global $tester; - - $revision = array(); - - $createFields = array('revision' => $revision); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->linkCommit($designID, $repoID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_DESIGN)->where('id')->eq($designID)->fetchAll(); - - return $objects; - } - - public function unlinkCommitTest($designID = 0, $commitID = 0) - { - $objects = $this->objectModel->unlinkCommit($designID = 0, $commitID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getCommitTest($designID = 0, $pager = null) - { - $objects = $this->objectModel->getCommit($designID = 0, $pager = null); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/dev.class.php b/test/class/dev.class.php deleted file mode 100644 index 93a6c272c5..0000000000 --- a/test/class/dev.class.php +++ /dev/null @@ -1,201 +0,0 @@ -objectModel = $tester->loadModel('dev'); - } - - /** - * Test get All tables. - * - * @access public - * @return void - */ - public function getTablesTest() - { - $result = $this->objectModel->getTables(); - return $result; - } - - /** - * Test get fields of table. - * - * @param string $table - * @access public - * @return void - */ - public function getFieldsTest($table) - { - $result = $this->objectModel->getFields($table); - return $result; - } - - /** - * Test set field method. - * - * @param array $type - * @access public - * @return array - */ - public function setFieldTest($type) - { - $this->objectModel->dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); - $sql = "DESC zt_product"; - $rawFields = $this->objectModel->dbh->query($sql)->fetchAll(); - return $this->objectModel->setField((array)$rawFields[1], (object)$rawFields[1], $type, 1); - } - - - /** - * Test get APIs of a module. - * - * @param string $module - * @access public - * @return void - */ - public function getAPIsTest($module) - { - $result = $this->objectModel->getAPIs($module); - return $result; - } - - /** - * Test get all modules. - * - * @access public - * @return void - */ - public function getModulesTest() - { - $result = $this->objectModel->getModules(); - foreach($result as $module => $group) $result[$module] = current($group); - return $result; - } - - /** - * Test get original lang method. - * - * @param string $type - * @param string $module - * @param string $method - * @access public - * @return int|array - */ - public function getOriginalLangTest($type = 'common', $module = '', $method = '') - { - $result = $this->objectModel->getOriginalLang($type, $module, $method); - return empty($result) ? 0 : $result; - } - - /** - * Test get customed lang method. - * - * @param string $type - * @param string $module - * @param string $method - * @access public - * @return int|array - */ - public function getCustomedLangTest($type = 'common', $module = '', $method = '') - { - $result = $this->objectModel->getCustomedLang($type, $module, $method); - return empty($result) ? 0 : $result; - } - - /** - * Get nav lang. - * - * @param string $type - * @param string $module - * @param string $method - * @param string $language - * @param object $defaultLang - * @access public - * @return object - */ - public function getNavLangTest($type, $module, $method, $language = 'zh-cn', $defaultLang = null) - { - return $this->objectModel->getNavLang($type, $module, $method, $language, $defaultLang); - } - - /** - * Get links title. - * - * @access public - * @return array - */ - public function getLinkTitleTest() - { - $lang = $this->objectModel->lang->mainNav; - return $this->objectModel->getLinkTitle($lang); - } - - /** - * Test parse common lang. - * - * @param string $lang - * @access public - * @return string - */ - public function parseCommonLangTest($lang) - { - $lang = $this->objectModel->parseCommonLang($lang); - return empty($lang) ? 'null' : $lang; - } - - /** - * Test is original lang changed. - * - * @param array|string $defaultValue - * @param array|string $customedLang - * @access public - * @return string - */ - public function isOriginalLangChangedTest($defaultValue, $customedLang) - { - $isOriginalLangChanged = $this->objectModel->isOriginalLangChanged($defaultValue, $customedLang); - return $isOriginalLangChanged ? 'TRUE' : 'FALSE'; - } - - /** - * Test save customed lang. - * - * @param string $type - * @param string $module - * @param string $method - * @param string $language - * @access public - * @return string - */ - public function saveCustomedLangTest($type, $module, $method, $language) - { - $moduleName = $module; - if($type == 'common' or $type == 'first') $moduleName = 'common'; - if($type == 'second') $moduleName = $module . 'Menu'; - if($type == 'third') $moduleName = $module . 'SubMenu'; - - $this->objectModel->config->custom->URSR = $this->objectModel->dao->select('*')->from(TABLE_LANG)->where('section')->eq('URSRList')->andWhere('module')->eq('custom')->andWhere('lang')->eq($language)->orderBy('id')->limit(1)->fetch('key'); - $this->objectModel->saveCustomedLang($type, $moduleName, $method, $language); - $customedLang = $this->objectModel->getCustomedLang($type, $module, $method, $language); - return empty($customedLang) ? 'null' : implode('|', $customedLang); - } - - /** - * Sort menus. - * - * @param object|array $menus - * @access public - * @return string - */ - public function sortMenusTest($menus) - { - $result = ''; - $menus = $this->objectModel->sortMenus($menus); - foreach($menus as $key => $value) $result .= $key . ','; - - return $result; - } -} diff --git a/test/class/doc.class.php b/test/class/doc.class.php deleted file mode 100644 index a224f2cf86..0000000000 --- a/test/class/doc.class.php +++ /dev/null @@ -1,596 +0,0 @@ -objectModel = $tester->loadModel('doc'); - } - - /** - * Function createLib test by doc - * - * @param array $param - * @access public - * @return object - */ - public function createLibTest($param) - { - $createFields = array('type' => '', 'name' => '', 'acl' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - $objectID = $this->objectModel->createLib(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getLibById($objectID); - - return $objects; - } - - /** - * Function createApiLib test by doc - * - * @param array $param - * @access public - * @return object - */ - public function createApiLibTest($param) - { - global $tester; - $tester->loadModel('api'); - $tester->app->loadLang('doclib'); - - $createFields = array('name' => '', 'baseUrl' => '', 'acl' => '', 'desc' => '测试详情'); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - $objectID = $this->objectModel->createApiLib(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getLibById($objectID); - - return $objects; - } - - /** - * Function updateApiLib test by doc - * - * @param int $id - * @param array $param - * @access public - * @return void - */ - public function updateApiLibTest($id, $param) - { - global $tester; - $tester->app->loadConfig('api'); - $tester->app->loadLang('doclib'); - - $oldDoc = $this->objectModel->getLibById($id); - $data = new stdClass; - foreach($param as $key => $value) $data->$key = $value; - - $objects = $this->objectModel->updateApiLib($id, $oldDoc, $data); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function updateLib test by doc - * - * @param int $libID - * @param array $param - * @access public - * @return array - */ - public function updateLibTest($libID, $param) - { - global $tester; - $tester->app->loadConfig('doc'); - - foreach($param as $key => $value) $_POST[$key] = $value; - $objects = $this->objectModel->updateLib($libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getDocsByBrowseType test by doc - * - * @param string $browseType - * @param array $moduleID - * @param string $sort - * @param mixed $pager - * @access public - * @return array - */ - public function getDocsByBrowseTypeTest($browseType, $moduleID, $sort = 'id_desc', $pager = null) - { - global $tester; - $tester->app->loadConfig('doc'); - - $objects = $this->objectModel->getDocsByBrowseType($browseType, $queryID = '', $moduleID, $sort, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function create test by doc - * - * @param array $param - * @access public - * @return array - */ - public function createTest($param) - { - global $tester; - $tester->loadModel('api'); - $tester->app->loadLang('doclib'); - - $labels = array(); - $files = array(); - - $createFields = array('lib' => '', 'module' => '', 'title' => '', 'keywords' => '', 'type' => '', 'content' => '', 'contentMarkdown' => '', 'contentType' => '', - 'url' => '', 'labels' => $labels, 'files' => $files, 'contactListMenu' => '', 'acl' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->create(); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_DOC)->where('title')->eq($_POST['title'])->andwhere('lib')->eq($_POST['lib'])->fetchAll(); - unset($_POST); - - return $objects; - } - - /** - * Function update test by doc - * - * @param int $docID - * @param array $param - * @access public - * @return array - */ - public function updateTest($docID, $param) - { - global $tester; - $tester->app->loadConfig('api'); - $tester->app->loadLang('doclib'); - - $labels = array(); - $files = array(); - - $createFields = array('lib' => '', 'module' => '', 'title' => '', 'keywords' => '', 'type' => '', 'content' => '', 'contentType' => '', - 'url' => '', 'labels' => $labels, 'files' => $files, 'contactListMenu' => '', 'acl' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($docID); - - if(dao::isError()) return dao::getError(); - - return $objects["changes"]; - } - - /** - * Function saveDraft test by doc - * - * @param mixed $docID - * @param array $param - * @access public - * @return void - */ - public function saveDraftTest($docID, $param = array()) - { - global $tester; - $tester->app->loadConfig('doc'); - $tester->app->loadConfig('allowedTags'); - $createFields = array('content' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->saveDraft($docID); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('id,draft')->from(TABLE_DOC)->where('id')->eq($docID)->fetchAll('id'); - unset($_POST); - - return $objects; - } - - /** - * Function getAllLibsByType test by doc - * - * @param mixed $type - * @param mixed $product - * @param mixed $pager - * @access public - * @return void - */ - public function getAllLibsByTypeTest($type, $product, $pager = null) - { - $objects = $this->objectModel->getAllLibsByType($type, $pager, $product); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test stat module and document counts of lib. - * - * @param array $idList - * @access public - * @return array - */ - public function statLibCountsTest($idList) - { - $objects = $this->objectModel->statLibCounts($idList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get lib files. - * - * @param string $type - * @param int $objectID - * @param string $orderBy - * @param object $pager - * @access public - * @return string - */ - public function getLibFilesTest($type, $objectID, $orderBy, $pager = null) - { - $objects = $this->objectModel->getLibFiles($type, $objectID, $orderBy, $pager = null); - - if(dao::isError()) return dao::getError(); - - $titles = ''; - foreach($objects as $object) - { - $titles .= "$object->title,"; - } - $titles = trim($titles, ','); - return $titles; - } - - /** - * Test get file source pairs. - * - * @param array $files - * @access public - * @return void - */ - public function getFileSourcePairsTest($type, $objectID) - { - $files = $this->objectModel->getLibFiles($type, $objectID, 't1.id_desc', $pager = null); - - $objects = $this->objectModel->getFileSourcePairs($files); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $type => $items) - { - $counts .= "$type:" . count($items) .';'; - } - return $counts; - } - - /** - * Test get file icon. - * - * @param string $type - * @param int $objectID - * @access public - * @return string - */ - public function getFileIconTest($type, $objectID) - { - $files = $this->objectModel->getLibFiles($type, $objectID, 't1.id_desc', $pager = null); - - $objects = $this->objectModel->getFileIcon($files); - - if(dao::isError()) return dao::getError(); - - $icons = ''; - foreach($objects as $object) - { - preg_match("/icon-[^']*/", $object, $matches); - $icons .= "$matches[0] "; - } - $icons = trim($icons); - return $icons; - } - - /** - * Test get doc tree. - * - * @param int $libID - * @access public - * @return string - */ - public function getDocTreeTest($libID) - { - $objects = $this->objectModel->getDocTree($libID); - - if(dao::isError()) return dao::getError(); - - $names = ''; - foreach($objects as $object) - { - $names .= "$object->name:"; - foreach($object->children as $children) $names .= (isset($children->name) ? $children->name : $children->title) . ","; - $names = trim($names, ','); - $names .= ";"; - } - return $names; - } - - /** - * Test fill docs in tree. - * - * @param object $node - * @param int $libID - * @access public - * @return object - */ - public function fillDocsInTreeTest($node, $libID) - { - $object = $this->objectModel->fillDocsInTree($node, $libID); - - if(dao::isError()) return dao::getError(); - - $docsCounts = "$object->name:$object->docsCount;"; - foreach($object->children as $children) - { - if(isset($children->type) and $children->type == 'doc') continue; - $docsCounts .= "$children->name:$children->docsCount;"; - } - return $docsCounts; - } - - public function getProductCrumbTest($productID, $executionID = 0) - { - $objects = $this->objectModel->getProductCrumb($productID, $executionID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test set lib users. - * - * @param string $type - * @param int $objectID - * @access public - * @return array - */ - public function setLibUsersTest($type, $objectID) - { - $objects = $this->objectModel->setLibUsers($type, $objectID); - - if(dao::isError()) return dao::getError(); - - return implode($objects, ','); - } - - public function getLibIdListByProjectTest($projectID = 0) - { - $objects = $this->objectModel->getLibIdListByProject($projectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get statistic information. - * - * @access public - * @return object - */ - public function getStatisticInfoTest() - { - $objects = $this->objectModel->getStatisticInfo(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get the previous and next doc. - * - * @param int $docID - * @param int $libID - * @access public - * @return object - */ - public function getPreAndNextDocTest($docID, $libID) - { - $objects = $this->objectModel->getPreAndNextDoc($docID, $libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function printChildModuleTest($module, $libID, $methodName, $browseType, $moduleID) - { - $objects = $this->objectModel->printChildModule($module, $libID, $methodName, $browseType, $moduleID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function buildCrumbTitleTest($libID = 0, $param = 0, $title = '') - { - $objects = $this->objectModel->buildCrumbTitle($libID = 0, $param = 0, $title = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function buildCreateButton4DocTest($objectType, $objectID, $libID) - { - $objects = $this->objectModel->buildCreateButton4Doc($objectType, $objectID, $libID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function buildCollectButton4DocTest() - { - $objects = $this->objectModel->buildCollectButton4Doc(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function buildBrowseSwitchTest($type, $objectID, $viewType) - { - $objects = $this->objectModel->buildBrowseSwitch($type, $objectID, $viewType); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setFastMenuTest($fastLib) - { - $objects = $this->objectModel->setFastMenu($fastLib); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get toList and ccList. - * - * @param int $docID - * @access public - * @return bool|array - */ - public function getToAndCcListTest($docID) - { - $doc = $this->objectModel->getByID($docID); - $objects = $this->objectModel->getToAndCcList($doc); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function selectTest($type, $objects, $objectID, $libs, $libID = 0) - { - $objects = $this->objectModel->select($type, $objects, $objectID, $libs, $libID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getApiModuleTreeTest($rootID, $docID = 0, $release = 0) - { - $objects = $this->objectModel->getApiModuleTree($rootID, $docID = 0, $release = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getTreeMenuTest($type, $objectID, $rootID, $startModule = 0, $docID = 0) - { - $objects = $this->objectModel->getTreeMenu($type, $objectID, $rootID, $startModule = 0, $docID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function summaryTest($files) - { - $objects = $this->objectModel->summary($files); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setMenuByTypeTest($type, $objectID, $libID, $appendLib = 0) - { - $objects = $this->objectModel->setMenuByType($type, $objectID, $libID, $appendLib = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Whether the url of link type documents needs to be autoloaded. - * - * @param int $docID - * @access public - * @return bool - */ - public function checkAutoloadPageTest($docID) - { - $doc = $this->objectModel->getByID($docID); - $objects = $this->objectModel->checkAutoloadPage($doc); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check api library name. - * - * @param object $lib - * @param string $libType - * @param int $libID - * @access public - * @return bool - */ - public function checkApiLibNameTest($lib, $libType, $libID = 0) - { - $this->objectModel->checkApiLibName($lib, $libType, $libID); - - if(dao::isError()) - { - $errors = dao::getError(); - return zget($errors, 'name', '1'); - } - - return 'noerror'; - } -} diff --git a/test/class/editor.class.php b/test/class/editor.class.php deleted file mode 100644 index 4081adfd1f..0000000000 --- a/test/class/editor.class.php +++ /dev/null @@ -1,398 +0,0 @@ -objectModel = $tester->loadModel('editor'); - } - - /** - * Test for get module files. - * - * @param string $moduleName - * @access public - * @return 1|0 - */ - public function getModuleFilesTest($moduleName) - { - $moduleFiles = $this->objectModel->getModuleFiles($moduleName); - $modulePath = $this->objectModel->app->getModulePath('', $moduleName); - if(!isset($moduleFiles[$modulePath])) return 0; - if(!isset($moduleFiles[$modulePath][$modulePath . 'model.php'])) return 0; - if(!isset($moduleFiles[$modulePath][$modulePath . 'model.php'][$modulePath . 'model.php/create'])) return 0; - return 1; - } - - /** - * Test for get extension files. - * - * @param string $moduleName - * @access public - * @return 1|0 - */ - public function getExtensionFilesTest($moduleName) - { - $files = $this->objectModel->getExtensionFiles($moduleName); - $edition = $this->objectModel->config->edition; - - if($edition == 'open') return 1; - - $extensionRoot = $this->objectModel->app->getExtensionRoot(); - $extensionPath = $extensionRoot . $edition . DS . $moduleName . DS . 'ext' . DS . 'control' . DS; - if(!isset($files[$edition][$extensionPath])) return 0; - return 1; - } - - /** - * Test for get two grade files. - * - * @access public - * @return 1|0 - */ - public function getTwoGradeFilesTest() - { - $extensionFullDir = $this->objectModel->app->getModulePath('', 'todo'); - $files = $this->objectModel->getTwoGradeFiles($extensionFullDir); - if(!isset($files[$extensionFullDir . 'lang'])) return 0; - if(!isset($files[$extensionFullDir . 'lang'][$extensionFullDir . 'lang' . DS . 'zh-cn.php'])) return 0; - return 1; - } - - /** - * Test for analysis. - * - * @access public - * @return 1|0 - */ - public function analysisTest() - { - $fileName = $this->objectModel->app->getModulePath('', 'todo') . 'control.php'; - $objects = $this->objectModel->analysis($fileName); - if(!isset($objects[$fileName . '/create'])) return 0; - return 1; - } - - /** - * Test for print tree. - * - * @access public - * @return 1|0 - */ - public function printTreeTest() - { - $files = $this->objectModel->getModuleFiles('todo'); - $tree = $this->objectModel->printTree($files); - if(strpos($tree, 'extendTree') === false) return 0; - if(strpos($tree, 'L2hvbWUvei9zaXRlcy96ZW50YW9tYXgvbW9kdWxlL3RvZG8vbW9kZWwucGhw') === false) return 0; - if(strpos($tree, 'L2hvbWUvei9zaXRlcy96ZW50YW9tYXgvbW9kdWxlL3RvZG8vbW9kZWwucGhwL2JhdGNoQ3JlYXRl') === false) return 0; - if(strpos($tree, "target='editWin'") === false) return 0; - return 1; - } - - /** - * Test for add link for dir. - * - * @access public - * @return string - */ - public function addLink4DirTest() - { - $result = ''; - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - - $controlPath = $modulePath . 'control.php'; - $link = $this->objectModel->addLink4Dir($controlPath); - $result .= (strpos($link, 'newPage') === false ? 0 : 1) . ','; - - $modelPath = $modulePath . 'model.php'; - $link = $this->objectModel->addLink4Dir($modelPath); - $result .= (strpos($link, 'newMethod') === false ? 0 : 1) . ','; - - $langPath = $modulePath . 'lang'; - $link = $this->objectModel->addLink4Dir($langPath); - $result .= (strpos($link, 'lang') === false ? 0 : 1) . ','; - - $edition = $this->objectModel->config->edition; - if($edition == 'open') return $result . '1,1,1,1,1'; - - $extensionRoot = $this->objectModel->app->getExtensionRoot(); - $extensionPath = $extensionRoot . $edition . DS . 'todo' . DS . 'ext' . DS; - $extControlPath = $extensionPath . 'control'; - $link = $this->objectModel->addLink4Dir($extControlPath); - $result .= (strpos($link, 'newExtend') === false ? 0 : 1) . ','; - - $extModelPath = $extensionPath . 'model'; - $link = $this->objectModel->addLink4Dir($extModelPath); - $result .= (strpos($link, 'newExtend') === false ? 0 : 1) . ','; - - $extJSPath = $extensionPath . 'js'; - $link = $this->objectModel->addLink4Dir($extJSPath); - $result .= (strpos($link, 'newJS') === false ? 0 : 1) . ','; - - $extCSSPath = $extensionPath . 'css'; - $link = $this->objectModel->addLink4Dir($extCSSPath); - $result .= (strpos($link, 'newCSS') === false ? 0 : 1) . ','; - - $extLangPath = $extensionPath . 'lang'; - $link = $this->objectModel->addLink4Dir($extLangPath); - $result .= (strpos($link, 'lang') === false ? 0 : 1); - return $result; - } - - /** - * Test for add link for file. - * - * @access public - * @return string - */ - public function addLink4FileTest() - { - $result = ''; - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - - $viewPath = $modulePath . 'view' . DS . 'create.html.php'; - $link = $this->objectModel->addLink4File($viewPath, 'create.html.php'); - $result .= ((strpos($link, 'override') === false || strpos($link, 'newHook') === false) ? 0 : 1) . ','; - - $controlPath = $modulePath . 'control.php' . DS . 'create'; - $link = $this->objectModel->addLink4File($controlPath, 'create'); - $result .= (strpos($link, 'extendControl') === false ? 0 : 1) . ','; - - $modelPath = $modulePath . 'model.php' . DS . 'create'; - $link = $this->objectModel->addLink4File($modelPath, 'create'); - $result .= (strpos($link, 'extendModel') === false ? 0 : 1) . ','; - - $langPath = $modulePath . 'lang' . DS . 'zh-cn.php'; - $link = $this->objectModel->addLink4File($langPath, 'zh-cn.php'); - $result .= ((strpos($link, 'newzh_cn') === false || strpos($link, 'extendOther') === false) ? 0 : 1) . ','; - - $configPath = $modulePath . 'config.php'; - $link = $this->objectModel->addLink4File($configPath, 'config.php'); - $result .= ((strpos($link, 'newConfig') === false || strpos($link, 'extendOther') === false) ? 0 : 1) . ','; - - $edition = $this->objectModel->config->edition; - if($edition == 'open') return $result . '1,1,1,1,1,1'; - - $extensionRoot = $this->objectModel->app->getExtensionRoot(); - $extensionPath = $extensionRoot . $edition . DS . 'todo' . DS . 'ext' . DS; - $extControlPath = $extensionPath . 'control' . DS . 'create.php'; - $link = $this->objectModel->addLink4File($extControlPath, 'create.php'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1) . ','; - - $extModelPath = $extensionPath . 'model' . DS . 'zentaobiz.class.php'; - $link = $this->objectModel->addLink4File($extModelPath, 'zentaobiz.class.php'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1) . ','; - - $extJSPath = $extensionPath . 'js' . DS . 'create' . DS . 'zentaobiz.js'; - $link = $this->objectModel->addLink4File($extJSPath, 'zentaobiz.js'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1) . ','; - - $extCSSPath = $extensionPath . 'css' . DS . 'create' . DS . 'zentaobiz.css'; - $link = $this->objectModel->addLink4File($extCSSPath, 'zentaobiz.css'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1) . ','; - - $extLangPath = $extensionPath . 'lang' . DS . 'zh-cn' . DS . 'zentaobiz.php'; - $link = $this->objectModel->addLink4File($extLangPath, 'zentaobiz.php'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1) . ','; - - $extConfigPath = $extensionPath . 'config' . DS . 'zentaobiz.php'; - $link = $this->objectModel->addLink4File($extConfigPath, 'zentaobiz.php'); - $result .= ((strpos($link, 'delete') === false || strpos($link, 'edit') === false) ? 0 : 1); - return $result; - } - - /** - * Test for get extend link. - * - * @access public - * @return 1|0 - */ - public function getExtendLinkTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $viewPath = $modulePath . 'view' . DS . 'create.html.php'; - $link = $this->objectModel->getExtendLink($viewPath, 'extendOther'); - return (strpos($link, 'edit') !== false && strpos($link, 'extendOther') !== false) ? 1 : 0; - } - - /** - * Test for get api link. - * - * @access public - * @return 1|0 - */ - public function getAPILinkTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $modelPath = $modulePath . 'model.php' . DS . 'create'; - $link = $this->objectModel->getAPILink($modelPath, 'extendModel'); - return (strpos($link, 'debug') !== false && strpos($link, 'extendModel') !== false) ? 1 : 0; - } - - /** - * Test for extend model. - * - * @access public - * @return 1|0 - */ - public function extendModelTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $modelPath = $modulePath . 'model.php' . DS . 'create'; - $content = $this->objectModel->extendModel($modelPath); - return strpos($content, 'public function create(') === false ? 0 : 1; - } - - /** - * Test for extend control. - * - * @access public - * @return string - */ - public function extendControlTest() - { - $result = ''; - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $filePath = $modulePath . 'control.php' . DS . 'create'; - $content = $this->objectModel->extendControl($filePath, 'yes'); - $result .= strpos($content, 'class mytodo extends todo') !== false ? '1,' : '0,'; - - $content = $this->objectModel->extendControl($filePath, 'no'); - $result .= strpos($content, 'class todo extends control') !== false ? 1 : 0; - return $result; - } - - /** - * Test for new control. - * - * @access public - * @return 1|0 - */ - public function newControlTest() - { - $filePath = $this->objectModel->app->getModulePath('', 'todo') . 'control.php' . DS . 'create'; - $content = $this->objectModel->newControl($filePath); - return (strpos($content, 'class todo extends control') !== false && strpos($content, 'public function create(') !== false) ? 1 : 0; - } - - /** - * Test for get param. - * - * @access public - * @return 1|0 - */ - public function getParamTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo') . 'control.php'; - include $modulePath; - $params = $this->objectModel->getParam('todo', 'create'); - return $params == "\$date='today', \$userID='', \$from='todo'" ? 1 : 0; - } - - /** - * Test for get method code. - * - * @access public - * @return 1|0 - */ - public function getMethodCodeTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo') . 'control.php'; - include $modulePath; - $code = $this->objectModel->getMethodCode('todo', 'create'); - return strpos($code, "public function create(\$date = 'today', \$userID = '', \$from = 'todo')") !== false ? 1 : 0; - } - - /** - * Test for get save path. - * - * @access public - * @return string - */ - public function getSavePathTest() - { - $_POST['fileName'] = 'test.php'; - $result = ''; - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $extPath = $this->objectModel->app->getExtensionRoot() . 'custom' . DS; - - $filePath = $modulePath . 'model.php' . DS . 'create'; - $path = $this->objectModel->getSavePath($filePath, 'extendModel'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'model' . DS . 'test.php' ? '1,' : '0,'; - - $filePath = $modulePath . 'control.php' . DS . 'create'; - $path = $this->objectModel->getSavePath($filePath, 'extendControl'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'control' . DS . 'create.php' ? '1,' : '0,'; - - $filePath = $modulePath . 'view' . DS . 'create.html.php'; - $path = $this->objectModel->getSavePath($filePath, 'override'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'view' . DS . 'create.html.php' ? '1,' : '0,'; - - $filePath = $modulePath . 'config.php'; - $path = $this->objectModel->getSavePath($filePath, 'extendOther'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'config' . DS . 'test.php' ? '1,' : '0,'; - - $filePath = $modulePath . 'lang' . DS . 'zh-cn.php'; - $path = $this->objectModel->getSavePath($filePath, 'extendOther'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'lang' . DS . 'zh-cn' . DS . 'test.php' ? '1,' : '0,'; - - $_POST['fileName'] = 'create.html.hook.php'; - $filePath = $modulePath . 'view' . DS . 'create.html.php'; - $path = $this->objectModel->getSavePath($filePath, 'newhook'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'view' . DS . 'create.html.hook.php' ? '1,' : '0,'; - - $_POST['fileName'] = 'test.php'; - $filePath = $modulePath . 'control.php'; - $path = $this->objectModel->getSavePath($filePath, 'newmethod'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'control' . DS . 'test.php' ? '1,' : '0,'; - - $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'control'; - $path = $this->objectModel->getSavePath($filePath, 'newextend'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'control' . DS . 'test.php' ? '1,' : '0,'; - - $filePath = $modulePath . 'config.php'; - $path = $this->objectModel->getSavePath($filePath, 'newconfig'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'config' . DS . 'test.php' ? '1,' : '0,'; - - $_POST['fileName'] = 'test.js'; - $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'js' . DS . 'create' . DS; - $path = $this->objectModel->getSavePath($filePath, 'newJS'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'js' . DS . 'create' . DS . 'test.js' ? '1,' : '0,'; - - $_POST['fileName'] = 'test.css'; - $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'css' . DS . 'create' . DS; - $path = $this->objectModel->getSavePath($filePath, 'newCSS'); - $result .= $path == $extPath . 'todo' . DS . 'ext' . DS . 'css' . DS . 'create' . DS . 'test.css' ? '1' : '0'; - - return $result; - } - - /** - * Test for get class name by path. - * - * @access public - * @return string - */ - public function getClassNameByPathTest() - { - $modulePath = $this->objectModel->app->getModulePath('', 'todo'); - $extPath = $this->objectModel->app->getExtensionRoot() . 'custom' . DS; - - $result = ''; - $filePath = $modulePath . 'model.php' . DS . 'create'; - $className = $this->objectModel->getClassNameByPath($filePath); - $result .= $className == 'todo' ? '1,' : '0,'; - $filePath = $extPath . 'todo' . DS . 'ext' . DS . 'control'; - $className = $this->objectModel->getClassNameByPath($filePath); - $result .= $className == 'todo' ? '1' : '0'; - return $result; - } -} diff --git a/test/class/entry.class.php b/test/class/entry.class.php deleted file mode 100644 index 9d7c4b1266..0000000000 --- a/test/class/entry.class.php +++ /dev/null @@ -1,192 +0,0 @@ -objectModel = $tester->loadModel('entry'); - } - - /** - * Test get entry by id. - * - * @param int $entryID - * @access public - * @return object - */ - public function getByIdTest($entryID) - { - $object = $this->objectModel->getById($entryID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get entry by code. - * - * @param int $code - * @access public - * @return object - */ - public function getByCodeTest($code) - { - $object = $this->objectModel->getByCode($code); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get entry by key. - * - * @param int $key - * @access public - * @return object - */ - public function getByKeyTest($key) - { - $object = $this->objectModel->getByKey($key); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Get list test. - * - * @param string $orderBy - * @param int $pager - * @access public - * @return object - */ - public function getListTest($orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get logs test. - * - * @param int $id - * @param string $orderBy - * @param int $pager - * @access public - * @return object - */ - public function getLogsTest($id, $orderBy = 'date_desc', $pager = null) - { - $object = $this->objectModel->getLogs($id, $orderBy, $paper); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test create a object. - * - * @param array $params - * @access public - * @return object - */ - public function createObject($params = array()) - { - $createFields = array(); - $createFields['name'] = '这是应用名称'; - $createFields['code'] = 'code'; - $createFields['account'] = 'admin'; - $createFields['key'] = md5(time()); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($params as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($objectID); - return $object; - } - - /** - * Test update a entry. - * - * @param int $entryID - * @param int $params - * @access public - * @return object - */ - public function updateObject($entryID, $params) - { - global $tester; - - $object = $tester->dbh->query("SELECT * FROM " . TABLE_ENTRY ." WHERE id = $entryID")->fetch(); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($params))) - { - $_POST[$field] = $params[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $this->objectModel->update($entryID); - if($change == array()) $change = '没有数据更新'; - unset($_POST); - - if(dao::isError()) return dao::getError(); - return $change; - } - - /** - * Test update calledTime. - * - * @param int $code - * @param int $time - * @access public - * @return object - */ - public function updateCalledTimeTest($code, $time) - { - $this->objectModel->updateCalledTime($code, $time); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByCode($code); - return $object; - } - - /** - * Test save a log. - * - * @param int $entryID - * @param int $url - * @access public - * @return object - */ - public function saveLogTest($entryID, $url) - { - $this->objectModel->saveLog($entryID, $url); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_LOG ." WHERE objectID = $entryID AND objectType = 'entry'")->fetch(); - return $object; - } - -} diff --git a/test/class/execution.class.php b/test/class/execution.class.php deleted file mode 100644 index 5c79afdd64..0000000000 --- a/test/class/execution.class.php +++ /dev/null @@ -1,2982 +0,0 @@ -executionModel = $tester->loadModel('execution'); - $this->treeModel = $tester->loadModel('tree'); - $this->productModel = $tester->loadModel('product'); - } - - /** - * Compute cfd of a execution. - * - * @param int|string|array $executionID - * @access public - * @return array - */ - public function computeCFDTest($executionID = 0) - { - $this->executionModel->computeCFD($executionID); - - $today = helper::today(); - return $this->executionModel->dao->select('*')->from(TABLE_CFD) - ->where('date')->eq($today) - ->beginIF(!empty($executionID))->andWhere('execution')->in($executionID)->fi() - ->fetchAll('id'); - } - - /** - * Get no multiple execution id. - * - * @param int $projectID - * @access public - * @return int - */ - public function getNoMultipleIDTest($projectID) - { - return $this->executionModel->getNoMultipleID($projectID); - } - - /** - * Check begin and end date. - * - * @param int $projectID - * @param string $begin - * @param string $end - * @access public - * @return bool|array - */ - public function checkBeginAndEndDateTest($projectID, $begin, $end) - { - $this->executionModel->checkBeginAndEndDate($projectID, $begin, $end); - - if(dao::isError()) return dao::getError(); - return true; - } - - /** - * Check the workload format and total. - * - * @param string $executionID - * @param string $type - * @param int $percent - * @access public - * @return object - */ - public function checkWorkloadTest($executionID, $type = '', $percent = 0) - { - global $tester; - $tester->loadModel('programplan'); - - $_POST['percent'] = $percent; - $oldExecution = empty($executionID) ? '' : $this->executionModel->getByID($executionID); - $this->executionModel->checkWorkload($type, $percent, $oldExecution); - unset($_POST); - - if(dao::isError()) return dao::getError(); - return true; - } - - /** - * Set Kanban. - * - * @param int $executionID - * @param array $param - * @access public - * @return object - */ - public function setKanbanTest($executionID, $param = array()) - { - global $tester; - $tester->loadModel('kanban'); - - $object = $tester->dbh->query("SELECT `displayCards`,`fluidBoard`,`colWidth`,`minColWidth`,`maxColWidth` FROM zt_project WHERE id = $executionID ")->fetch(); - - $_POST['heightType'] = 'auto'; - foreach($object as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->executionModel->setKanban($executionID); - $execution = $this->executionModel->getByID($executionID); - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $execution; - } - } - - /** - * Set project into session. - * - * @param int $executionID - * @access public - * @return int - */ - public function setProjectSessionTest($executionID) - { - unset($_SESSION['project']); - $this->executionModel->setProjectSession($executionID); - return empty($_SESSION['project']) ? 0 : $_SESSION['project']; - } - - /** - * Test save state. - * - * @param int $executionID - * @param array $executions - * @access public - * @return array - */ - public function saveStateTest($executionID = 0, $executions = array()) - { - return $this->executionModel->saveState($executionID, $executions); - } - - /** - * Create the select code of executions. - * - * @param int $executionID - * @param string $currentModule - * @param string $currentMethod - * @access public - * @return void - */ - public function selectTest($executionID, $currentModule, $currentMethod) - { - $executions = $this->executionModel->getPairs(); - return $this->executionModel->select($executions, $executionID, 0, $currentModule, $currentMethod); - } - - /** - * Check the privilege. - * - * @param mixed $executionID - * @access public - * @return bool - */ - public function checkPrivTest($executionID) - { - return $this->executionModel->checkPriv($executionID); - } - - /** - * get todate - * - * @access public - * @return string - */ - public function getHour() - { - return date('Y-m-d'); - } - - /** - * get Reduce date - * - * @param string $dayNum - * @access public - * @return string - */ - public function getReduceHour($dayNum) - { - return date('Y-m-d',strtotime("-$dayNum day")); - } - - /** - * function create test by execution - * - * @param array $param - * @param string $project - * @param string $dayNum - * @param string $days - * @access public - * @return array - */ - public function createTest($param = array(), $project = '', $dayNum = '', $days = '') - { - $products = array(''); - $plans = array(''); - $whitelist = array(''); - $beginData = date('Y-m-d'); - $endData = date('Y-m-d',strtotime("+$dayNum day")); - $delta = intval($dayNum) + 1; - - $createFields = array('project' => $project, 'name' => '', 'code' => '', 'begin' => $beginData, 'end' => $endData, - 'lifetime' => 'short', 'status' => 'wait', 'products' => $products, 'delta' => $delta, 'days' => $days, - 'plans' => $plans, 'team' => '', 'teams' => '0', 'PO' => '', 'QD' => '', 'PM' => '', 'RD' => '', 'whitelist' => '', - 'desc' => '', 'acl' => 'private', 'percent' => '0'); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->executionModel->create(); - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->executionModel->getByID($objectID); - return $object; - } - } - - /** - * function update test by execution - * - * @param string $objectID - * @param array $param - * @access public - * @return array - */ - public function updateObject($objectID, $param = array()) - { - global $tester; - - $products = array('1','81','91'); - $object = $tester->dbh->query("SELECT `project`,`name`,`code`,`begin`,`end`,`days`,`lifetime`,`team`,`status`,`PO`,`QD`,`PM`, - `RD`,`desc`,`acl` FROM zt_project WHERE id = $objectID ")->fetch(); - $object->products = $products; - - foreach($object as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $change = $this->executionModel->update($objectID); - - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } - } - - /** - * function batchUpdate test by execution - * - * @param array $param - * @param string $executionID - * @access public - * @return array - */ - public function batchUpdateObject($param = array(), $executionID = '') - { - $executionIDList = array($executionID => $executionID); - $codes = array($executionID => ''); - $name = array($executionID => ''); - $pms = array($executionID => ''); - $pos = array($executionID => ''); - $qds = array($executionID => ''); - $rds = array($executionID => ''); - $lifetimes = array($executionID => ''); - $statuses = array($executionID => ''); - $begins = array($executionID => date('Y-m-d')); - $ends = array($executionID => date('Y-m-d',strtotime("+5 day"))); - $descs = array($executionID => ''); - $teams = array($executionID => ''); - $dayses = array($executionID => ''); - - $createFields = array('executionIDList' => $executionIDList, 'names' => $name, 'codes' => $codes, 'PMs' => $pms, 'lifetimes' => $lifetimes, - 'begins' => $begins, 'ends' => $ends, 'descs' => $descs, 'statuses' => $statuses, 'teams' => $teams, 'dayses' => $dayses,'POs' => $pos, - 'QDs' => $qds, 'RDs' => $rds); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->executionModel->batchUpdate(); - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $object[$executionID]; - return $object; - } - } - - /** - * function batchChangeStatus test by execution - * - * @param array $executionIdList - * @param string $status - * @access public - * @return array - */ - public function batchChangeStatusObject($executionIdList = '', $status = '') - { - $result = $this->executionModel->batchChangeStatus($executionIdList, $status); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return empty($result) ? 'empty' : $result; - } - } - - /** - * function changeStatus2Wait test by execution - * - * @param int $executionID - * @access public - * @return string|array - */ - public function changeStatus2WaitObject($executionID) - { - global $tester; - - $tester->loadModel('programplan'); - $selfAndChildrenList = $tester->programplan->getSelfAndChildrenList($executionID); - $siblingStages = $tester->programplan->getSiblings($executionID); - - $selfAndChildren = $selfAndChildrenList[$executionID]; - $execution = $selfAndChildren[$executionID]; - $executionType = $execution->type; - - $siblingList = array(); - if($executionType == 'stage') $siblingList = $siblingStages[$executionID]; - - $result = $this->executionModel->changeStatus2Wait($executionID, $selfAndChildren, $siblingList); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return (empty($result) or $result == "'',") ? 'empty' : $result; - } - } - - /** - * function changeStatus2Doing test by execution - * - * @param int $executionID - * @access public - * @return bool|array - */ - public function changeStatus2DoingObject($executionID) - { - global $tester; - - $tester->loadModel('programplan'); - $selfAndChildrenList = $tester->programplan->getSelfAndChildrenList($executionID); - - $selfAndChildren = $selfAndChildrenList[$executionID]; - $execution = $selfAndChildren[$executionID]; - $executionType = $execution->type; - - $this->executionModel->changeStatus2Doing($executionID, $selfAndChildren); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return true; - } - } - - /** - * function changeStatus2Inactived test by execution - * - * @param int $executionID - * @param string $status suspended|closed - * @access public - * @return bool|array - */ - public function changeStatus2InactivedObject($executionID, $status) - { - global $tester; - - $tester->loadModel('programplan'); - $selfAndChildrenList = $tester->programplan->getSelfAndChildrenList($executionID); - $siblingStages = $tester->programplan->getSiblings($executionID); - - $selfAndChildren = $selfAndChildrenList[$executionID]; - $execution = $selfAndChildren[$executionID]; - $executionType = $execution->type; - - $siblingList = array(); - if($executionType == 'stage') $siblingList = $siblingStages[$executionID]; - - $result = $this->executionModel->changeStatus2Inactived($executionID, $status, $selfAndChildren, $siblingList); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return (empty($result) or $result == "'',") ? 'empty' : $result; - } - } - - /** - * function start test by execution - * - * @param string $executionID - * @param array $param - * @param bool $testParent - * @access public - * @return array - */ - public function startTest($executionID,$param = array(), $testParent = false) - { - $data = date('Y-m-d'); - - $createFields = array( 'comment' => '开始描述测试', 'realBegan' => $data); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $obj = $this->executionModel->start($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - if ($error[0] = "此任务已被启动,不能重复启动!") - { - return $error[0]; - } - else - { - return $error; - } - } - else - { - if($testParent) - { - $execution = $this->executionModel->getByID($executionID); - $executionParent = $this->executionModel->getByID($execution->parent); - return $executionParent; - } - return $obj; - } - } - - /** - * function putoff test by execution - * - * @param string $executionID - * @param array $param - * @access public - * @return array - */ - public function putoffTest($executionID, $param = array()) - { - $begin = date('Y-m-d'); - $end = date('Y-m-d',strtotime("+5 day")); - - $createFields = array('status' => 'wait', 'days' => '5', 'comment' => '延期描述测试', 'begin' => $begin, 'end' => $end); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $obj = $this->executionModel->putoff($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $obj; - } - } - - /** - * function suspend test by execution - * - * @param string $executionID - * @param array $param - * @access public - * @return array - */ - public function suspendTest($executionID, $param = array()) - { - $createFields = array('status' => 'suspended', 'comment' => '挂起描述测试'); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $obj = $this->executionModel->suspend($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $obj; - } - } - - /** - * function activate test by execution - * - * @param string $executionID - * @param array $param - * @param bool $testParent - * @access public - * @return array - */ - public function activateTest($executionID, $param = array(), $testParent = false) - { - self::suspendTest($executionID); - - $begin = date('Y-m-d'); - $end = date('Y-m-d',strtotime("+5 day")); - - $createFields = array('status' => 'doing', 'comment' => '激活描述测试', 'begin' => $begin, 'end' => $end); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $obj = $this->executionModel->activate($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - if($testParent) - { - $execution = $this->executionModel->getByID($executionID); - $executionParent = $this->executionModel->getByID($execution->parent); - return $executionParent; - } - return $obj; - } - } - - /** - * function close test by execution - * - * @param string $executionID - * @param array $param - * @param bool $testParent - * @access public - * @return array - */ - public function closeTest($executionID, $param = array(), $testParent = false) - { - $todate = date('Y-m-d'); - - $createFields = array('status' => 'closed', 'comment' => '关闭描述测试', 'realEnd' => $todate); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $obj = $this->executionModel->close($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - if($testParent) - { - $execution = $this->executionModel->getByID($executionID); - $executionParent = $this->executionModel->getByID($execution->parent); - return $executionParent; - } - return $obj; - } - } - - /** - * function getPairs test by execution - * - * @param string $projectID - * @param string $count - * @access public - * @return array - */ - public function getPairsTest($projectID, $count) - { - $object = $this->executionModel->getPairs($projectID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getByID test by execution - * - * @param string $executionID - * @access public - * @return array - */ - public function getByIDTest($executionID) - { - $object = $this->executionModel->getByID($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $object; - } - } - - /** - * function getByIdList test by execution - * - * @param array $executionIdList - * @access public - * @return array - */ - public function getByIdListTest($executionIdList) - { - $object = $this->executionModel->getByIdList($executionIdList); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $object; - } - } - - /** - * function getList test by execution - * - * @param string $projectID - * @param string $type - * @param array $status - * @param string $limit - * @param string $productID - * @param string $count - * @access public - * @return array - */ - public function getListTest($projectID, $type, $status, $limit, $productID, $count) - { - $object = $this->executionModel->getList($projectID, $type, $status, $limit, $productID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * fnction getInvolvedExecutionList test by execution - * - * @param string $projectID - * @param string $limit - * @param string $productID - * @param string $count - * @access public - * @return array - */ - public function getInvolvedExecutionListTest($projectID, $limit, $productID, $count) - { - $object = $this->executionModel->getInvolvedExecutionList($projectID,$status = 'involved',$limit, $productID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getByProject test by execution - * - * @param string $projectID - * @param array $status - * @param string $limit - * @param string $count - * @access public - * @return array - */ - public function getByProjectTest($projectID, $status, $limit, $count) - { - $object = $this->executionModel->getByProject($projectID, $status, $limit); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getIdList test execution - * - * @param string $projectID - * @param string $count - * @access public - * @return array - */ - public function getIdListTest($projectID, $count) - { - $object = $this->executionModel->getIdList($projectID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * Get execution stat data. - * - * @param int $projectID - * @param string $browseType - * @param int $productID - * @param int $branch - * @param bool $withTasks - * @param string $param - * @param string $orderBy - * @param object $pager - * @access public - * @return int - */ - public function getStatDataTest($projectID = 0, $browseType = 'undone', $productID = 0, $branch = 0, $withTasks = false, $param = '', $orderBy = 'id_asc', $pager = null) - { - $objects = $this->executionModel->getStatData($projectID); - return count($objects); - } - - /** - * function getBranches test execution - * - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getBranchesTest($executionID, $count) - { - $object = $this->executionModel->getBranches($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getTree test execution - * - * @param string $executionID - * @access public - * @return array - */ - public function getTreeTest($executionID) - { - global $app; - $app->moduleName = 'task'; - $object = $this->executionModel->getTree($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object[0] ? count($object[0]->children) : 0; - } - } - - /** - * function getRelatedExecutions test execution - * - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getRelatedExecutionsTest($executionID, $count) - { - $object = $this->executionModel->getRelatedExecutions($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getChildExecutions test execution - * - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getChildExecutionsTest($executionID, $count) - { - $object = $this->executionModel->getChildExecutions($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * Check the privilege. - * - * @access public - * @return string|bool - */ - public function getLimitedExecutionTest() - { - $this->executionModel->getProductGroupList(); - return isset($_SESSION['limitedExecutions']) ? $_SESSION['limitedExecutions'] : true; - } - - /** - * function getProductGroupList test execution - * - * @param string $count - * @access public - * @return array - */ - public function getProductGroupListTest($count) - { - $object = $this->executionModel->getProductGroupList(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object[""]; - } - } - - /** - * function getTasks test by execution - * - * @param string $productID - * @param string $executionID - * @param string $browseType - * @param string $queryID - * @param string $moduleID - * @param string $sort - * @param string $count - * @access public - * @return array - */ - public function getTasksTest($productID, $executionID, $browseType, $queryID, $moduleID, $sort, $count) - { - global $tester; - - $execution = $tester->dbh->query("select * from zt_project where id = $executionID")->fetch(); - $executions = array($executionID => $execution->name); - $page = 'NULL'; - - $object = $this->executionModel->getTasks($productID, $executionID, $executions, $browseType, $queryID, $moduleID, $sort, $page); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * Get the task data group by execution id list. - * - * @param array $executionIdList - * @access public - * @return int - */ - public function getTaskGroupByExecutionTest($executionIdList = array()) - { - $objects = $this->executionModel->getTaskGroupByExecution($executionIdList); - return count($objects); - } - - /** - * function getDefaultManagers test by execution - * - * @param string $executionID - * @access public - * @return array - */ - public function getDefaultManagersTest($executionID) - { - $object = $this->executionModel->getDefaultManagers($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function getBranchByProduct test by execution - * - * @param string $productID - * @param string $count - * @access public - * @return array - */ - public function getBranchByProductTest($productID, $count) - { - $object = $this->executionModel->getBranchByProduct($productID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return isset($object[$productID]) ? count($object[$productID]) : 0; - } - else - { - return $object; - } - } - - /** - * function getOrderedExecutions test exection - * - * @param string $projectID - * @param string $status - * @param string $count - * @access public - * @return array - */ - public function getOrderedExecutionsTest($projectID, $status, $count) - { - $object = $this->executionModel->getOrderedExecutions($projectID,$status); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getToImport test execution - * - * @param string $executionIds - * @param string $type - * @param string $count - * @access public - * @return array - */ - public function getToImportTest($executionIds, $type, $count) - { - $object = $this->executionModel->getToImport($executionIds, $type); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function updateProducts test by execution - * - * @param string $executionID - * @param array $param - * @access public - * @return array - */ - public function updateProductsTest($executionID,$param = array()) - { - global $tester; - - $products = array(); - $branch = array(); - - $createFields = array('products' => $products, 'branch' => $branch, 'post' => 'post'); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->executionModel->updateProducts($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - - $productList = $tester->dbh->query("select * from zt_projectproduct where project = $executionID")->fetchAll(); - return $productList; - } - } - - /** - * function getTasks2Imported test by execution - * - * @param string $toExecution - * @param string $count - * @access public - * @return array - */ - public function getTasks2ImportedTest($toExecution, $count) - { - $branches = $this->executionModel->getBranches($toExecution); - - $object = $this->executionModel->getTasks2Imported($toExecution, $branches); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object[$toExecution]); - } - else - { - return $object[$toExecution]; - } - } - - /** - * function importTask test by execution - * - * @param string $executionID - * @param string $count - * @param array $param - * @access public - * @return array - */ - public function importTaskTest($executionID, $count, $param = array()) - { - global $tester; - - $tasks = array(); - $createFields = array('tasks' => $tasks); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->executionModel->importTask($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - $taskList = $tester->dbh->query("select * from zt_task where execution = $executionID")->fetchAll(); - return count($taskList); - } - else - { - $taskList = $tester->dbh->query("select * from zt_task where execution = $executionID")->fetchAll(); - return $taskList; - } - } - - /** - * function statRelatedData test by execution - * - * @param string $executionID - * @access public - * @return array - */ - public function statRelatedDataTest($executionID) - { - $object = $this->executionModel->statRelatedData($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function importBug test by execution - * - * @param string $executionID - * @param string $count - * @param array $param - * @access public - * @return array - */ - public function importBugTest($executionID, $count, $param = array()) - { - $import = array(); - $id = array(); - $pri = array(); - $assignedTo = array(); - $estimate = array(); - $deadline = array(); - - $createFields = array('import' => $import, 'id' => $id, 'pri' => $pri, 'assignedTo' => $assignedTo, - 'estimate' => $estimate, 'deadline' => $deadline); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->executionModel->importBug($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function updateChilds test by execution - * - * @param string $executionID - * @param string $count - * @param array $param - * @access public - * @return array - */ - public function updateChildsTest($executionID, $count, $param = array()) - { - global $tester; - - $childs = array(); - $createFields = array('childs' => $childs); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->executionModel->updateChilds($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - $childExecutions = $tester->dbh->query("select id,name,type from zt_project where parent = $executionID")->fetchAll(); - return count($childExecutions); - } - else - { - $childExecutions = $tester->dbh->query("select id,name,type from zt_project where parent = $executionID")->fetchAll(); - return $childExecutions; - } - } - - /** - * function changeProject test by execution - * - * @param string $newProject - * @param string $oldProject - * @param string $executionID - * @param array $syncStories - * @access public - * @return array - */ - public function changeProjectTest($newProject, $oldProject, $executionID, $syncStories = 'no') - { - global $tester; - - $this->executionModel->changeProject($newProject, $oldProject, $executionID, $syncStories); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - $newExecution = $tester->dbh->query("select parent,path from zt_project where id = $executionID")->fetchAll(); - return $newExecution; - } - } - - /** - * function linkStory test by execution - * - * @param string $executionID - * @param string $count - * @param array $param - * @access public - * @return array - */ - public function linkStoryTest($executionID, $count, $param = array()) - { - global $tester; - - $stories = array(); - $products = array(); - - $createFields = array('stories' => $stories, 'products' => $products); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $tester->dbh->query("delete from zt_projectstory where project = $executionID"); - - $this->executionModel->linkStory($executionID); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - $object = $tester->dbh->query("select * from zt_projectstory where project = $executionID")->fetchAll(); - return count($object); - } - else - { - $object = $tester->dbh->query("select * from zt_projectstory where project = $executionID")->fetchAll(); - return $object; - } - } - - /** - * Link all stories by execution. - * - * @param int $executionID - * @param int $productID - * @param int $planID - * @access public - * @return int - */ - public function linkStoriesTest($executionID, $productID = 0, $planID = 0) - { - global $tester; - if($planID) $tester->dao->update(TABLE_PROJECTPRODUCT)->set('plan')->eq($planID)->where('project')->eq($executionID)->andWhere('product')->eq($productID)->exec(); - - $this->executionModel->linkStories($executionID); - $objects = $tester->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($executionID)->andWhere('product')->eq($productID)->fetchAll(); - return count($objects); - } - - /** - * function linkCases test by execution - * - * @param string $executionID - * @param string $count - * @param string $productID - * @param string $storyID - * @access public - * @return array - */ - public function linkCasesTest($executionID, $count, $productID, $storyID) - { - global $tester; - - $tester->dbh->query("delete from zt_projectcase where project = $executionID"); - - $this->executionModel->linkCases($executionID, $productID, $storyID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - $object = $tester->dbh->query("select * from zt_projectcase where project = $executionID")->fetchAll(); - return count($object); - } - else - { - $object = $tester->dbh->query("select * from zt_projectcase where project = $executionID")->fetchAll(); - return $object; - } - } - - /** - * function unlinkStory test by execution - * - * @param string $executionID - * @param string $count - * @param string $storyID - * @param array $param - * @access public - * @return array - */ - public function unlinkStoryTest($executionID, $count, $storyID, $param = array()) - { - global $tester; - - $stories = array(); - $products = array(); - - $createFields = array('stories' => $stories, 'products' => $products); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $tester->dbh->query("delete from zt_projectstory where project = $executionID"); - - $this->executionModel->linkStory($executionID); - - unset($_POST); - - $this->executionModel->unlinkStory($executionID, $storyID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - $object = $tester->dbh->query("select * from zt_projectstory where project = $executionID")->fetchAll(); - return count($object); - } - else - { - $object = $tester->dbh->query("select * from zt_projectstory where project = $executionID")->fetchAll(); - if(isset($object)) - { - return $object; - } - else - { - return "全部需求已解除"; - } - } - } - - /** - * function unlinkCases test by execution - * - * @param string $executionID - * @param string $productID - * @param string $storyID - * @access public - * @return array - */ - public function unlinkCasesTest($executionID, $productID, $storyID) - { - global $tester; - - $tester->dbh->query("delete from zt_projectcase where project = $executionID"); - - $this->executionModel->linkCases($executionID, $productID, $storyID); - $this->executionModel->unlinkCases($executionID, $storyID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - $object = $tester->dbh->query("select * from zt_projectcase where project = $executionID")->fetchAll(); - return $object; - } - } - - /** - * function getTeamMembers test by execution - * - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getTeamMembersTest($executionID, $count) - { - $object = $this->executionModel->getTeamMembers($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getMembersByIdList test by execution - * - * @param array $executionIdList - * @param string $count - * @access public - * @return array - */ - public function getMembersByIdListTest($executionIdList, $count) - { - $object = $this->executionModel->getMembersByIdList($executionIdList); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getTeams2Import test by execution - * - * @param string $account - * @param string $currentExecution - * @param string $count - * @access public - * @return array - */ - public function getTeams2ImportTest($account, $currentExecution, $count) - { - $object = $this->executionModel->getTeams2Import($account, $currentExecution); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - if(empty($object)) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * function getMembers2Import test by execution - * - * @param string $execution - * @param array $currentMembers - * @param string $count - * @access public - * @return array - */ - public function getMembers2ImportTest($execution, $currentMembers, $count) - { - $object = $this->executionModel->getMembers2Import($execution, $currentMembers); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - if(empty($object)) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * function getCanCopyObjects test by execution - * - * @param int $projectID - * @param string $count - * @access public - * @return array - */ - public function getCanCopyObjectsTest($projectID = 0, $count = 0) - { - $object = $this->executionModel->getCanCopyObjects($projectID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - if(empty($object)) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * function manageMembers test by execution - * - * @param string $executionID - * @param string $count - * @param array $param - * @access public - * @return array - */ - public function manageMembersTest($executionID, $count, $param = array()) - { - global $tester; - $tester->dbh->query("delete from zt_team where root = $executionID"); - - $realnames = array(); - $roles = array(); - $days = array(); - $hours = array(); - $accounts = array(); - $limited = array(); - - $createFields = array('realnames' => $realnames, 'roles' => $roles, 'hours' => $hours, 'accounts' => $accounts, - 'limited' => $limited, 'days' => $days); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $object = $this->executionModel->manageMembers($executionID); - - unset($_POST); - - $object = $tester->dbh->query("select * from zt_team where root = $executionID")->fetchAll(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - if(empty($object)) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * function addProjectMembers test by execution - * - * @param int $projectID - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function addProjectMembersTest($projectID = 0, $executionID = 0, $count = 0) - { - global $tester; - $tester->dbh->query("delete from zt_team where root = $projectID"); - $executionMembers = $tester->dao->select('`root`,`account`,`join`,`role`,`days`,`type`,`hours`')->from(TABLE_TEAM)->where('root')->eq($executionID)->fetchAll('account'); - - $this->executionModel->addProjectMembers($projectID, $executionMembers); - - $object = $tester->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($projectID)->fetchAll(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function unlinkMember test by execution - * - * @param string $sprintID - * @param string $account - * @param string $count - * @access public - * @return array - */ - public function unlinkMemberTest($sprintID, $account, $count) - { - global $tester; - $oldObject = $tester->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($sprintID)->fetchAll(); - - $this->executionModel->unlinkMember($sprintID, $account); - - $object = $tester->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($sprintID)->fetchAll(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($oldObject); - } - else - { - return $object; - } - } - - /** - * function computeBurn test by execution - * - * @param string $count - * @access public - * @return array - */ - public function computeBurnTest($count) - { - $object = $this->executionModel->computeBurn(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * Function fixFirst test by execution. - * - * @param string $executionID - * @param array $param - * @param string $date - * @access public - * @return array - */ - public function fixFirstTest($executionID, $param = array(), $date) - { - global $tester; - - $createFields = array('estimate' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->executionModel->computeBurn(); - $this->executionModel->fixFirst($executionID); - - unset($_POST); - - $object = $tester->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($date)->fetchAll(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - if(empty($object)) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * Function getBurnDataFlot test by execution. - * - * @param int $executionID - * @access public - * @return int - */ - public function getBurnDataFlotTest($executionID = 0) - { - $object = $this->executionModel->getBurnDataFlot($executionID, $burnBy = 'left'); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * Function getBurnData test by execution. - * - * @param int $executionID - * @access public - * @return int - */ - public function getBurnDataTest($executionID = 0) - { - $execution = $this->executionModel->getByID($executionID); - if(empty($execution)) return '0'; - - $object = $this->executionModel->getBurnData(array($executionID => $execution)); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function processBurnData test by execution - * - * @param string $executionID - * @param array $itemCounts - * @param string $begin - * @param string $end - * @param string $count - * @access public - * @return array - */ - public function processBurnDataTest($executionID, $itemCounts, $begin, $end, $count) - { - global $tester; - $sets = $tester->dao->select('execution, `date` as name, `left` as value')->from(TABLE_BURN)->where('execution')->eq($executionID)->fetchAll('name'); - - $object = $this->executionModel->processBurnData($sets, $itemCounts, $begin, $end); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == "1") - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function summary test by execution - * - * @param string $executionID - * @access public - * @return array - */ - public function summaryTest($executionID) - { - global $tester; - $execution = $tester->dbh->query("select * from zt_project where id = $executionID")->fetch(); - $executions = array($executionID => $execution->name); - $page = 'NULL'; - $tasks = $this->executionModel->getTasks('0', $executionID, $executions,'all', '0', '0', 'status,id_desc', $page); - - $object = $this->executionModel->summary($tasks); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $object; - } - } - - /** - * function isClickable test by execution - * - * @param string $execution - * @param string $action - * @access public - * @return array - */ - public function isClickableTest($execution, $action) - { - $object = $this->executionModel->isClickable($execution, $action); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - if($object == true) - { - return "检查通过"; - } - else - { - return "检查不通过"; - } - } - } - - /** - * function getDateList test by execution - * - * @param string $begin - * @param string $end - * @param string $type - * @param string $count - * @param int $interval - * @access public - * @return array - */ - public function getDateListTest($begin, $end, $type, $count, $interval = 0) - { - $object = $this->executionModel->getDateList($begin, $end, $type, $interval); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - elseif($count == "1") - { - return count($object[0]); - } - else - { - if(empty($object[0])) - { - return '无数据'; - } - else - { - return $object; - } - } - } - - /** - * function getTotalEstimate test by execution - * - * @param string $executionID - * @access public - * @return array - */ - public function getTotalEstimateTest($executionID) - { - $object = $this->executionModel->getTotalEstimate($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $object; - } - } - - /** - * function fixOrder test by execution - * - * @access public - * @return array - */ - public function fixOrderTest() - { - global $tester; - - $this->executionModel->fixOrder(); - - $object = $tester->dao->select('id,`order`')->from(TABLE_EXECUTION)->fetchAll('id'); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * function getKanbanTasks test by execution - * - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getKanbanTasksTest($executionID, $count) - { - $object = $this->executionModel->getKanbanTasks($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getKanbanSetting test by execution - * - * @param string $count - * @access public - * @return array - */ - public function getKanbanSettingTest($count) - { - $object = $this->executionModel->getKanbanSetting(); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object->colorList); - } - else - { - return $object; - } - } - - /** - * function getKanbanColumns test by execution - * - * @param string $count - * @access public - * @return array - */ - public function getKanbanColumnsTest($count) - { - $kanbanSetting = $this->executionModel->getKanbanSetting(); - $object = $this->executionModel->getKanbanColumns($kanbanSetting); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getKanbanStatusMap test by execution - * - * @param string $count - * @access public - * @return array - */ - public function getKanbanStatusMapTest($count) - { - $kanbanSetting = $this->executionModel->getKanbanSetting(); - $object = $this->executionModel->getKanbanStatusMap($kanbanSetting); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getKanbanStatusList test by execution - * - * @param string $count - * @access public - * @return array - */ - public function getKanbanStatusListTest($count) - { - $kanbanSetting = $this->executionModel->getKanbanSetting(); - $object = $this->executionModel->getKanbanStatusList($kanbanSetting); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getKanbanColorList test by execution - * - * @param string $count - * @access public - * @return array - */ - public function getKanbanColorListTest($count) - { - $kanbanSetting = $this->executionModel->getKanbanSetting(); - $object = $this->executionModel->getKanbanColorList($kanbanSetting); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function buildBurnData test by execution - * - * @param string $executionID - * @param string $count - * @param string $type - * @access public - * @return array - */ - public function buildBurnDataTest($executionID, $count, $type = 'noweek') - { - $begin = '2022-01-07'; - $end = '2022-01-17'; - - $dateList = $this->executionModel->getDateList($begin, $end, $type, 0, $format = 'Y-m-d'); - - $object = $this->executionModel->buildBurnData($executionID, $dateList[0], $type); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getPlans test by execution - * - * @param array $products - * @param string $executionID - * @param string $count - * @access public - * @return array - */ - public function getPlansTest($products, $executionID, $count) - { - $object = $this->executionModel->getPlans($products,'', $executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function getStageLinkProductPairs test by execution - * - * @param array $projects - * @param string $count - * @access public - * @return array - */ - public function getStageLinkProductPairsTest($projects, $count) - { - $object = $this->executionModel->getStageLinkProductPairs($projects); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - elseif($count == 1) - { - return count($object); - } - else - { - return $object; - } - } - - /** - * function setTreePath test by executon - * - * @param string $executionID - * @access public - * @return array - */ - public function setTreePathTest($executionID) - { - global $tester; - - $this->executionModel->setTreePath($executionID); - - $object = $tester->dao->select('id,project,parent,path')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetchAll('id'); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * Test get begin and end for CFD. - * - * @param int $executionID - * @access public - * @return array - */ - public function getBeginEnd4CFDTest($executionID) - { - global $tester; - - $execution = $this->executionModel->getByID($executionID); - $object = $this->executionModel->getBeginEnd4CFD($execution); - - $object[0] = $object[0] == date('Y-m-d', strtotime('-13 days', time())) ? 1 : 0; - $object[1] = $object[1] == helper::today() ? 1 : 0; - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * Test get taskes by search. - * - * @param string $condition - * @param int $recPerPage - * @param string $orderBy - * @access public - * @return array - */ - public function getSearchTasksTest($condition, $recPerPage, $orderBy) - { - global $tester; - - /* Load pager. */ - $tester->app->loadClass('pager', $static = true); - $pager = new pager(0, $recPerPage, 1); - - $objects = $this->executionModel->getSearchTasks($condition, $pager, $orderBy); - - $returns = ''; - foreach($objects as $object) - { - $returns .= "$object->id:name:$object->name"; - if(!empty($object->team)) - { - $returns .= ',team:['; - foreach($object->team as $team) $returns .= "$team->id,"; - $returns = trim($returns, ','); - $returns .= ']'; - } - $returns .= ';'; - } - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $returns; - } - } - - /** - * Test Get bugs by search in execution. - * - * @param array $products - * @param int $executionID - * @param string $sql - * @param object $pager - * @param string $orderBy - * @access public - * @return void - */ - public function getSearchBugsTest($products, $executionID, $sql, $pager = null, $orderBy = 'id_desc') - { - $object = $this->executionModel->getSearchBugs($products, $executionID, $sql, $pager, $orderBy); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return $object; - } - } - - /** - * Test Get kanban group data. - * - * @param array $stories - * @param array $tasks - * @param array $bugs - * @param string $type - * @access public - * @return void - */ - public function getKanbanGroupDataTest($stories, $tasks, $bugs, $type = 'story') - { - $object = $this->executionModel->getKanbanGroupData($stories, $tasks, $bugs, $type); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - if(count((array)$object['closed']) == 0 and count((array)$object['nokey']) == 0) return 'empty'; - return count($object['nokey']->tasks); - } - } - - /** - * Test Get Prev Kanban. - * - * @param int $executionID - * @access public - * @return void - */ - public function getPrevKanbanTest($executionID) - { - $result = $this->executionModel->getPrevKanban($executionID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - return !$result ? 'empty' : $result; - } - } - - /** - * Test save Kanban Data. - * - * @param int $executionID - * @param array $kanbanDatas - * @access public - * @return void - */ - public function saveKanbanDataTest($executionID, $kanbanDatas = '') - { - if($kanbanDatas === '') - { - global $tester; - $contents = array('story', 'wait', 'doing', 'done', 'cancel'); - $stories = $tester->loadModel('story')->getExecutionStories($executionID, 0, 0, 'id_asc'); - $kanbanTasks = $this->executionModel->getKanbanTasks($executionID, "id"); - $kanbanBugs = $tester->loadModel('bug')->getExecutionBugs($executionID); - $users = array(); - $taskAndBugs = array(); - foreach($kanbanTasks as $task) - { - $storyID = $task->storyID; - $status = $task->status; - $users[] = $task->assignedTo; - - $taskAndBugs[$status]["task{$task->id}"] = $task; - } - foreach($kanbanBugs as $bug) - { - $storyID = $bug->story; - $status = $bug->status; - $status = $status == 'active' ? 'wait' : ($status == 'resolved' ? ($bug->resolution == 'postponed' ? 'cancel' : 'done') : $status); - $users[] = $bug->assignedTo; - - $taskAndBugs[$status]["bug{$bug->id}"] = $bug; - } - - $datas = array(); - foreach($contents as $content) - { - if($content != 'story' and !isset($taskAndBugs[$content])) continue; - $datas[$content] = $content == 'story' ? $stories : $taskAndBugs[$content]; - } - $kanbanDatas = $datas; - } - - $object = $this->executionModel->saveKanbanData($executionID, $kanbanDatas); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - $result = $this->executionModel->getPrevKanban($executionID); - return !$result ? 'empty' : $result; - } - } - - /** - * Test Update user view of execution and it's product. - * - * @param int $executionID - * @param string $objectType - * @param array $users - * @access public - * @return void - */ - public function updateUserViewTest($executionID, $objectType = 'sprint', $users = array()) - { - $this->executionModel->updateUserView($executionID, $objectType, $users); - - if(dao::isError()) - { - $error = dao::getError(); - return $error; - } - else - { - if(count($users) > 0) su($users[0]); - - global $tester; - return ",{$tester->app->user->view->sprints},"; - } - } - - /** - * Create default sprint. - * - * @param int $projectID - * @access public - * @return int - */ - public function createDefaultSprintTest($projectID) - { - $result = $this->executionModel->createDefaultSprint($projectID); - - if(dao::isError()) return dao::getError(); - - return $result > 0; - } - - /** - * Test set menu. - * - * @param int $executionID - * @access public - * @return string - */ - public function setMenuTest($executionID = 0) - { - $execution = $this->executionModel->getByID($executionID); - if(empty($execution)) return '0'; - - $this->executionModel->setMenu($executionID); - - global $lang; - return strip_tags($lang->switcherMenu); - } - - /** - * Get switcher. - * - * @param int $executionID - * @param string $method - * @access public - * @return string - */ - public function getSwitcherTest($executionID = 0, $method = '') - { - return $this->executionModel->getSwitcher($executionID, 'execution', $method); - } - - /** - * Test sync no multiple sprint. - * - * @param int $projectID - * @access public - * @return void - */ - public function syncNoMultipleSprintTest($projectID) - { - return $this->executionModel->syncNoMultipleSprint($projectID); - } - - /** - * Test build search form. - * - * @param int $queryID - * @access public - * @return void - */ - public function buildSearchFormTest($queryID) - { - $this->executionModel->buildSearchForm($queryID, 'searchUrl'); - - return $_SESSION['executionsearchParams']['queryID']; - } - - /** - * Test print cell. - * - * @param int $executionID - * @access public - * @return void - */ - public function printCellTest($executionID) - { - $col = new stdClass(); - $col->order = 1; - $col->id = 'id'; - $col->show = 1; - $col->width = 70; - $col->fixed = 'left'; - $col->title = 'ID'; - $col->sort = 'yes'; - $col->name = ''; - - $execution = $this->executionModel->getByID($executionID); - - ob_start(); - $this->executionModel->printCell($col, $execution, array()); - $objects = ob_get_clean(); - - if(dao::isError()) return dao::getError(); - - return strip_tags($objects); - } - - /** - * Test build operate menu. - * - * @param int $executionID - * @access public - * @return string - */ - public function buildOperateMenuTest($executionID = 0) - { - $execution = $this->executionModel->getByID($executionID); - if(empty($execution)) return '0'; - - return $this->executionModel->buildOperateMenu($execution); - } - - /** - * Test print nested list. - * - * @param int $projectID - * @access public - * @return string - */ - public function printNestedListTest($projectID = 0) - { - $executions = $this->executionModel->getStatData($projectID); - - global $app; - $app->moduleName = 'execution'; - ob_start(); - $this->executionModel->printNestedList($executions[0], false, array(), 1); - $result = ob_get_clean(); - return mb_substr(strip_tags($result), 0, 2); - } - - /** - * Test print nested list. - * - * @param int $executionID - * @access public - * @return string - */ - public function printTreeTest($executionID) - { - global $app; - $app->moduleName = 'task'; - $tree = $this->executionModel->getTree($executionID); - return str_replace(' ', '', strip_tags($this->executionModel->printTree($tree, false))); - } - - /** - * Test format tasks for tree. - * - * @param int $executionID - * @access public - * @return string - */ - public function formatTasksForTreeTest($executionID) - { - global $app; - $app->moduleName = 'task'; - $tasks = $this->executionModel->getSearchTasks("execution = $executionID", null, 'id_desc'); - return $this->executionModel->formatTasksForTree($tasks); - } - - /** - * Test fill tasks in tree. - * - * @param int $executionID - * @access public - * @return object - */ - public function fillTasksInTreeTest($executionID) - { - $fullTrees = $this->treeModel->getTaskStructure($executionID, 0); - if(empty($fullTrees)) return '0'; - - return $this->executionModel->fillTasksInTree((object)$fullTrees[0], $executionID); - } - - /** - * Test build task search form. - * - * @param int $executionID - * @param int $queryID - * @access public - * @return int - */ - public function buildTaskSearchFormTest($executionID, $queryID) - { - $this->executionModel->buildTaskSearchForm($executionID, array($executionID => 'yes'), $queryID, 'searchTask'); - - return $_SESSION['tasksearchParams']['queryID']; - } - - /** - * Test build bug search form. - * - * @param int $productID - * @param int $queryID - * @access public - * @return int - */ - public function buildBugSearchFormTest($productID, $queryID) - { - $product = $this->productModel->getByID($productID); - if(empty($product)) return '0'; - - $this->executionModel->loadModel('bug'); - $this->executionModel->buildBugSearchForm(array($productID => $product), $queryID, 'searchBug'); - - return $_SESSION['executionBugsearchParams']['queryID']; - } - - /** - * Test build story search form. - * - * @param int $executionID - * @param int $queryID - * @access public - * @return int - */ - public function buildStorySearchFormTest($executionID, $queryID) - { - $execution = $this->executionModel->getByID($executionID); - if(empty($execution)) return '0'; - - $this->executionModel->loadModel('story'); - $products = $this->productModel->getProducts($executionID); - $branchGroups = $this->executionModel->loadModel('branch')->getByProducts(array_keys($products)); - $this->executionModel->buildStorySearchForm($products, $branchGroups, array(), $queryID, 'searchStory', 'executionStory', $execution); - - return $_SESSION['executionStorysearchParams']['queryID']; - } - - /** - * Test get CFD data. - * - * @param int $executionID - * @access public - * @return array - */ - public function getCFDDataTest($executionID = 0) - { - $begin = strtotime('2022-01-12'); - $end = strtotime('2022-02-12'); - - $dateList = array(); - for($date = $begin; $date <= $end; $date += 24 * 3600) $dateList[] = date('Y-m-d', $date); - - return $this->executionModel->getCFDData($executionID, $dateList); - } - - /** - * Test build CFD data. - * - * @param int $executionID - * @access public - * @return array - */ - public function buildCFDDataTest($executionID = 0) - { - $begin = strtotime('2022-01-12'); - $end = strtotime('2022-02-12'); - - $dateList = array(); - for($date = $begin; $date <= $end; $date += 24 * 3600) $dateList[] = date('Y-m-d', $date); - - return $this->executionModel->buildCFDData($executionID, $dateList, 'task'); - } - - /** - * Test check CFD data. - * - * @param int $executionID - * @param string $date - * @access public - * @return array - */ - public function checkCFDDataTest($executionID, $date) - { - $this->executionModel->checkCFDData($executionID, $date); - return $this->executionModel->dao->select("date, `count` AS value, `name`")->from(TABLE_CFD) - ->where('execution')->eq((int)$executionID) - ->andWhere('date')->eq($date) - ->orderBy('date DESC, id asc')->fetchGroup('name', 'date'); - } - - /** - * Test build execution object by status. - * - * @param string $status - * @access public - * @return object - */ - public function buildExecutionByStatusTest($status) - { - return $this->executionModel->buildExecutionByStatus($status); - } - - /** - * Reset execution sorts. - * - * @param int $projectID - * @param string $type noParent - * @access public - * @return string - */ - public function resetExecutionSortsTest($projectID, $type = '') - { - $executions = array(); - $executionIDList = ''; - $firstGradeExecutions = array(); - if($projectID) - { - $executions = $this->executionModel->dao->select('*')->from(TABLE_EXECUTION) - ->where('deleted')->eq(0) - ->andWhere('project')->eq($projectID) - ->andWhere('type')->in('sprint,stage,kanban') - ->orderBy('order_asc') - ->fetchAll('id'); - - if($type == 'hasParent') - { - foreach($executions as $execution) - { - if($execution->grade == 1) $firstGradeExecutions[$execution->id] = $execution->id; - } - } - } - - $executions = $this->executionModel->resetExecutionSorts($executions, $firstGradeExecutions); - if(!empty($executions)) - { - $executionIDList = array_keys($executions); - $executionIDList = implode(',', $executionIDList); - } - return $executionIDList; - } -} diff --git a/test/class/file.class.php b/test/class/file.class.php deleted file mode 100644 index e69398e11d..0000000000 --- a/test/class/file.class.php +++ /dev/null @@ -1,314 +0,0 @@ -objectModel = $tester->loadModel('file'); - } - - /** - * Test get files of an object. - * - * @param string $objectType - * @param int $objectID - * @param string $extra - * @access public - * @return array - */ - public function getByObjectTest($objectType, $objectID, $extra = '') - { - $objects = $this->objectModel->getByObject($objectType, $objectID, $extra = ''); - foreach($objects as $object) - { - if(isset($object->webPath)) $object->webPath = substr($object->webPath, strpos($object->webPath, '/data/upload')); - } - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get info of a file. - * - * @param int $fileID - * @access public - * @return object - */ - public function getByIdTest($fileID) - { - $object = $this->objectModel->getById($fileID); - if(isset($object->webPath)) $object->webPath = substr($object->webPath, strpos($object->webPath, '/data/upload')); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get counts of uploaded files. - * - * @param array $files - * @param array $labels - * @access public - * @return int - */ - public function getCountTest($files, $labels) - { - $_FILES['files'] = $files; - $_POST['labels'] = $labels; - - $count = $this->objectModel->getCount(); - - unset($_FILES['files']); - unset($_POST['labels']); - - if(dao::isError()) return dao::getError(); - - return $count; - } - - /** - * Test get info of uploaded files. - * - * @param array $files - * @param array $labels - * @access public - * @return array - */ - public function getUploadTest($files, $labels) - { - $_FILES['files'] = $files; - $_POST['labels'] = $labels; - - $objects = $this->objectModel->getUpload($htmlTagName = 'files', $labelsName = 'labels'); - - unset($_FILES['files']); - unset($_POST['labels']); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get uploaded file from zui.uploader. - * - * @param array $image - * @param array $files - * @access public - * @return object - */ - public function getUploadFileTest($image, $files) - { - $_FILES['file'] = $files; - - foreach($image as $key => $value) $_POST[$key] = $value; - - $object = $this->objectModel->getUploadFile($htmlTagName = 'file'); - - unset($_POST); - unset($_FILES['file']); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get extension of a file. - * - * @param string $filename - * @access public - * @return string - */ - public function getExtensionTest($filename) - { - $string = $this->objectModel->getExtension($filename); - - if(dao::isError()) return dao::getError(); - - return $string; - } - - /** - * Test get save name. - * - * @param string $pathName - * @access public - * @return string - */ - public function getSaveNameTest($pathName) - { - $objects = $this->objectModel->getSaveName($pathName); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get real path name. - * - * @param string $pathName - * @access public - * @return string - */ - public function getRealPathNameTest($pathName) - { - $realpath = $this->objectModel->getRealPathName($pathName); - - if(dao::isError()) return dao::getError(); - - return $realpath; - } - - /** - * Test get export tpl. - * - * @param string $module - * @access public - * @return array - */ - public function getExportTemplateTest($module) - { - $objects = $this->objectModel->getExportTemplate($module); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get tmp import path. - * - * @access public - * @return string - */ - public function getPathOfImportedFileTest() - { - $path = $this->objectModel->getPathOfImportedFile(); - $path = substr($path, strpos($path, 'tmp')); - - if(dao::isError()) return dao::getError(); - - return $path; - } - - /** - * Test save export template. - * - * @param string $module - * @access public - * @return object - */ - public function saveExportTemplateTest($module, $file) - { - foreach($file as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->saveExportTemplate($module); - - unset($_POST); - - if(dao::isError()) return dao::getError()['title'][0]; - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_USERTPL)->where('id')->eq($objectID)->fetch(); - return $object; - } - - /** - * Test set save path. - * - * @access public - * @return string - */ - public function setSavePathTest() - { - $this->objectModel->setSavePath(); - - if(dao::isError()) return dao::getError(); - - global $tester; - $path = substr($tester->file->savePath, strpos($tester->file->savePath, '/www/')); - return $path; - } - - /** - * Test set the web path of upload files. - * - * @access public - * @return string - */ - public function setWebPathTest() - { - $this->objectModel->setWebPath(); - - - if(dao::isError()) return dao::getError(); - - global $tester; - $path = substr($tester->file->webPath, strpos($tester->file->webPath, '/test/model/')); - return $path; - } - - /** - * Test compress image. - * - * @param object $file - * @access public - * @return object - */ - public function compressImageTest($file) - { - $object = $this->objectModel->compressImage($file); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test update objectID. - * - * @param int $uid - * @param int $objectID - * @param string $objectType - * @param array $albums - * @access public - * @return array - */ - public function updateObjectIDTest($uid, $objectID, $objectType, $albums) - { - $_SESSION['album'] = $albums; - - $this->objectModel->updateObjectID($uid, $objectID, $objectType); - - unset($_SESSION['album']); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_FILE)->where('id')->in($albums['used'][$uid])->fetchAll('id'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get file pairs. - * - * @param array $IDs - * @param string $value - * @access public - * @return array - */ - public function getPairsTest($IDs, $value = 'title') - { - $objects = $this->objectModel->getPairs($IDs, $value); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/git.class.php b/test/class/git.class.php deleted file mode 100644 index d667572f9c..0000000000 --- a/test/class/git.class.php +++ /dev/null @@ -1,119 +0,0 @@ -tester = $tester; - $this->gitModel = $this->tester->loadModel('git'); - } - - /** - * Update commit. - * - * @param object $repo - * @param array $commentGroup - * @param bool $printLog - * @access public - * @return bool - */ - public function updateCommit($repo) - { - $repoID = isset($repo->id) ? $repo->id : 0; - $oldLastSync = $this->tester->dao->select('lastSync')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch('lastSync'); - $result = $this->gitModel->updateCommit($repo, array(), false); - if(empty($repoID)) return $result; - $newLastSync = $this->tester->dao->select('lastSync')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch('lastSync'); - return $oldLastSync != $newLastSync; - } - - /** - * Set the repos. - * - * @access public - * @return object - */ - public function setRepos() - { - $this->gitModel->setRepos(); - $repo = array_shift($this->gitModel->repos); - return $repo; - } - - /** - * Get repos. - * - * @access public - * @return string - */ - public function getRepos() - { - $pairs = $this->gitModel->getRepos(); - return array_shift($pairs); - } - - /** - * Set repo. - * - * @param object $repo - * @access public - * @return object - */ - public function setRepo($repo) - { - $this->gitModel->client = ''; - $this->gitModel->repoRoot = ''; - - $result = $this->gitModel->setRepo($repo); - - $data = new stdclass(); - $data->result = $result; - $data->client = !empty($this->gitModel->client); - $data->repoRoot = !empty($this->gitModel->repoRoot); - return $data; - } - - /** - * get tags histories for repo. - * - * @param object $repo - * @access public - * @return int - */ - public function getRepoTags($repo) - { - $tags = $this->gitModel->getRepoTags($repo); - if(is_array($tags) and count($tags) >= 1) return 1; - return 0; - } - - /** - * Get repo logs. - * - * @param object $repo - * @access public - * @return int - */ - public function getRepoLogs($repo) - { - $logs = $this->gitModel->getRepoLogs($repo, ''); - if(is_array($logs) and count($logs) >= 1) return 1; - return 0; - } - - /** - * Convert log from xml format to object. - * - * @param object $log - * @access public - * @return object - */ - public function convertLog($log) - { - $parsedLogs = $this->gitModel->convertLog($log); - if(empty($parsedLogs->revision)) $parsedLogs->revision = 0; - return $parsedLogs; - } -} diff --git a/test/class/gitea.class.php b/test/class/gitea.class.php deleted file mode 100644 index 52cec105a3..0000000000 --- a/test/class/gitea.class.php +++ /dev/null @@ -1,102 +0,0 @@ -tester = $tester; - $this->gitea = $this->tester->loadModel('gitea'); - } - - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $gitea = $this->gitea->getByID($id); - if(empty($gitea)) return 0; - return $gitea; - } - - /** - * Get gitea list. - * - * @param string $orderBy - * @access public - * @return object - */ - public function getList($orderBy = 'id_desc') - { - $gitea = $this->gitea->getList($orderBy); - if(empty($gitea)) return 0; - return array_shift($gitea); - } - - /** - * Get gitea pairs - * - * @return string - */ - public function getPairs() - { - $pairs = $this->gitea->getPairs(); - return key($pairs); - } - - /** - * Get gitea tasks. - * - * @param int $id - * @access public - * @return array - */ - public function getTasks($id) - { - $tasks = $this->gitea->getTasks($id); - if(empty($tasks)) return 0; - return $tasks; - } - - /** - * Create a gitea. - * - * @access public - * @return object|string - */ - public function create() - { - $giteaID = $this->gitea->create(); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gitea->getById($giteaID); - } - - /** - * Update a gitea. - * - * @param int $id - * @access public - * @return object|string - */ - public function update($id) - { - $this->gitea->update($id); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gitea->getById($id); - } -} diff --git a/test/class/gitlab.class.php b/test/class/gitlab.class.php deleted file mode 100644 index 3b37d06525..0000000000 --- a/test/class/gitlab.class.php +++ /dev/null @@ -1,152 +0,0 @@ -tester = $tester; - $this->gitlab = $this->tester->loadModel('gitlab'); - } - - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $gitlab = $this->gitlab->getByID($id); - if(empty($gitlab)) return 0; - return $gitlab; - } - - /** - * Get gitlab list. - * - * @param string $orderBy - * @access public - * @return object - */ - public function getList($orderBy = 'id_desc') - { - $gitlab = $this->gitlab->getList($orderBy); - if(empty($gitlab)) return 0; - return array_shift($gitlab); - } - - /** - * Get gitlab pairs - * - * @return string - */ - public function getPairs() - { - $pairs = $this->gitlab->getPairs(); - return key($pairs); - } - - /** - * Create a gitlab. - * - * @access public - * @return object|string - */ - public function create() - { - $gitlabID = $this->gitlab->create(); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gitlab->getById($gitlabID); - } - - /** - * Update a gitlab. - * - * @param int $id - * @access public - * @return object|string - */ - public function update($id) - { - $this->gitlab->update($id); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gitlab->getById($id); - } - - /** - * Manage branch privs. - * - * @param int $gitlabID - * @param int $projectID - * @param array $hasAccessBranches - * @access public - * @return string - */ - public function manageBranchPrivsTest($gitlabID, $projectID, $hasAccessBranches = array()) - { - $result = $this->gitlab->manageBranchPrivs($gitlabID, $projectID, $hasAccessBranches); - return empty($result) ? 'success' : 'fail'; - } - - /** - * Manage tag privs. - * - * @param int $gitlabID - * @param int $projectID - * @param array $hasAccessTags - * @access public - * @return string - */ - public function manageTagPrivsTest($gitlabID, $projectID, $hasAccessTags = array()) - { - $result = $this->gitlab->manageTagPrivs($gitlabID, $projectID, $hasAccessTags); - return empty($result) ? 'success' : 'fail'; - } - - /** - * Api get signle tag. - * - * @param int $gitlabID - * @param int $projectID - * @param string $tag - * @access public - * @return object - */ - public function apiGetSingleTagTest($gitlabID, $projectID, $tag) - { - return $this->gitlab->apiGetSingleTag($gitlabID, $projectID, $tag); - } - - /** - * Get gitlab menu. - * - * @param int $gitlabID - * @param string $type - * @access public - * @return void - */ - public function getGitlabMenuTest($gitlabID, $type = 'project') - { - $html = $this->gitlab->getGitlabMenu($gitlabID, $type); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return substr($html, 0, 4); - } -} diff --git a/test/class/gogs.class.php b/test/class/gogs.class.php deleted file mode 100644 index 68d7c74435..0000000000 --- a/test/class/gogs.class.php +++ /dev/null @@ -1,88 +0,0 @@ -tester = $tester; - $this->gogs = $this->tester->loadModel('gogs'); - } - - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $gogs = $this->gogs->getByID($id); - if(empty($gogs)) return 0; - return $gogs; - } - - /** - * Get gogs list. - * - * @param string $orderBy - * @access public - * @return object - */ - public function getList($orderBy = 'id_desc') - { - $gogs = $this->gogs->getList($orderBy); - if(empty($gogs)) return 0; - return array_shift($gogs); - } - - /** - * Get gogs pairs - * - * @return string - */ - public function getPairs() - { - $pairs = $this->gogs->getPairs(); - return key($pairs); - } - - /** - * Create a gogs. - * - * @access public - * @return object|string - */ - public function create() - { - $gogsID = $this->gogs->create(); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gogs->getById($gogsID); - } - - /** - * Update a gogs. - * - * @param int $id - * @access public - * @return object|string - */ - public function update($id) - { - $this->gogs->update($id); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->gogs->getById($id); - } -} diff --git a/test/class/group.class.php b/test/class/group.class.php deleted file mode 100755 index a9837417d0..0000000000 --- a/test/class/group.class.php +++ /dev/null @@ -1,473 +0,0 @@ -objectModel = $tester->loadModel('group'); - } - - /** - * Test create a group. - * - * @param mixed $param - * @access public - * @return object - */ - public function createObject($param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - - $groupID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($groupID); - - return $object; - } - - /** - * Update a group. - * - * @param int $groupID - * @access public - * @return void - */ - public function updateTest($groupID, $param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - - $object = $this->objectModel->update($groupID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($groupID); - - return $object; - } - - /** - * Copy a group. - * - * @param int $groupID - * @access public - * @return void - */ - public function copyTest($groupID, $param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - - $objects = $this->objectModel->copy($groupID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $newGroupID = $this->objectModel->dao->lastInsertID(); - $object = $this->objectModel->getByID($newGroupID); - - $this->objectModel->delete($newGroupID); - return $object; - } - - /** - * Copy privileges. - * - * @param string $fromGroup - * @param string $toGroup - * @access public - * @return void - */ - public function copyPrivTest($fromGroup, $toGroup) - { - $objects = $this->objectModel->copyPriv($fromGroup, $toGroup); - - if(dao::isError()) return dao::getError(); - - $fromPrivs = $this->objectModel->getPrivs($fromGroup); - $toPrivs = $this->objectModel->getPrivs($toGroup); - - $result = true; - foreach($fromPrivs as $group => $privs) - { - foreach($privs as $key => $priv) - { - if(!isset($toPrivs[$group][$key]) or $toPrivs[$group][$key] != $fromPrivs[$group][$key]) - { - $result = false; - break; - } - } - } - return $result; - } - - /** - * Copy user. - * - * @param string $fromGroup - * @param string $toGroup - * @access public - * @return void - */ - public function copyUserTest($fromGroup, $toGroup) - { - $objects = $this->objectModel->copyUser($fromGroup, $toGroup); - - if(dao::isError()) return dao::getError(); - - $fromUsers = $this->objectModel->getUserPairs($fromGroup); - $toUsers = $this->objectModel->getUserPairs($toGroup); - - $result = true; - foreach($fromUsers as $account => $name) - { - if(!isset($toUsers[$account]) or $toUsers[$account] != $fromUsers[$account]) - { - $result = false; - break; - } - } - return $result; - } - - /** - * Get group lists. - * - * @param int $projectID - * @access public - * @return array - */ - public function getListTest($projectID = 0) - { - $objects = $this->objectModel->getList($projectID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get group pairs. - * - * @param int $projectID - * @access public - * @return array - */ - public function getPairsTest($projectID = 0) - { - $objects = $this->objectModel->getPairs($projectID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get group by id. - * - * @param int $groupID - * @access public - * @return object - */ - public function getByIDTest($groupID) - { - $objects = $this->objectModel->getByID($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get group by account. - * - * @param string $account - * @access public - * @return array - */ - public function getByAccountTest($account) - { - $objects = $this->objectModel->getByAccount($account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get groups by accounts. - * - * @param array $accounts - * @access public - * @return array - */ - public function getByAccountsTest($accounts) - { - $objects = $this->objectModel->getByAccounts($accounts); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get the account number in the group. - * - * @param array $groupIdList - * @access public - * @return array - */ - public function getGroupAccountsTest($groupIdList) - { - $objects = $this->objectModel->getGroupAccounts($groupIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get privileges of a groups. - * - * @param int $groupID - * @access public - * @return array - */ - public function getPrivsTest($groupID) - { - $objects = $this->objectModel->getPrivs($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get user pairs of a group. - * - * @param int $groupID - * @access public - * @return array - */ - public function getUserPairsTest($groupID) - { - $objects = $this->objectModel->getUserPairs($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get user programs of a group. - * - * @param int $groupID - * @access public - * @return array - */ - public function getUserProgramsTest($groupID) - { - $objects = $this->objectModel->getUserPrograms($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get the ID of the group that has access to the program. - * - * @access public - * @return array - */ - public function getAccessProgramGroupTest() - { - $objects = $this->objectModel->getAccessProgramGroup(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete a group. - * - * @param int $groupID - * @param null $null compatible with that of model::delete() - * @access public - * @return void - */ - public function deleteTest($groupID, $null = null) - { - $this->objectModel->delete($groupID, $null = null); - - if(dao::isError()) return dao::getError(); - - return true; - } - - /** - * Update privilege of a group. - * - * @param int $groupID - * @access public - * @return bool - */ - public function updatePrivByGroupTest($groupID, $menu, $version) - { - $objects = $this->objectModel->updatePrivByGroup($groupID, $menu, $version); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Update privilege by module. - * - * @access public - * @return void - */ - public function updatePrivByModuleTest() - { - $objects = $this->objectModel->updatePrivByModule(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Update users. - * - * @param int $groupID - * @access public - * @return void - */ - public function updateUserTest($groupID) - { - $objects = $this->objectModel->updateUser($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Update project admins. - * - * @param int $groupID - * @access public - * @return void - */ - public function updateProjectAdminTest($groupID) - { - $objects = $this->objectModel->updateProjectAdmin($groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Sort resource. - * - * @access public - * @return void - */ - public function sortResourceTest() - { - $objects = $this->objectModel->sortResource(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Check menu have module - * - * @param string $menu - * @param string $moduleName - * @access public - * @return void - */ - public function checkMenuModuleTest($menu, $moduleName) - { - $objects = $this->objectModel->checkMenuModule($menu, $moduleName); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get modules in menu - * - * @param string $menu - * @access public - * @return void - */ - public function getMenuModulesTest($menu) - { - $objects = $this->objectModel->getMenuModules($menu); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - - - - - /** - * 获取一条权限的基本信息 - * - * @param int $privID - * @param string $lang - * @access public - * @return void - */ - public function getPrivInfoTest($priv, $lang) - { - $object = $this->objectModel->getPrivInfo($priv, $lang); - if(dao::isError()) return dao::getError(); - return $object; - } - - - - - - /** - * 获取模块和权限包option - * - * @access public - * @return array - */ - public function getModuleAndPackageTreeTest() - { - return $this->objectModel->getModuleAndPackageTree(); - } - - - /** - * 更新权限 - * - * @access public - * @return void - */ - public function updatePrivTest($privID,$lang) - { - $this->objectModel->updatePrivLang($privID,$lang); - if(dao::isError()) - { - return false; - } - return true; - } -} diff --git a/test/class/holiday.class.php b/test/class/holiday.class.php deleted file mode 100644 index 5b2fcccdcc..0000000000 --- a/test/class/holiday.class.php +++ /dev/null @@ -1,320 +0,0 @@ -objectModel = $tester->loadModel('holiday'); - } - - /** - * Test getById method. - * - * @param int $id - * @access public - * @return object - */ - public function getByIdTest($id) - { - $objects = $this->objectModel->getById($id); - - if($objects === false) return 'Object not found'; - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test getList method. - * - * @param string $year - * @param string $type - * @access public - * @return object - */ - public function getListTest($year = '', $type = 'all') - { - $objects = $this->objectModel->getList($year, $type); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test getYearPairs method. - * - * @access public - * @return int - */ - public function getYearPairsTest() - { - $objects = $this->objectModel->getYearPairs(); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test create method. - * - * @param array $param - * @access public - * @return object - */ - public function createTest($param = array()) - { - $defaultParam['type'] = 'holiday'; - $defaultParam['begin'] = '2022-01-01'; - $defaultParam['end'] = '2022-02-01'; - $defaultParam['name'] = '测试创建holiday'; - $defaultParam['desc'] = '默认的holiday'; - - foreach($defaultParam as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - $lastInsertID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->objectModel->getByID($lastInsertID); - return $object; - } - } - - /** - * Test update method. - * - * @param int $holidayID - * @param array $param - * @access public - * @return object - */ - public function updateTest($holidayID, $param = array()) - { - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_HOLIDAY ." WHERE id = $holidayID")->fetch(); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $noError = $this->objectModel->update($bugID); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return 'true'; - } - } - - /** - * Test getHolidays method. - * - * @param string $begin - * @param string $end - * @access public - * @return object - */ - public function getHolidaysTest($begin, $end) - { - $objects = $this->objectModel->getHolidays($begin, $end); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test getWorkingDays method. - * - * @param string $begin - * @param string $end - * @access public - * @return int - */ - public function getWorkingDaysTest($begin = '', $end = '') - { - $objects = $this->objectModel->getWorkingDays($begin, $end); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test getActualWorkingDays method. - * - * @param string $begin - * @param string $end - * @access public - * @return int - */ - public function getActualWorkingDaysTest($begin, $end) - { - $objects = $this->objectModel->getActualWorkingDays($begin, $end); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test getDaysBetweenTest method. - * - * @param string $begin - * @param string $end - * @access public - * @return int - */ - public function getDaysBetweenTest($begin, $end) - { - $objects = $this->objectModel->getDaysBetween($begin, $end); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test isHoliday method. - * - * @param string $date - * @access public - * @return object - */ - public function isHolidayTest($date) - { - $objects = $this->objectModel->isHoliday($date); - - if(dao::isError()) return dao::getError(); - - return $objects === true ? "It is a holiday" : "It is not a holiday"; - } - - /** - * Test isWorkingDay method. - * - * @param string $date - * @access public - * @return object - */ - public function isWorkingDayTest($date) - { - $objects = $this->objectModel->isWorkingDay($date); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test updateProgramPlanDuration method. - * - * @param int $testProjectID - * @param object $holiday - * @access public - * @return int - */ - public function updateProgramPlanDurationTest($testProjectID, $holidayID) - { - global $tester; - - $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); - - $this->objectModel->updateProgramPlanDuration($holiday->begin, $holiday->end); - - $project = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($testProjectID)->fetch(); - - if(dao::isError()) return dao::getError(); - - return $project->planDuration; - } - - /** - * Test updateProjectRealDuration method. - * - * @param int $testProjectID - * @param object $holiday - * @access public - * @return int - */ - public function updateProjectRealDurationTest($testProjectID, $holidayID) - { - global $tester; - - $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); - - $this->objectModel->updateProjectRealDuration($holiday->begin, $holiday->end); - - $project = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($testProjectID)->fetch(); - - if(dao::isError()) return dao::getError(); - - return $project->realDuration; - } - - /** - * Test updateTaskPlanDuration method. - * - * @param int $testTaskID - * @param object $holiday - * @access public - * @return int - */ - public function updateTaskPlanDurationTest($testTaskID, $holidayID) - { - global $tester; - - $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); - - $this->objectModel->updateTaskPlanDuration($holiday->begin, $holiday->end); - - $task = $tester->dao->select('*')->from(TABLE_TASK)->where('id')->eq($testTaskID)->fetch(); - - if(dao::isError()) return dao::getError(); - - return $task->planDuration; - } - - /** - * Test updateTaskRealDuration method. - * - * @param int $testTaskID - * @param object $holiday - * @access public - * @return int - */ - public function updateTaskRealDurationTest($testTaskID, $holidayID) - { - global $tester; - - $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); - - $this->objectModel->updateTaskRealDuration($holiday->begin, $holiday->end); - - $task = $tester->dao->select('*')->from(TABLE_TASK)->where('id')->eq($testTaskID)->fetch(); - - if(dao::isError()) return dao::getError(); - - return $task->realDuration; - } -} diff --git a/test/class/jenkins.class.php b/test/class/jenkins.class.php deleted file mode 100644 index 7d75f0c5f1..0000000000 --- a/test/class/jenkins.class.php +++ /dev/null @@ -1,102 +0,0 @@ -tester = $tester; - $this->jenkins = $this->tester->loadModel('jenkins'); - } - - /** - * Get by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $jenkins = $this->jenkins->getByID($id); - if(empty($jenkins)) return 0; - return $jenkins; - } - - /** - * Get jenkins list. - * - * @param string $orderBy - * @access public - * @return object - */ - public function getList($orderBy = 'id_desc') - { - $jenkins = $this->jenkins->getList($orderBy); - if(empty($jenkins)) return 0; - return array_shift($jenkins); - } - - /** - * Get jenkins pairs - * - * @return string - */ - public function getPairs() - { - $pairs = $this->jenkins->getPairs(); - return key($pairs); - } - - /** - * Get jenkins tasks. - * - * @param int $id - * @access public - * @return array - */ - public function getTasks($id) - { - $tasks = $this->jenkins->getTasks($id); - if(empty($tasks)) return 0; - return $tasks; - } - - /** - * Create a jenkins. - * - * @access public - * @return object|string - */ - public function create() - { - $jenkinsID = $this->jenkins->create(); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->jenkins->getById($jenkinsID); - } - - /** - * Update a jenkins. - * - * @param int $id - * @access public - * @return object|string - */ - public function update($id) - { - $this->jenkins->update($id); - if(dao::isError()) - { - $errors = dao::getError(); - return key($errors); - } - - return $this->jenkins->getById($id); - } -} diff --git a/test/class/job.class.php b/test/class/job.class.php deleted file mode 100644 index b7636392f5..0000000000 --- a/test/class/job.class.php +++ /dev/null @@ -1,305 +0,0 @@ -objectModel = $tester->loadModel('job'); - } - - /** - * Test get job by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByIdTest($id) - { - $object = $this->objectModel->getById($id); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get job list. - * - * @param string $orderBy - * @param int $pager - * @access public - * @return object - */ - public function getListTest($orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get list by repo id. - * - * @param int $repoID - * @access public - * @return object - */ - public function getListByRepoIDTest($repoID) - { - return $this->objectModel->getListByRepoID($repoID); - } - - /** - * Test get job pairs. - * - * @param int $repoID - * @param string $engine - * @access public - * @return object - */ - public function getPairsTest($repoID, $engine = '') - { - $objects = $this->objectModel->getPairs($repoID, $engine); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get job list by trigger type. - * - * @param string $triggerType - * @param array $repoIdList - * @access public - * @return object - */ - public function getListByTriggerTypeTest($triggerType, $repoIdList = array()) - { - $objects = $this->objectModel->getListByTriggerType($triggerType, $repoIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get trigger config. - * - * @param int $id - * @access public - * @return object - */ - public function getTriggerConfigTest($id) - { - - $job = $this->objectModel->getById($id); - - $object = $this->objectModel->getTriggerConfig($job); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get trigger group. - * - * @param string $triggerType - * @param array $repoIdList - * @access public - * @return array - */ - public function getTriggerGroupTest($triggerType, $repoIdList) - { - $array = $this->objectModel->getTriggerGroup($triggerType, $repoIdList); - - if(dao::isError()) return dao::getError(); - - $group = array(); - if($triggerType == 'tag') $group = isset($array[1]) ? $array[1] : array(); - if($triggerType == 'commit') $group = isset($array[2]) ? $array[2] : array(); - - return $group; - } - - /** - * Test create object. - * - * @param array $params - * @access public - * @return object - */ - public function createObject($params) - { - $createFields['name'] = '这是一个JOB3'; - $createFields['engine'] = 'gitlab'; - $createFields['repo'] = '1'; - $createFields['reference'] = 'test_case'; - $createFields['product'] = '1'; - $createFields['frame'] = 'phpunit'; - $createFields['triggerType'] = 'commit'; - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($params as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create(); - unset($_POST); - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($objectID); - return $object; - } - - /** - * Test update object. - * - * @param int $jobId - * @param array $params - * @access public - * @return string - */ - public function updateObject($jobId, $params = array()) - { - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_JOB ." WHERE id = $jobId")->fetch(); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($params))) - { - $_POST[$field] = $params[$field]; - } - else - { - $_POST[$field] = $value; - } - } - $_POST['jkServer'] = 3; - $_POST['jkTask'] = 'dave'; - - $result = $this->objectModel->update($jobId); - unset($_POST); - if(dao::isError()) return dao::getError()[0]; - - return $result ? 'Job更新成功' : 'Job更新失败'; - } - - /** - * Test exec job. - * - * @param int $id - * @param array $extraParam - * @access public - * @return object - */ - public function execTest($id, $extraParam = array()) - { - $object = $this->objectModel->exec($id, $extraParam); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test exec jenkins pipeline. - * - * @param int $jobID - * @param object $repo - * @param int $compileID - * @param array $extraParam - * @access public - * @return object - */ - public function execJenkinsPipelineTest($jobID, $repo, $compileID, $extraParam = array()) - { - $job = $this->objectModel->getById($jobID); - - $object = $this->objectModel->execJenkinsPipeline($job, $repo, $compileID, $extraParam); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test exec gitlab pipeline. - * - * @param int $jobID - * @access public - * @return object - */ - public function execGitlabPipelineTest($jobID) - { - $job = $this->objectModel->getById($jobID); - - $object = $this->objectModel->execGitlabPipeline($job); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get last tag by repo. - * - * @param int $repoId - * @param int $jobId - * @access public - * @return string - */ - public function getLastTagByRepoTest($jobId) - { - global $tester; - $job = $this->objectModel->getById($jobId); - $repo = $tester->loadModel('repo')->getRepoById($job->repo); - $object = $this->objectModel->getLastTagByRepo($repo, $job); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get sonarqube by RepoID. - * - * @param array $repoIDList - * @param int $jobID - * @param bool $showDeleted - * @access public - * @return array - */ - public function getSonarqubeByRepoTest($repoIDList, $jobID = 0, $showDeleted = false) - { - $array = $this->objectModel->getSonarqubeByRepo($repoIDList, $jobID, $showDeleted); - - if(dao::isError()) return dao::getError(); - - return $array; - } - - /** - * Test get job pairs by sonarqube projectkeys. - * - * @param int $sonarqubeID - * @param array $projectKeys - * @param bool $emptyShowAll - * @param bool $showDeleted - * @access public - * @return array - */ - public function getJobBySonarqubeProjectTest($sonarqubeID, $projectKeys = array(), $emptyShowAll = false, $showDeleted = false) - { - $array = $this->objectModel->getJobBySonarqubeProject($sonarqubeID, $projectKeys, $emptyShowAll, $showDeleted); - - if(dao::isError()) return dao::getError(); - - return $array; - } - -} diff --git a/test/class/kanban.class.php b/test/class/kanban.class.php deleted file mode 100644 index a3bb5b49b7..0000000000 --- a/test/class/kanban.class.php +++ /dev/null @@ -1,1797 +0,0 @@ -objectModel = $tester->loadModel('kanban'); - } - - /** - * Test create a kanban group. - * - * @param int $kanbanID - * @param int $regionID - * @access public - * @return object - */ - public function createGroupTest($kanbanID, $regionID) - { - $objectID = $this->objectModel->createGroup($kanbanID, $regionID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->findByID($objectID)->from(TABLE_KANBANGROUP)->fetch(); - return $object; - } - - /** - * Test create a default kanban region. - * - * @param int $kanbanID - * @access public - * @return object - */ - public function createDefaultRegionTest($kanban) - { - $objectID = $this->objectModel->createDefaultRegion($kanban); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getRegionByID($objectID); - return $object; - } - - /** - * Test create a region. - * - * @param object $kanban - * @param object $region - * @param int $copyRegionID - * @access public - * @return object - */ - public function createRegionTest($kanban, $region = null, $copyRegionID = 0) - { - if(!is_null($region)) - { - if(empty($copyRegionID)) - { - foreach($region as $key => $value) $_POST[$key] = $value; - $region = null; - } - - $objectID = $this->objectModel->createRegion($kanban, $region, $copyRegionID); - } - else - { - $objectID = $this->objectModel->createDefaultRegion($kanban); - } - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getRegionByID($objectID); - return $object; - } - - /** - * Test create default kanban lanes. - * - * @param int $regionID - * @param int $groupID - * @access public - * @return object - */ - public function createDefaultLaneTest($regionID, $groupID) - { - $objectID = $this->objectModel->createDefaultLane(null, $regionID, $groupID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getLaneByID($objectID); - return $object; - } - - /** - * Test create default kanban columns. - * - * @param int $regionID - * @param int $groupID - * @access public - * @return int - */ - public function createDefaultColumnsTest($regionID, $groupID) - { - $this->objectModel->createDefaultColumns(null, $regionID, $groupID); - - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`region`')->eq($regionID)->andWhere('`group`')->eq($groupID)->andWhere('`type`')->like('column%')->fetchAll(); - return count($objects); - } - - /** - * Test create a column. - * - * @param object $param - * @access public - * @return object - */ - public function createColumnTest($param) - { - $regionID = 1; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->createColumn($regionID, null, 0, $param->parent); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getColumnByID($objectID); - return $object; - } - - /** - * Test split column. - * - * @param int $columnID - * @param array $param - * @access public - * @return int - */ - public function splitColumnTest($columnID, $param) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->splitColumn($columnID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $childs = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`parent`')->eq($columnID)->fetchAll(); - return count($childs); - } - - /** - * Test create a card. - * - * @param array $param - * @access public - * @return object - */ - public function createCardTest($param) - { - $kanbanID = 1; - $regionID = 1; - $groupID = 1; - $columnID = 1; - - $_POST['lane'] = 1; - $_POST['begin'] = date('Y-m-d', strtotime("-3 day")); - $_POST['end'] = date('Y-m-d', strtotime("+3 day")); - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->createCard($kanbanID, $regionID, $groupID, $columnID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getCardByID($objectID); - return $object; - } - - /** - * Test import card. - * - * @param int $kanbanID - * @param int $regionID - * @param int $groupID - * @param int $columnID - * @param array $cards - * @param int $targetLane - * @access public - * @return object - */ - public function importCardTest($kanbanID, $regionID, $groupID, $columnID, $cards, $targetLane) - { - $_POST['cards'] = $cards; - $_POST['targetLane'] = $targetLane; - - $this->objectModel->importCard($kanbanID, $regionID, $groupID, $columnID); - - unset($_POST); - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('`lane`')->eq($targetLane)->andWhere('`column`')->eq($columnID)->andWhere('kanban')->eq($kanbanID)->andWhere('type')->eq('common')->fetch(); - return $object; - } - - /** - * Test import object. - * - * @param int $kanbanID - * @param int $regionID - * @param int $groupID - * @param int $columnID - * @param string $objectType - * @param array $param - * @access public - * @return object - */ - public function importObjectTest($kanbanID, $regionID, $groupID, $columnID, $objectType, $param) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->importObject($kanbanID, $regionID, $groupID, $columnID, $objectType); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('`lane`')->eq($param['targetLane'])->andWhere('`column`')->eq($columnID)->andWhere('kanban')->eq($kanbanID)->andWhere('type')->eq('common')->fetch(); - return $object; - } - - /** - * Test batch create kanban cards. - * - * @param array $param - * @param bool $endLtBegin - * @access public - * @return object - */ - public function batchCreateCardTest($param = array(), $endLtBegin = false) - { - $kanbanID = 1; - $regionID = 1; - $groupID = 1; - $columnID = 1; - $batchCreateFields['name'] = array('0' => '批量创建卡片1', '1' => '批量创建卡片2', '2' => '批量创建卡片3', '3' => '批量创建卡片4'); - $batchCreateFields['lane'] = array('0' => '1', '1' => 'ditto', '2' => 'ditto', '3' => 'ditto'); - $batchCreateFields['assignedTo'] = array(); - $batchCreateFields['estimate'] = array('0' => '1', '1' => '2', '2' => '3', '3' => '4'); - $batchCreateFields['begin'] = array('0' => date('Y-m-d', time()), '1' => date('Y-m-d', time()), '2' => '', '3' => ''); - $batchCreateFields['end'] = !$endLtBegin ? array('0' => date('Y-m-d', time()), '1' => '', '2' => '', '3' => '') : array('0' => date('Y-m-d', strtotime("-1 day")), '1' => date('Y-m-d', strtotime("-1 day")), '2' => date('Y-m-d', strtotime("-2 day")), '3' => date('Y-m-d', strtotime("-3 day"))); - $batchCreateFields['desc'] = array('0' => '描述1', '1' => '描述2', '2' => '描述3', '3' => '描述4'); - $batchCreateFields['pri'] = array('0' => '1', '1' => '2', '2' => '3', '3' => '4'); - $batchCreateFields['beginDitto'] = array('1' => 'on', '2' => 'on', '3' => 'on', '4' => 'on'); - $batchCreateFields['endDitto'] = array('1' => 'on', '2' => 'on', '3' => 'on', '4' => 'on'); - - foreach($batchCreateFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->batchCreateCard($kanbanID, $regionID, $groupID, $columnID); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('kanban')->eq($kanbanID)->andWhere('lane')->eq(1)->andWhere('`column`')->eq($columnID)->andWhere('type')->eq('common')->fetch(); - - unset($_POST); - - if(dao::isError()) return dao::getError()[0]; - - return $object; - } - - /** - * Test get kanban by id. - * - * @param int $kanbanID - * @access public - * @return object - */ - public function getByIDTest($kanbanID) - { - $object = $this->objectModel->getByID($kanbanID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get kanban data. - * - * @param int $kanbanID - * @access public - * @return string - */ - public function getKanbanDataTest($kanbanID) - { - $objects = $this->objectModel->getKanbanData($kanbanID); - - if(dao::isError()) return dao::getError(); - - $columnCount = 0; - $laneCount = 0; - $cardCount = 0; - foreach($objects as $regions) - { - foreach($regions->groups as $group) - { - foreach($group->lanes as $lane) $cardCount += count($lane->items); - - $columnCount += count($group->columns); - $laneCount += count($group->lanes); - } - } - return 'columns:' . $columnCount . ', lanes:' . $laneCount . ', cards:' . $cardCount; - } - - /** - * Test get plan kanban. - * - * @param int $productID - * @param int $branchID - * @access public - * @return string - */ - public function getPlanKanbanTest($productID, $branchID = 0) - { - global $tester; - $product = $tester->loadModel('product')->getByID($productID); - - $tester->loadModel('productplan'); - $planGroup = $product->type == 'normal' ? $tester->productplan->getList($product->id, 0, 'all', '', 'begin_desc', 'skipparent') : $tester->productplan->getGroupByProduct($product->id, 'skipParent', '', 'begin_desc'); - - $objects = $this->objectModel->getPlanKanban($product, $branchID, $planGroup); - - if(dao::isError()) return dao::getError(); - - $laneCount = 0; - $cardCount = 0; - foreach($objects->lanes as $lane) - { - foreach($lane->items as $item) $cardCount += count($item); - } - return 'lanes:' . count($objects->lanes) . ', cards:' . $cardCount; - } - - /** - * Test get a RD kanban data. - * - * @param int $executionID - * @param string $browseType - * @param int $regionID - * @access public - * @return string - */ - public function getRDKanbanTest($executionID, $browseType = 'all', $regionID = 0) - { - $objects = $this->objectModel->getRDKanban($executionID, $browseType, 'id_desc', $regionID); - - if(dao::isError()) return dao::getError(); - - $columnCount = 0; - $laneCount = 0; - $cardCount = 0; - foreach($objects as $regions) - { - foreach($regions->groups as $group) - { - $columnCount += count($group->columns); - $laneCount += count($group->lanes); - foreach($group->lanes as $lane) - { - foreach($lane->items as $item) $cardCount += count($item); - } - } - } - return 'columns:' . $columnCount . ', lanes:' . $laneCount . ', cards:' . $cardCount; - } - - /** - * Test get region by id. - * - * @param int $regionID - * @access public - * @return object - */ - public function getRegionByIDTest($regionID) - { - $object = $this->objectModel->getRegionByID($regionID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get ordered region pairs. - * - * @param int $kanbanID - * @param int $regionID - * @param string $from - * @access public - * @return array - */ - public function getRegionPairsTest($kanbanID, $regionID = 0, $from = 'kanban') - { - $objects = $this->objectModel->getRegionPairs($kanbanID, $regionID, $from); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get kanban id by region id. - * - * @param int $regionID - * @access public - * @return int - */ - public function getKanbanIDByRegionTest($regionID) - { - $object = $this->objectModel->getKanbanIDByRegion($regionID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get kanban group by regions. - * - * @param string $regions - * @access public - * @return int - */ - public function getGroupGroupByRegionsTest($regions) - { - $objects = $this->objectModel->getGroupGroupByRegions($regions); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - - return $count; - } - - public function getLaneGroupByRegionsTest($regions, $browseType = 'all') - { - $objects = $this->objectModel->getLaneGroupByRegions($regions, $browseType); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - return $count; - } - - /** - * Test get lane pairs by group id. - * - * @param int $groupID - * @param string $orderBy - * @access public - * @return string - */ - public function getLanePairsByGroupTest($groupID, $orderBy = '`order`_asc') - { - $objects = $this->objectModel->getLanePairsByGroup($groupID, $orderBy = '`order`_asc'); - - if(dao::isError()) return dao::getError(); - - $names = implode(',', $objects); - return $names; - } - - public function getColumnGroupByRegionsTest($regions, $order = 'order') - { - $objects = $this->objectModel->getColumnGroupByRegions($regions, $order = 'order'); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - return $count; - } - - /** - * Test get card group by kanban id. - * - * @param int $kanbanID - * @access public - * @return int - */ - public function getCardGroupByKanbanTest($kanbanID) - { - $objects = $this->objectModel->getCardGroupByKanban($kanbanID); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get imported cards. - * - * @param int $kanbanID - * @param string $fromType - * @param int $archived - * @param int $regionID - * @access public - * @return string - */ - public function getImportedCardsTest($kanbanID, $fromType, $archived = 0, $regionID = 0) - { - global $tester; - $cards = $tester->dao->select('*')->from(TABLE_KANBANCARD) - ->where('deleted')->eq(0) - ->andWhere('kanban')->eq($kanbanID) - ->andWhere('archived')->eq($archived) - ->andWhere('fromID')->eq(0) - ->beginIF($regionID)->andWhere('region')->eq($regionID)->fi() - ->fetchAll('id'); - - $objects = $this->objectModel->getImportedCards($kanbanID, $cards, $fromType, $archived, $regionID); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test get RD column group by regions. - * - * @param int $regions - * @param array $groupIDList - * @access public - * @return int - */ - public function getRDColumnGroupByRegionsTest($regions, $groupIDList = array()) - { - $objects = $this->objectModel->getRDColumnGroupByRegions($regions, $groupIDList); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - return $count; - } - - /** - * Test get card group by execution id. - * - * @param int $executionID - * @param string $browseType - * @param string $orderBy - * @access public - * @return int - */ - public function getCardGroupByExecutionTest($executionID, $browseType = 'all') - { - $objects = $this->objectModel->getCardGroupByExecution($executionID, $browseType); - - if(dao::isError()) return dao::getError(); - - $cardCount = 0; - foreach($objects as $lane) - { - foreach($lane as $type) $cardCount += count($type); - } - return $cardCount; - } - - /** - * Test get Kanban by execution id. - * - * @param int $executionID - * @param string $browseType - * @param string $groupBy - * @access public - * @return string - */ - public function getExecutionKanbanTest($executionID, $browseType = 'all', $groupBy = 'default') - { - $objects = $this->objectModel->getExecutionKanban($executionID, $browseType, $groupBy); - - if(empty($objects)) - { - $this->objectModel->createExecutionLane($executionID, $browseType, $groupBy); - $objects = $this->objectModel->getExecutionKanban($executionID, $browseType, $groupBy); - } - - if(dao::isError()) return dao::getError(); - - $columnCount = 0; - $laneCount = 0; - $cardCount = 0; - foreach($objects as $types) - { - foreach($types['lanes'] as $lane) - { - foreach($lane['cards'] as $card) $cardCount += count($card); - } - $columnCount += count($types['columns']); - $laneCount += count($types['lanes']); - } - return 'columns:' . $columnCount . ', lanes:' . $laneCount . ', cards:' . $cardCount; - } - - /** - * Test get kanban for group view. - * - * @param int $executionID - * @param string $browseType - * @param string $groupBy - * @access public - * @return int - */ - public function getKanban4GroupTest($executionID, $browseType, $groupBy) - { - $objects = $this->objectModel->getKanban4Group($executionID, $browseType, $groupBy); - - if(empty($objects)) - { - $this->objectModel->createExecutionLane($executionID, $browseType, $groupBy); - $objects = $this->objectModel->getKanban4Group($executionID, $browseType, $groupBy); - } - - if(dao::isError()) return dao::getError(); - - $laneCount = 0; - foreach($objects as $types) $laneCount += count($types['lanes']); - - return 'lanes:' . $laneCount; - } - - /** - * Test get kanban for group view. - * - * @param int $executionID - * @param string $browseType - * @param string $groupBy - * @access public - * @return void - */ - public function getLanes4GroupTest($executionID, $browseType, $groupBy) - { - global $tester; - /* Get group objects. */ - if($browseType == 'story') $cardList = $tester->loadModel('story')->getExecutionStories($executionID, 0, 0, 't1.`order`_desc', 'allStory'); - if($browseType == 'bug') $cardList = $tester->loadModel('bug')->getExecutionBugs($executionID); - if($browseType == 'task') $cardList = $tester->loadModel('execution')->getKanbanTasks($executionID, "id"); - $objects = $this->objectModel->getLanes4Group($executionID, $browseType, $groupBy, $cardList); - - if(empty($objects)) - { - $this->objectModel->createExecutionLane($executionID, $browseType, $groupBy); - $objects = $this->objectModel->getLanes4Group($executionID, $browseType, $groupBy); - } - - if(dao::isError()) return dao::getError(); - - $names = ''; - foreach($objects as $object) $names .= ',' . $object->name; - return $names; - } - - /** - * Test get space list. - * - * @param string $user - * @param string $browseType - * @access public - * @return int - */ - public function getSpaceListTest($user, $browseType) - { - su($user); - $objects = $this->objectModel->getSpaceList($browseType); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get space pairs. - * - * @param int $user - * @param string $browseType - * @access public - * @return int - */ - public function getSpacePairsTest($user, $browseType = 'private') - { - su($user); - $objects = $this->objectModel->getSpacePairs($browseType); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get Kanban pairs. - * - * @param string $user - * @access public - * @return int - */ - public function getKanbanPairsTest($user) - { - su($user); - $objects = $this->objectModel->getKanbanPairs(); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get can view objects. - * - * @param string $user - * @param string $objectType - * @param string $param - * @access public - * @return void - */ - public function getCanViewObjectsTest($user, $objectType = 'kanban', $param = '') - { - su($user); - $objects = $this->objectModel->getCanViewObjects($objectType, $param); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test create a space. - * - * @param array $param - * @access public - * @return object - */ - public function createSpaceTest($param) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->createSpace(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getSpaceByID($objectID); - return $object; - } - - /** - * Test update a space. - * - * @param int $spaceID - * @param string $type - * @param array $param - * @access public - * @return array - */ - public function updateSpaceTest($spaceID, $type = '', $param = array()) - { - global $tester; - $object = $tester->dao->select('`type`,`name`,`owner`,`team`,`desc`,`whitelist`')->from(TABLE_KANBANSPACE)->where('`id`')->eq($spaceID)->fetch(); - $object->team = explode(',', $object->team); - $object->whitelist = explode(',', $object->whitelist); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $this->objectModel->updateSpace($spaceID, $type); - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test get lane pairs by region id. - * - * @param int $regionID - * @param string $type - * @access public - * @return string - */ - public function getLanePairsByRegionTest($regionID, $type = 'all') - { - global $tester; - - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->getLanePairsByRegion($regionID, $type); - - if(dao::isError()) return dao::getError(); - - $names = implode(',', $objects); - return $names; - } - - /** - * Test get lane group by regionid. - * - * @param int $regionID - * @param string $type - * @access public - * @return int - */ - public function getLaneGroupByRegionTest($regionID, $type = 'all') - { - $objects = $this->objectModel->getLaneGroupByRegion($regionID, $type); - - if(dao::isError()) return dao::getError(); - - return count($objects[$regionID]); - } - - /** - * Test create a lane. - * - * @param object $object - * @param int $kanbanID - * @param int $regionID - * @access public - * @return object - */ - public function createLaneTest($object, $kanbanID, $regionID) - { - $lane = isset($object->id) ? $this->objectModel->getLaneByID($object->id) : null; - unset($object->id); - unset($lane->id); - - foreach($object as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->createLane($kanbanID, $regionID, $lane); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getLaneByID($objectID); - return $object; - } - - /** - * Test create a kanban. - * - * @param array $param - * @access public - * @return object - */ - public function createTest($param = array()) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($objectID); - return $object; - } - - /** - * Test update a kanban. - * - * @param int $kanbanID - * @param array $param - * @access public - * @return array - */ - public function updateTest($kanbanID, $param) - { - global $tester; - $object = $tester->dao->select('`space`,`name`,`owner`,`team`,`desc`')->from(TABLE_KANBAN)->where('`id`')->eq($kanbanID)->fetch(); - $object->team = explode(',', $object->team); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $this->objectModel->update($kanbanID); - if($change == array()) $change = '没有数据更新'; - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test add execution Kanban lanes and columns. - * - * @param int $executionID - * @param string $type - * @param string $groupBy - * @access public - * @return int - */ - public function createExecutionLaneTest($executionID, $type = 'all', $groupBy = 'default') - { - $this->objectModel->createExecutionLane($executionID, $type, $groupBy); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANLANE) - ->where('execution')->eq($executionID) - ->beginIF($type != 'all')->andWhere('type')->eq($type)->fi() - ->fetchAll(); - return count($objects); - } - - /** - * Test create execution columns. - * - * @param int $laneID - * @param string $type - * @param int $executionID - * @access public - * @return int - */ - public function createExecutionColumnsTest($laneID, $type, $executionID) - { - $this->objectModel->createExecutionColumns($laneID, $type, $executionID); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANCELL) - ->where('kanban')->eq($executionID) - ->andWhere('lane')->eq($laneID) - ->andWhere('type')->eq($type) - ->fetchAll(); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test add kanban cell. - * - * @param int $kanbanID - * @param int $laneID - * @param int $colID - * @param int $type - * @param int $cardID - * @access public - * @return object - */ - public function addKanbanCellTest($kanbanID, $laneID, $colID, $type, $cardID = 0) - { - $this->objectModel->addKanbanCell($kanbanID, $laneID, $colID, $type, $cardID); - - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('kanban')->eq($kanbanID)->andWhere('lane')->eq($laneID)->andWhere('`column`')->eq($colID)->andWhere('type')->eq($type)->fetch(); - return $object; - } - - /** - * Test remove kanban cell. - * - * @param string $type - * @param int $removeCardID - * @param array $kanbanList - * @access public - * @return string - */ - public function removeKanbanCellTest($type, $removeCardID, $kanbanList) - { - $this->objectModel->removeKanbanCell($type, $removeCardID, $kanbanList); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('kanban')->in($kanbanList)->andWhere('type')->eq($type)->fetchAll(); - $cards = ''; - foreach($objects as $object) $cards .= $object->id . ':' . $object->cards . '; '; - $cards = trim($cards, '; '); - $cards = str_replace(':,', ':', $cards); - $cards = str_replace(':;', ';', $cards); - return $cards; - } - - /** - * Test create rd kanban. - * - * @param object $execution - * @access public - * @return string - */ - public function createRDKanbanTest($execution) - { - $this->objectModel->createRDKanban($execution); - - if(dao::isError()) return dao::getError(); - - global $tester; - $regions = $tester->dao->select('*')->from(TABLE_KANBANREGION)->where('`kanban`')->eq($execution->id)->fetchAll('id'); - $lanes = $tester->dao->select('*')->from(TABLE_KANBANLANE)->where('`execution`')->eq($execution->id)->andWhere('`type`')->ne('common')->fetchAll('id'); - $regionIDList = implode($regions, ','); - $columns = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`region`')->in($regionIDList)->fetchAll('id'); - return count($regions) . ',' . count($lanes) . ',' . count($columns); - } - - /** - * Test create default RD region. - * - * @param object $execution - * @access public - * @return object - */ - public function createRDRegionTest($execution) - { - $objectID = $this->objectModel->createRDRegion($execution); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getRegionByID($objectID); - return $object; - } - - /** - * - * Test create default RD lanes. - * - * @param int $executionID - * @param int $regionID - * @access public - * @return int - */ - public function createRDLaneTest($executionID, $regionID) - { - $this->objectModel->createRDLane($executionID, $regionID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANLANE)->where('`region`')->eq($regionID)->andWhere('`execution`')->eq($executionID)->fetchAll(); - return count($objects); - } - - /** - * Test create default RD columns. - * - * @param int $regionID - * @param int $groupID - * @param int $laneID - * @param string $laneType - * @param int $executionID - * @access public - * @return int - */ - public function createRDColumnTest($regionID, $groupID, $laneID, $laneType, $executionID) - { - $this->objectModel->createRDColumn($regionID, $groupID, $laneID, $laneType, $executionID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`region`')->eq($regionID)->andWhere('`group`')->eq($groupID)->fetchAll(); - return count($objects); - } - - /** - * Test update a region. - * - * @param int $regionID - * @param string $name - * @access public - * @return array - */ - public function updateRegionTest($regionID, $name) - { - $_POST['name'] = $name; - - $change = $this->objectModel->updateRegion($regionID); - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test update kanban lane. - * - * @param int $executionID - * @param string $laneType - * @param int $cardID - * @access public - * @return string - */ - public function updateLaneTest($executionID, $laneType, $cardID = 0) - { - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANLANE)->where('type')->ne('common')->andWhere('execution')->eq($executionID)->fetch(); - if(empty($objects)) $this->objectModel->createExecutionLane($executionID); - - $this->objectModel->updateLane($executionID, $laneType, $cardID); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('kanban')->eq($executionID)->andWhere('type')->eq($laneType)->fetchAll(); - $cards = ''; - foreach($objects as $object) $cards .= $object->cards; - $cards = preg_replace('#,+#', ',', $cards); - return $cards; - } - - /** - * Test refresh column cards. - * - * @param int $laneID - * @access public - * @return string - */ - public function refreshCardsTest($laneID) - { - $lane = $this->objectModel->getLaneByID($laneID); - $this->objectModel->refreshCards($lane); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('`lane`')->eq($laneID)->fetchAll(); - - $cards = ''; - foreach($objects as $object) $cards .= $object->id . ':' . $object->cards . '; '; - $cards = trim($cards, '; '); - $cards = str_replace(':,', ':', $cards); - $cards = str_replace(':;', ';', $cards); - return $cards; - } - - /** - * Test update a column. - * - * @param int $columnID - * @param string $name - * @param string $color - * @access public - * @return array - */ - public function updateLaneColumnTest($columnID, $name, $color) - { - $_POST['name'] = $name; - $_POST['color'] = $color; - - $column = $this->objectModel->getColumnByID($columnID); - $change = $this->objectModel->updateLaneColumn($columnID, $column); - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test activate a card. - * - * @param int $cardID - * @param int $progress - * @access public - * @return object - */ - public function activateCardTest($cardID, $progress) - { - global $tester; - $tester->post->progress = $progress; - - $this->objectModel->activateCard($cardID); - - unset($this->post); - - if(dao::isError()) return dao::getError()[0]; - - $object = $this->objectModel->getCardByID($cardID); - return $object; - } - - /** - * Test update a card. - * - * @param int $cardID - * @param array $param - * @access public - * @return array - */ - public function updateCardTest($cardID, $param) - { - global $tester; - $object = $tester->dao->select('`name`,`desc`,`assignedTo`,`begin`,`end`,`pri`,`estimate`, `progress`')->from(TABLE_KANBANCARD)->where('`id`')->eq($cardID)->fetch(); - $object->assignedTo = explode(',', $object->assignedTo); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $this->objectModel->updateCard($cardID); - if($change == array()) $change = '没有数据更新'; - unset($_POST); - - - if(dao::isError()) return dao::getError()[0]; - - return $change; - } - - /** - * Test set WIP. - * - * @param int $columnID - * @param int $limit - * @param int $WIPCount - * @access public - * @return object - */ - public function setWIPTest($columnID, $limit, $WIPCount) - { - $_POST['limit'] = $limit; - if($WIPCount == '-1') $_POST['WIPCount'] = $WIPCount; - if($WIPCount == '-1') $_POST['noLimit'] = $WIPCount; - - $this->objectModel->setWIP($columnID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getColumnByID($columnID); - return $object; - } - - /** - * Test set a lane. - * - * @param int $laneID - * @access public - * @return object - */ - public function setLaneTest($laneID, $name, $color) - { - $_POST['name'] = $name; - $_POST['color'] = $color; - - $this->objectModel->setLane($laneID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getLaneByID($laneID); - return $object; - } - - /** - * Test set kanban lane height. - * - * @param int $kanbanID - * @param string $heightType - * @param int $displayCards - * @param string $from - * @access public - * @return object - */ - public function setLaneHeightTest($kanbanID, $heightType, $displayCards, $from = 'kanban') - { - $_POST['heightType'] = $heightType; - $_POST['displayCards'] = $displayCards; - - $this->objectModel->setLaneHeight($kanbanID, $from); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $table = $tester->config->objectTables[$from]; - $object = $tester->dao->select('*')->from($table)->where('id')->eq($kanbanID)->fetch(); - return $object; - } - - /** - * Test set column width. - * - * @param int $kanbanID - * @param string $from - * @access public - * @return object - */ - public function setColumnWidthTest($kanbanID, $fluidBoard, $from = 'kanban') - { - $_POST['fluidBoard'] = $fluidBoard; - - $this->objectModel->setColumnWidth($kanbanID, $from); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $table = $tester->config->objectTables[$from]; - $object = $tester->dao->select('*')->from($table)->where('id')->eq($kanbanID)->fetch(); - return $object; - } - - /** - * Test sort kanban group; - * - * @param int $region - * @param array $groups - * @access public - * @return string - */ - public function sortGroupTest($region, $groups) - { - $this->objectModel->sortGroup($region, $groups); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_KANBANGROUP)->where('region')->eq($region)->orderBy('order_asc')->fetchAll('id'); - return implode(array_keys($objects), ','); - } - - /** - * Test move a card. - * - * @param int $cardID - * @param int $fromColID - * @param int $toColID - * @param int $fromLaneID - * @param int $toLaneID - * @param int $kanbanID - * @access public - * @return object - */ - public function moveCardTest($cardID, $fromColID, $toColID, $fromLaneID, $toLaneID, $kanbanID = 0) - { - $objects = $this->objectModel->moveCard($cardID, $fromColID, $toColID, $fromLaneID, $toLaneID, $kanbanID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('`lane`')->eq($toLaneID)->andWhere('`column`')->eq($toColID)->andWhere('`type`')->eq('common')->fetch(); - return $object; - } - - /** - * Test update a card's color. - * - * @param int $cardID - * @param string $color - * @access public - * @return object - */ - public function updateCardColorTest($cardID, $color) - { - $this->objectModel->updateCardColor($cardID, $color); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getCardByID($cardID); - return $object; - } - - /** - * Test archive a column. - * - * @param int $columnID - * @access public - * @return array - */ - public function archiveColumnTest($columnID) - { - $this->objectModel->archiveColumn($columnID); - - $object = $this->objectModel->getColumnByID($columnID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test restore a column. - * - * @param int $columnID - * @access public - * @return object - */ - public function restoreColumnTest($columnID) - { - $this->objectModel->restoreColumn($columnID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $object = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`id`')->eq($columnID)->fetch(); - return $object; - } - - /** - * Test archive a card. - * - * @param int $cardID - * @access public - * @return array - */ - public function archiveCardTest($cardID) - { - $changes = $this->objectModel->archiveCard($cardID); - - if(dao::isError()) return dao::getError(); - - return $changes; - } - - /** - * Test restore a card. - * - * @param int $cardID - * @access public - * @return array - */ - public function restoreCardTest($cardID) - { - $objects = $this->objectModel->restoreCard($cardID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function processCardsTest($columnID) - { - $column = $this->objectModel->getColumnByID($columnID); - $this->objectModel->processCards($column); - - if(dao::isError()) return dao::getError(); - - global $tester; - $nodes = $tester->dao->select('*')->from(TABLE_KANBANCOLUMN)->where('`parent`')->eq($column->parent)->andWhere('`id`')->ne($columnID)->fetchAll('id'); - $objects = $tester->dao->select('*')->from(TABLE_KANBANCELL)->where('`column`')->in(array_keys($nodes))->fetchAll(); - - $cards = ''; - foreach($objects as $object) $cards .= $object->id . ':' . $object->cards . '; '; - $cards = trim($cards, '; '); - return $cards; - } - - /** - * Test get space by id. - * - * @param int $spaceID - * @access public - * @return object - */ - public function getSpaceByIdTest($spaceID) - { - $object = $this->objectModel->getSpaceById($spaceID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get kanban group by space id list. - * - * @param string $spaceIdList - * @param string $kanbanIdList - * @access public - * @return int - */ - public function getGroupBySpaceListTest($spaceIdList, $kanbanIdList = '') - { - $objects = $this->objectModel->getGroupBySpaceList($spaceIdList, $kanbanIdList); - - if(dao::isError()) return dao::getError(); - - $count = 0; - if(empty($kanbanIdList)) - { - foreach($objects as $object) $count += count($object); - } - else - { - $count += count($objects); - } - return $count; - } - - /** - * Test get group list by region id. - * - * @param int $region - * @access public - * @return object - */ - public function getGroupListTest($region) - { - $objects = $this->objectModel->getGroupList($region); - - if(dao::isError()) return dao::getError(); - - $kanban = ''; - foreach($objects as $object) $kanban .= ',' . $object->kanban; - return $kanban; - } - - /** - * Test get column by id. - * - * @param int $columnID - * @access public - * @return object - */ - public function getColumnByIDTest($columnID) - { - $object = $this->objectModel->getColumnByID($columnID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get columns by object id. - * - * @param string $objectType - * @param int $objectID - * @param int $archived - * @param string $deleted - * @access public - * @return int - */ - public function getColumnsByObjectTest($objectType = '', $objectID = 0, $archived = 0, $deleted = '0') - { - $objects = $this->objectModel->getColumnsByObject($objectType, $objectID, $archived, $deleted); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get column ID by lane ID. - * - * @param int $laneID - * @param string $columnType - * @access public - * @return string - */ - public function getColumnIDByLaneIDTest($laneID, $columnType) - { - $object = $this->objectModel->getColumnIDByLaneID($laneID, $columnType); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get lane by id. - * - * @param int $laneID - * @access public - * @return object - */ - public function getLaneByIdTest($laneID) - { - $object = $this->objectModel->getLaneById($laneID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get object group list. - * - * @param int $executionID - * @param string $type - * @param string $groupBy - * @access public - * @return array - */ - public function getObjectGroupTest($executionID, $type, $groupBy) - { - $objects = $this->objectModel->getObjectGroup($executionID, $type, $groupBy); - - if(dao::isError()) return dao::getError(); - - $objects = implode(',', $objects); - return $objects; - } - - /** - * Test get card by id. - * - * @param int $cardID - * @access public - * @return object - */ - public function getCardByIDTest($cardID) - { - $object = $this->objectModel->getCardByID($cardID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get cards by object id. - * - * @param string $objectType - * @param int $objectID - * @param string $archived - * @param string $deleted - * @access public - * @return int - */ - public function getCardsByObjectTest($objectType = '', $objectID = 0, $archived = '0', $deleted = '0') - { - $objects = $this->objectModel->getCardsByObject($objectType, $objectID, $archived, $deleted); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get cards to import. - * - * @param int $kanbanID - * @param int $excludedID - * @param object $pager - * @access public - * @return int - */ - public function getCards2ImportTest($kanbanID = 0, $excludedID = 0, $pager = null) - { - $objects = $this->objectModel->getCards2Import($kanbanID, $excludedID, $pager); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get Kanban cards menus by execution id. - * - * @param int $executionID - * @param string $objecType - * @access public - * @return int - */ - public function getKanbanCardMenuTest($executionID, $objecType) - { - global $tester; - /* Get group objects. */ - if($objecType == 'story') $objectGroup['story'] = $tester->loadModel('story')->getExecutionStories($executionID, 0, 0, 't1.`order`_desc', 'allStory'); - if($objecType == 'bug') $objectGroup['bug'] = $tester->loadModel('bug')->getExecutionBugs($executionID); - if($objecType == 'task') $objectGroup['task'] = $tester->loadModel('execution')->getKanbanTasks($executionID, "id"); - - $objects = array(); - /* Get objects cards menus. */ - if($objecType == 'story') $objects = $this->objectModel->getKanbanCardMenu($executionID, $objectGroup['story'], 'story'); - if($objecType == 'bug') $objects = $this->objectModel->getKanbanCardMenu($executionID, $objectGroup['bug'], 'bug'); - if($objecType == 'task') $objects = $this->objectModel->getKanbanCardMenu($executionID, $objectGroup['task'], 'task'); - - if(dao::isError()) return dao::getError(); - - $count = 0; - foreach($objects as $object) $count += count($object); - return $count; - } - - /** - * Get toList and ccList. - * - * @param object $card - * @access public - * @return array - */ - public function getToAndCcListTest($card) - { - $objects = $this->objectModel->getToAndCcList($card); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check if user can execute an action. - * - * @param string $objectType - * @param int $objectID - * @param string $action - * @access public - * @return int - */ - public function isClickableTest($objectType, $objectID, $action) - { - $functionName = 'get' . $objectType . 'ById'; - $object = $this->objectModel->$functionName($objectID); - - $result = $this->objectModel->isClickable($object, $action); - - if(dao::isError()) return dao::getError(); - - return $result ? 1 : 2; - } - - /** - * Test import. - * - * @param int $kanbanID - * @access public - * @return object - */ - public function importTest($kanbanID, $import, $importObjectList) - { - $_POST['import'] = $import; - $_POST['importObjectList'] = $importObjectList; - - $this->objectModel->import($kanbanID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($kanbanID); - $object->object = !empty($object->object) ? $object->object : 0; - return $object; - } -} diff --git a/test/class/mail.class.php b/test/class/mail.class.php deleted file mode 100644 index 8b31b2cd3b..0000000000 --- a/test/class/mail.class.php +++ /dev/null @@ -1,299 +0,0 @@ -dao = $dao; - $this->tester = $tester; - $this->objectModel = $tester->loadModel('mail'); - } - - /** - * AutoDetect. - * - * @param int $email - * @access public - * @return object - */ - public function autoDetectTest($email) - { - $objects = $this->objectModel->autoDetect($email); - - if(dao::isError()) return dao::getError(); - if(!$objects->host) return '没有检测到相关信息'; - - return $objects; - } - - /** - * Get config from provider. - * - * @param int $domain - * @param int $username - * @access public - * @return object - */ - public function getConfigFromProviderTest($domain, $username) - { - $object = $this->objectModel->getConfigFromProvider($domain, $username); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Get config by MXRR. - * - * @param int $domain - * @param int $username - * @access public - * @return object - */ - public function getConfigByMXRRTest($domain, $username) - { - $object = $this->objectModel->getConfigByMXRR($domain, $username); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Get config by detecting SMTP. - * - * @param int $domain - * @param int $username - * @param int $port - * @access public - * @return object - */ - public function getConfigByDetectingSMTPTest($domain, $username, $port) - { - $object = $this->objectModel->getConfigByDetectingSMTP($domain, $username, $port); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Set MTA. - * - * @access public - * @return object - */ - public function setMTATest() - { - $object = $this->objectModel->setMTA(); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Set sendmail. - * - * @access public - * @return object - */ - public function setSendMailTest() - { - $object = $this->objectModel->setSendMail(); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - - /** - * Send. - * - * @param int $toList - * @param int $subject - * @param string $body - * @param string $ccList - * @param int $includeMe - * @param array $emails - * @access public - * @return object - */ - public function sendTest($toList, $subject, $body = '', $ccList = '', $includeMe = false, $emails = array()) - { - $object = $this->objectModel->send($toList, $subject, $body, $ccList, $includeMe, $emails); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Set CC. - * - * @param int $ccList - * @param int $emails - * @access public - * @return object - */ - public function setCCTest($ccList, $emails) - { - $this->objectModel->setCC($ccList, $emails); - - return $this->setMTATest(); - } - - /** - * Set subject. - * - * @param int $subject - * @access public - * @return object - */ - public function setSubjectTest($subject) - { - $this->objectModel->setSubject($subject); - - return $this->setMTATest(); - } - - /** - * Set body. - * - * @param int $body - * @access public - * @return object - */ - public function setBodyTest($body) - { - $this->objectModel->setBody($body); - - return $this->setMTATest(); - } - - /** - * Mail exist. - * - * @access public - * @return object - */ - public function mailExistTest() - { - $object = $this->objectModel->mailExist(); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Add queue. - * - * @param int $toList - * @param int $subject - * @param string $body - * @param string $ccList - * @param int $includeMe - * @access public - * @return object - */ - public function addQueueTest($toList, $subject, $body = '', $ccList = '', $includeMe = false) - { - $this->objectModel->addQueue($toList, $subject, $body, $ccList, $includeMe); - - if($toList and $subject) - { - $id = $this->dao->lastInsertID(); - $object = $this->dao->select('*')->from(TABLE_NOTIFY)->where('id')->eq($id)->fetch(); - } - - if(!$object) return '没有数据提交'; - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Get queue. - * - * @param string $status - * @param string $orderBy - * @param int $pager - * @access public - * @return object - */ - public function getQueueTest($status = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getQueue($status = '', $orderBy = 'id_desc', $pager = null); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get queue by id. - * - * @param int $queueID - * @access public - * @return object - */ - public function getQueueByIdTest($queueID) - { - $object = $this->objectModel->getQueueById($queueID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Merge mails. - * - * @param int $user - * @access public - * @return object - */ - public function mergeMailsTest($user) - { - $mails = $this->dao->select('*')->from(TABLE_NOTIFY) - ->where('objectType')->eq('mail') - ->andWhere('toList')->eq($user) - ->fetchAll(); - - $object = $this->objectModel->mergeMails($mails); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Get subject. - * - * @param int $objectType - * @param int $object - * @param int $title - * @param int $actionType - * @access public - * @return object - */ - public function getSubjectTest($objectType, $object, $title, $actionType) - { - $object = $this->tester->loadModel($objectType)->getByID($object); - $object = $this->objectModel->getSubject($objectType, $object, $title, $actionType); - - if(dao::isError()) return dao::getError(); - - return $object; - } -} diff --git a/test/class/message.class.php b/test/class/message.class.php deleted file mode 100644 index dae6f3a58f..0000000000 --- a/test/class/message.class.php +++ /dev/null @@ -1,122 +0,0 @@ -objectModel = $tester->loadModel('message'); - } - - public function getMessagesTest($status) - { - $objects = $this->objectModel->getMessages($status); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get objectTypes. - * - * @access public - * @return void - */ - public function getObjectTypesTest() - { - $objects = $this->objectModel->getObjectTypes(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get object actions. - * - * @access public - * @return void - */ - public function getObjectActionsTest() - { - $objects = $this->objectModel->getObjectActions(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Check send. - * - * @param int $objectType - * @param int $objectID - * @param int $actionType - * @param int $actionID - * @param string $actor - * @access public - * @return void - */ - public function sendTest($objectType, $objectID, $actionType, $actionID, $actor = '') - { - $objects = $this->objectModel->send($objectType, $objectID, $actionType, $actionID, $actor = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Save notice. - * - * @param int $objectType - * @param int $objectID - * @param int $actionType - * @param int $actionID - * @param string $actor - * @access public - * @return void - */ - public function saveNoticeTest($objectType, $objectID, $actionType, $actionID, $actor = '') - { - $objects = $this->objectModel->saveNotice($objectType, $objectID, $actionType, $actionID, $actor = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get toList. - * - * @param int $objectType - * @access public - * @return void - */ - public function getToListTest($objectType) - { - global $tester; - $table = $tester->config->objectTables[$objectType]; - $object = $tester->dao->select('*')->from($table)->where('id')->eq('1')->fetch(); - $objects = $this->objectModel->getToList($object, $objectType); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get notice todos. - * - * @access public - * @return void - */ - public function getNoticeTodosTest() - { - $objects = $this->objectModel->getNoticeTodos(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/misc.class.php b/test/class/misc.class.php deleted file mode 100644 index 1346917bc0..0000000000 --- a/test/class/misc.class.php +++ /dev/null @@ -1,60 +0,0 @@ -misc = $tester->loadModel('misc'); - } - - /** - * hello - * - * @access public - * @return void - */ - public function hello() - { - $miscs = $this->misc->hello(); - return $miscs; - } - - /** - * getTableAndStatus - * 传入参数来获取表状态 - * @param string $type - * @access public - * @return void - */ - public function getTableAndStatus($type = 'check') - { - $miscs = $this->misc->getTableAndStatus($type = 'check'); - return $miscs; - } - - /** - * getRemind - * - * @access public - * @return void - */ - public function getRemind() - { - $miscs = $this->misc->getRemind(); - return $miscs; - } - - /** - * checkOneClickPackage - * - * @access public - * @return void - */ - public function checkOneClickPackage() - { - $miscs = $this->misc->checkOneClickPackage(); - return $miscs; - } -} -?> diff --git a/test/class/my.class.php b/test/class/my.class.php deleted file mode 100644 index ed7182cd37..0000000000 --- a/test/class/my.class.php +++ /dev/null @@ -1,213 +0,0 @@ -objectModel = $tester->loadModel('my'); - } - - /** - * Function getProducts test by my - * - * @param string $type - * @access public - * @return object - */ - public function getProductsTest($type) - { - $objects = $this->objectModel->getProducts($type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getDoingProjects test by my - * - * @access public - * @return object - */ - public function getDoingProjectsTest() - { - $objects = $this->objectModel->getDoingProjects(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getOverview test by my - * - * @access public - * @return object - */ - public function getOverviewTest() - { - $objects = $this->objectModel->getOverview(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getContribute test by my - * - * @access public - * @return object - */ - public function getContributeTest() - { - $objects = $this->objectModel->getContribute(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getActions test by my - * - * @access public - * @return array - */ - public function getActionsTest() - { - $objects = $this->objectModel->getActions(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function getAssignedByMe test by my - * - * @param string $account - * @param int $limit - * @param int $pager - * @param string $orderBy - * @param int $projectID - * @param string $objectType - * @access public - * @return int - */ - public function getAssignedByMeTest($account, $limit, $pager, $orderBy, $projectID, $objectType) - { - global $tester; - $recTotal = 0; - $recPerPage = 20; - $pageID = 0; - $tester->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $objects = $this->objectModel->getAssignedByMe($account, $limit, $pager, $orderBy, $objectType); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Get testcases by search. - * - * @param int $queryID - * @param string $type - * @param string $orderBy - * @access public - * @return array - */ - public function getTestcasesBySearchTest($queryID, $type, $orderBy) - { - global $tester; - $recTotal = 0; - $recPerPage = 20; - $pageID = 0; - $tester->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $objects = $this->objectModel->getTestcasesBySearch($query, $type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tasks by search. - * - * @param string $account - * @param int $limit - * @access public - * @return array - */ - public function getTasksBySearchTest($account, $limit = 0) - { - global $tester; - $recTotal = 0; - $recPerPage = 20; - $pageID = 0; - $tester->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $objects = $this->objectModel->getTasksBySearch($account, $limit, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get stories by search. - * - * @param int $queryID - * @param string $type - * @param string $orderBy - * @access public - * @return array - */ - public function getStoriesBySearchTest($queryID, $type, $orderBy) - { - global $tester; - $recTotal = 0; - $recPerPage = 1; - $pageID = 0; - $tester->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $objects = $this->objectModel->getStoriesBySearch($queryID, $type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get requirements by search. - * - * @param int $queryID - * @param string $type - * @param string $orderBy - * @access public - * @return array - */ - public function getRequirementsBySearchTest($queryID, $type, $orderBy) - { - global $tester; - $recTotal = 0; - $recPerPage = 1; - $pageID = 0; - $tester->app->loadClass('pager', $static = true); - $pager = new pager($recTotal, $recPerPage, $pageID); - - $objects = $this->objectModel->getRequirementsBySearch($queryID, $type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - -} diff --git a/test/class/personnel.class.php b/test/class/personnel.class.php deleted file mode 100644 index 3998ec5307..0000000000 --- a/test/class/personnel.class.php +++ /dev/null @@ -1,337 +0,0 @@ -objectModel = $tester->loadModel('personnel'); - $tester->app->loadClass('dao'); - } - /** - * Get accessible personnel test - * - * @param int $programID - * @param int $deptID - * @param string $browseType - * @param int $queryID - * @access public - * @return array - */ - public function getAccessiblePersonnelTest($programID = 0, $deptID = 0, $browseType = 'all', $queryID = 0) - { - $objects = $this->objectModel->getAccessiblePersonnel($programID, $deptID, $browseType, $queryID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Check if you have permission to view the program - * - * @param int mixed $programID - * @param string mixed $account - * @access public - * @return bool - */ - public function canViewProgramTest($programID, $account) - { - $objects = $this->objectModel->canViewProgram($programID, $account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get invest test - * - * @param int $programID - * @access public - * @return array - */ - public function getInvestTest($programID = 0) - { - $objects = $this->objectModel->getInvest($programID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getInvolvedProjectsTest($projects) - { - global $tester; - $projectID = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projects)->fetchall('id'); - $objects = $this->objectModel->getInvolvedProjects($projectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get involved executions test - * - * @param array mixed $projectID - * @access public - * @return array - */ - public function getInvolvedExecutionsTest($projectID) - { - global $tester; - $project = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projectID)->fetchall('id'); - $objects = $this->objectModel->getInvolvedExecutions($project); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get project task invest test - * - * @param array mixed $projects - * @param array mixed $accounts - * @access public - * @return void - */ - public function getProjectTaskInvestTest($projectID, $accounts) - { - global $tester; - $project = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projectID)->fetchall('id'); - $objects = $this->objectModel->getProjectTaskInvest($project, $accounts); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * GetUserHoursTest - * - * @param mixed $projectID - * @param array $accounts - * @access public - * @return void - */ - public function getUserHoursTest($projectID, $accounts) - { - global $tester; - $projects = $tester->dao->select('id')->from(TABLE_PROJECT)->where('id')->in($projectID)->fetchall('id'); - $tasks = $tester->dao->select('id,status,openedBy,finishedBy,assignedTo,project')->from(TABLE_TASK) - ->where('project')->in(array_keys($projects)) - ->andWhere('deleted')->eq('0') - ->fetchAll('id'); - - /* Initialize personnel related tasks. */ - $invest = array(); - foreach($accounts as $account) - { - $invest[$account]['createdTask'] = 0; - $invest[$account]['finishedTask'] = 0; - $invest[$account]['pendingTask'] = 0; - $invest[$account]['consumedTask'] = 0; - $invest[$account]['leftTask'] = 0; - } - - $userTasks = array(); - - foreach($tasks as $task) - { - if($task->openedBy && isset($invest[$task->openedBy])) - { - $invest[$task->openedBy]['createdTask'] += 1; - $userTasks[$task->openedBy][$task->id] = $task->id; - } - - if($task->finishedBy && isset($invest[$task->finishedBy])) - { - $invest[$task->finishedBy]['finishedTask'] += 1; - $userTasks[$task->finishedBy][$task->id] = $task->id; - } - - if($task->assignedTo && $task->status == 'wait' && isset($invest[$task->assignedTo])) - { - $invest[$task->assignedTo]['pendingTask'] += 1; - $userTasks[$task->assignedTo][$task->id] = $task->id; - } - } - - $objects = $this->objectModel->getUserHours($userTasks); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get whitelist test - * - * @param int $objectID - * @param string $objectType - * @param string $orderBy - * @param string $pager - * @access public - * @return array - */ - public function getWhitelistTest($objectID = 0, $objectType = '', $orderBy = 'id_desc', $pager = '') - { - $objects = $this->objectModel->getWhitelist($objectID, $objectType, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get whitelist account test - * - * @param int $objectID - * @param string $objectType - * @access public - * @return array - */ - public function getWhitelistAccountTest($objectID = 0, $objectType = '') - { - $objects = $this->objectModel->getWhitelistAccount($objectID, $objectType); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function updateWhitelistTest($users = array(), $objectType = '', $objectID = 0, $type = 'whitelist', $source = 'add', $updateType = 'replace') - { - $objects = $this->objectModel->updateWhitelist($users, $objectType, $objectID, $type, $source, $updateType); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Add whitelist test - * - * @param string $objectType - * @param int $objectID - * @param array mixed $user - * @access public - * @return void - */ - public function addWhitelistTest($objectType = '', $objectID = 0, $user = '') - { - $users = array('accounts' => $user); - foreach($users as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->addWhitelist($objectType, $objectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete product whitelist Test - * - * @param int mixed $productID - * @param string $account - * @access public - * @return void - */ - public function deleteProductWhitelistTest($productID, $account = '') - { - global $tester; - $this->addWhitelistTest('product', $productID, array('admin')); - $tester->dao->update(TABLE_ACL)->set('source')->eq('sync')->where('objectID')->eq($productID)->andWhere('objectType')->eq('product')->exec(); - - $objects = $this->objectModel->deleteProductWhitelist($productID, $account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete program whitelist Test - * - * @param int $programID - * @param string $account - * @access public - * @return void - */ - public function deleteProgramWhitelistTest($programID, $account) - { - global $tester; - $this->addWhitelistTest('program', $programID, array($account)); - $tester->dao->update(TABLE_ACL)->set('source')->eq('sync')->where('objectID')->eq($programID)->andWhere('objectType')->eq('program')->exec(); - $objects = $this->objectModel->deleteProgramWhitelist($programID, $account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete project whitelist Test - * - * @param int mixed $objectID - * @param string mixed $account - * @access public - * @return void - */ - public function deleteProjectWhitelistTest($objectID, $account) - { - global $tester; - $this->addWhitelistTest('project', $objectID, array($account)); - $tester->dao->update(TABLE_ACL)->set('source')->eq('sync')->where('objectID')->eq($objectID)->andWhere('objectType')->eq('project')->exec(); - $objects = $this->objectModel->deleteProjectWhitelist($objectID, $account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete execution whitelist Test - * - * @param int mixed $executionID - * @param string $account - * @access public - * @return void - */ - public function deleteExecutionWhitelistTest($executionID, $account = '') - { - global $tester; - $this->addWhitelistTest('sprint', $executionID, array($account)); - $tester->dao->update(TABLE_ACL)->set('source')->eq('sync')->where('objectID')->eq($executionID)->andWhere('objectType')->eq('sprint')->exec(); - $objects = $this->objectModel->deleteExecutionWhitelist($executionID, $account); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Delete whitelist Test - * - * @param array $users - * @param string $objectType - * @param int $objectID - * @param int $groupID - * @access public - * @return void - */ - public function deleteWhitelistTest($users = array(), $objectType = 'program', $objectID = 0, $groupID = 0) - { - global $tester; - $this->addWhitelistTest($objectType, $objectID, $users); - $tester->dao->update(TABLE_ACL)->set('source')->eq('sync')->where('objectID')->eq($objectID)->andWhere('objectType')->eq($objectType)->exec(); - $objects = $this->objectModel->deleteWhitelist($users, $objectType, $objectID, $groupID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/pipeline.class.php b/test/class/pipeline.class.php deleted file mode 100644 index 2fd000a20b..0000000000 --- a/test/class/pipeline.class.php +++ /dev/null @@ -1,126 +0,0 @@ -objectModel = $tester->loadModel('pipeline'); - } - - /** - * Get a pipeline by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByIDTest($id) - { - $objects = $this->objectModel->getByID($id); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get pipeline list. - * - * @param string $type jenkins|gitlab - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getListTest($type = 'jenkins', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get pipeline pairs - * - * @param int $data - * @access public - * @return array - */ - public function getPairs($data) - { - $objects = $this->objectModel->getPairs($data['type']); - - if(empty($objects)) return '没有获取到数据'; - if(isset($data['id'])) return $objects[$data['id']]; - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Create a pipeline. - * - * @param int $type - * @param int $param - * @access public - * @return void - */ - public function createTest($type, $param) - { - foreach($param as $k => $v) $_POST[$k] = $v; - $objects = $this->objectModel->create($type); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($objects); - - return $objects; - } - - /** - * Update a pipeline. - * - * @param int $id - * @access public - * @return bool - */ - public function updateTest($id) - { - $objects = $this->objectModel->update($id); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($id); - - return $objects; - } - - /** - * Delete one record. - * - * @param string $id the id to be deleted - * @param string $object the action object - * @access public - * @return int - */ - public function deleteTest($id, $object = 'gitlab') - { - $objects = $this->objectModel->delete($id, $object = 'gitlab'); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getById($id); - - return $objects; - } -} diff --git a/test/class/product.class.php b/test/class/product.class.php deleted file mode 100644 index 277b07545b..0000000000 --- a/test/class/product.class.php +++ /dev/null @@ -1,1099 +0,0 @@ -objectModel = $tester->loadModel('product'); - $tester->app->loadClass('dao'); - } - - /** - * Test create a product. - * - * @param array $param - * @access public - * @return object - */ - public function createObject($param = array()) - { - global $createFields; - $whitelist = array(); - $createFields = array('program' => 1, 'line' => 0, 'lineName' => '', 'newLine' => 0, 'name' => '', 'code' => '', 'PO' => 'admin', 'QD' => '', 'RD' => '', - 'reviewer' => '', 'type' => 'normal', 'status' => 'normal', 'desc' => '', 'acl' => 'open', 'uid' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->objectModel->getByID($objectID); - return $object; - } - } - - /** - * Test get the latest project of the product. - * - * @param mixed $productID - * @access public - * @return object - */ - public function testGetLatestProject($productID) - { - $project = $this->objectModel->getLatestProject($productID); - if($project == false) return '没有数据'; - return $project; - } - - /** - * Test get all products. - * - * @param int $programID - * @access public - * @return array - */ - public function getAllProducts($programID) - { - return $this->objectModel->getList($programID); - } - - /** - * Test get all products count. - * - * @param int $programID - * @access public - * @return int - */ - public function getAllProductsCount($programID) - { - return count($this->getAllProducts($programID)); - } - - /** - * Test get noclosed products. - * - * @param int $programID - * @access public - * @return array - */ - public function getNoclosedProducts($programID) - { - return $this->objectModel->getList($programID, 'noclosed'); - } - - /** - * Test get noclosed products count. - * - * @param int $programID - * @access public - * @return int - */ - public function getNoclosedProductsCount($programID) - { - return count($this->getNoclosedProducts($programID)); - } - - /** - * Test get closed products. - * - * @param int $programID - * @access public - * @return array - */ - public function getClosedProducts($programID) - { - return $this->objectModel->getList($programID, 'closed'); - } - - /** - * Test get closed products count. - * - * @param int $programID - * @access public - * @return int - */ - public function getClosedProductsCount($programID) - { - return count($this->getClosedProducts($programID)); - } - - /** - * Test get involved products. - * - * @param int $programID - * @access public - * @return array - */ - public function getInvolvedProducts($programID) - { - return $this->objectModel->getList($programID, 'involved'); - } - - /** - * Test get involved products count. - * - * @param int $programID - * @access public - * @return int - */ - public function getInvolvedProductsCount($programID) - { - return count($this->getInvolvedProducts($programID)); - } - - /** - * Test get products by line. - * - * @param int $programID - * @param int $line - * @access public - * @return array - */ - public function getProductsByLine($programID, $line = 0) - { - return $this->objectModel->getList($programID, 'all', 0, $line); - } - - /** - * Test get products count by line. - * - * @param int $programID - * @param int $line - * @access public - * @return int - */ - public function countProductsByLine($programID, $line = 0) - { - return count($this->getProductsByLine($programID, $line)); - } - - /** - * Test get product list. - * - * @param int $programID - * @param string $status - * @param int $line - * @access public - * @return array - */ - public function getProductList($programID, $status = 'all', $line = 0) - { - return $this->objectModel->getList($programID, $status, 0, $line); - } - - /** - * Test get product count. - * - * @param int $programID - * @param string $status - * @param int $line - * @access public - * @return int - */ - public function getProductCount($programID, $status = 'all', $line = 0) - { - return count($this->getProductList($programID, $status, $line)); - } - - /** - * Test get product pairs. - * - * @param int $programID - * @access public - * @return array - */ - public function getProductPairs($programID) - { - $pairs = $this->objectModel->getPairs('', $programID); - if($pairs == array()) return '没有数据'; - return $pairs; - } - - /** - * Test get product pairs count. - * - * @param int $programID - * @access public - * @return int - */ - public function getProductPairsCount($programID) - { - $pairsCount = count($this->getProductPairs($programID)); - if($pairsCount == '没有数据') return '0'; - return $pairsCount; - } - - /** - * Test get all product pairs. - * - * @param int $programID - * @access public - * @return void - */ - public function getAllPairs($programID) - { - $pairs = $this->objectModel->getPairs('all', $programID); - if($pairs == array()) return '没有数据'; - return $pairs; - } - - /** - * Test get all product count. - * - * @param int $programID - * @access public - * @return int - */ - public function getAllPairsCount($programID) - { - $pairsCount = count($this->getAllPairs($programID)); - if($pairsCount == '没有数据') return '0'; - return $pairsCount; - } - - /** - * Test get noclosed product pairs. - * - * @param int $programID - * @access public - * @return array - */ - public function getNoclosedPairs($programID) - { - $pairs = $this->objectModel->getPairs('noclosed', $programID); - if($pairs == array()) return '没有数据'; - return $pairs; - } - /** - * Test get noclosed pairs count. - * - * @param int $programID - * @access public - * @return int - */ - public function getNoclosedPairsCount($programID) - { - $pairsCount = count($this->getNoclosedPairs($programID)); - if($pairsCount == '没有数据') return '0'; - return $pairsCount; - } - - /** - * Test get product pairs by order. - * - * @param int $programID - * @param string $orderBy - * @param string $mode - * @access public - * @return array - */ - public function getProductPairsByOrder($programID, $orderBy = 'id_desc', $mode = '') - { - $this->objectModel->orderBy = $orderBy; - $pairs = $this->objectModel->getPairs($mode, $programID); - return checkOrder($pairs, $orderBy); - } - - /** - * Test get all projects by product. - * - * @param int $productID - * @access public - * @return array - */ - public function getAllProjectsByProduct($productID) - { - $projects = $this->objectModel->getProjectListByProduct($productID, 'all'); - if($projects == array()) return '没有数据'; - return $projects; - } - - /** - * Test get projects by status. - * - * @param int $productID - * @param string $status - * @access public - * @return array - */ - public function getProjectsByStatus($productID, $status) - { - $projects = $this->objectModel->getProjectListByProduct($productID, $browseType); - if($projects == array()) return '没有数据'; - return $projects; - } - - /** - * Test get project pairs by product id. - * - * @param int $productID - * @access public - * @return array - */ - public function getProjectPairsByProductID($productID) - { - $projects = $this->objectModel->getProjectPairsByProduct($productID, 0, 0); - if($projects == array()) return '没有数据'; - return $projects; - } - - /** - * Test get append project. - * - * @param int $projectID - * @access public - * @return array - */ - public function getAppendProject($projectID) - { - $project = $this->objectModel->getProjectPairsByProduct(10086, 0, $projectID); - if($project == array()) return '没有数据'; - return $project; - } - - /** - * Test judge an action is clickable or not. - * - * @param int $productID - * @param string $status - * @access public - * @return string - */ - public function testIsClickable($productID, $status) - { - $product = $this->objectModel->getById($productID); - $isClick = $this->objectModel->isClickable($product, $status); - return $isClick == false ? 'false' : 'true'; - } - - /** - * Test update a product. - * - * @param string $module - * @param int $objectID - * @param array $param - * @access public - * @return array - */ - public function updateObject($module, $objectID, $param = array()) - { - global $tester; - $objectModel = $tester->loadModel($module); - - $object = $objectModel->getById($objectID); - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $objectModel->update($objectID); - if($change == array()) $change = '没有数据更新'; - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } - } - - /** - * Test check privilege. - * - * @param int $productID - * @access public - * @return int - */ - public function checkPrivTest($productID) - { - $object = $this->objectModel->checkPriv($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object ? 1 : 2; - } - } - - /** - * Test get product by id. - * - * @param int $productID - * @access public - * @return object - */ - public function getByIdTest($productID) - { - $object = $this->objectModel->getById($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test get product by id list. - * - * @param array $productIDList - * @access public - * @return array - */ - public function getByIdListTest($productIDList) - { - $objects = $this->objectModel->getByIdList($productIDList); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get product pairs by project. - * - * @param int $productID - * @param string $status - * @access public - * @return array - */ - public function getProductPairsByProjectTest($projectID, $status = 'all') - { - $objects = $this->objectModel->getProductPairsByProject($projectID, $status); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get product pairs by project model. - * - * @param string $model - * @access public - * @return int - */ - public function getPairsByProjectModelTest($model) - { - $objects = $this->objectModel->getPairsByProjectModel($model); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($objects); - } - } - - /** - * Test get products by project. - * - * @param int $projectID - * @param string $status - * @access public - * @return array - */ - public function getProductsTest($projectID, $status) - { - $objects = $this->objectModel->getProducts($projectID, $status); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get product id by project. - * - * @param int $projectID - * @access public - * @return int - */ - public function getProductIDByProjectTest($projectID) - { - $object = $this->objectModel->getProductIDByProject($projectID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } - - /** - * Test get ordered products. - * - * @param string $status - * @access public - * @return int - */ - public function getOrderedProductsTest($status) - { - $objects = $this->objectModel->getOrderedProducts($status); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($objects); - } - } - - /** - * Test get Multi-branch product pairs. - * - * @param int $programID - * @access public - * @return array - */ - public function getMultiBranchPairsTest($programID) - { - $objects = $this->objectModel->getMultiBranchPairs($programID); - - $title = ''; - foreach($objects as $object) $title .= ',' . $object; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $title; - } - } - - /** - * Test batch update products. - * - * @param array $param - * @param int $productID - * @access public - * @return void - */ - public function batchUpdateTest($param, $productID) - { - $batchUpdateFields['productIDList'] = array('1' => '1', '2' => '2', '3' => '3'); - $batchUpdateFields['programs'] = array('1' => '', '2' => '1', '3' => '2'); - $batchUpdateFields['names'] = array('1' => '正常产品1', '2' => '正常产品2', '3' => '正常产品3'); - $batchUpdateFields['lines'] = array('1' => '0', '2' => '1', '3' => '2'); - $batchUpdateFields['POs'] = array('1' => 'po1', '2' => 'po2', '3' => 'po3'); - $batchUpdateFields['QDs'] = array('1' => 'test1', '2' => 'test2', '3' => 'test3'); - $batchUpdateFields['RDs'] = array('1' => 'dev1', '2' => 'dev2', '3' => 'dev3'); - $batchUpdateFields['types'] = array('1' => 'normal', '2' => 'normal', '3' => 'normal'); - $batchUpdateFields['statuses'] = array('1' => 'normal', '2' => 'normal', '3' => 'normal'); - $batchUpdateFields['descs'] = array('1' => '<div> <p><h1>一、禅道项目管理软件是做什么的?</h1> 禅道由 青岛易软天创网络科技有限公司开发,国产开源项目管理软件。它集产品管理、项目管理、质量管理、文档管理、组织管理和事务管理于一体,是一款专业的研发项目管理软件,完整覆盖了研发项目管理的核心流程。禅道管理思想注重实效,功能完备丰富,操作简洁高效,界面美观大方,搜索功能强大,统计报表丰富多样,软件架构合理,扩展灵活,有完善的API可以调用。禅道,专注研发项目管理 </p> <p>我是数字符号23@#$%#^$ </p> <p>我是英文dashcuscbrewg </p> </div>', '2' => '<div> <p><h1>一、禅道项目管理软件是做什么的?</h1> 禅道由 青岛易软天创网络科技有限公司开发,国产开源项目管理软件。它集产品管理、项目管理、质量管理、文档管理、组织管理和事务管理于一体,是一款专业的研发项目管理软件,完整覆盖了研发项目管理的核心流程。禅道管理思想注重实效,功能完备丰富,操作简洁高效,界面美观大方,搜索功能强大,统计报表丰富多样,软件架构合理,扩展灵活,有完善的API可以调用。禅道,专注研发项目管理 </p> <p>我是数字符号23@#$%#^$ </p> <p>我是英文dashcuscbrewg </p> </div>', '3' => 'i<div> <p><h1>一、禅道项目管理软件是做什么的?</h1> 禅道由 青岛易软天创网络科技有限公司开发,国产开源项目管理软件。它集产品管理、项目管理、质量管理、文档管理、组织管理和事务管理于一体,是一款专业的研发项目管理软件,完整覆盖了研发项目管理的核心流程。禅道管理思想注重实效,功能完备丰富,操作简洁高效,界面美观大方,搜索功能强大,统计报表丰富多样,软件架构合理,扩展灵活,有完善的API可以调用。禅道,专注研发项目管理 </p> <p>我是数字符号23@#$%#^$ </p> <p>我是英文dashcuscbrewg </p> </div>'); - $batchUpdateFields['acls'] = array('1' => 'open', '2' => 'open', '3' => 'open'); - - foreach($batchUpdateFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $changes = $this->objectModel->batchUpdate(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $changes[$productID]; - } - } - - /** - * Test close a product. - * - * @param int $productID - * @access public - * @return array - */ - public function closeTest($productID) - { - $changes = $this->objectModel->close($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $changes; - } - } - - /** - * Test manage line. - * - * @param array $param - * @access public - * @return void - */ - public function manageLineTest($param, $moduleID = 0) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->manageLine(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - global $tester; - - $moduleID = $moduleID ? $moduleID : $tester->dao->select('id')->from(TABLE_MODULE)->orderby('id desc')->fetch()->id; - $object = $tester->dao->select('*')->from(TABLE_MODULE)->where('id')->eq($moduleID)->fetch(); - - return $object; - } - } - - /** - * Test get stories. - * - * @param int $productID - * @param int $branch - * @param string $browseType - * @param int $queryID - * @param int $moduleID - * @access public - * @return array - */ - public function getStoriesTest($productID, $branch, $browseType, $queryID, $moduleID) - { - $objects = $this->objectModel->getStories($productID, $branch, $browseType, $queryID, $moduleID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return count($objects); - } - } - - /** - * Test batch get story stage. - * - * @param array $stories - * @access public - * @return array - */ - public function batchGetStoryStageTest($stories) - { - $objects = $this->objectModel->batchGetStoryStage($stories); - - foreach($objects as $id => $object) $stages[$id] = $object[0]->stage; - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $stages; - } - } - - /** - * Test get project stats by product. - * - * @param int $productID - * @param string $browseType - * @access public - * @return array - */ - public function getProjectStatsByProductTest($productID, $browseType = 'all') - { - $objects = $this->objectModel->getProjectStatsByProduct($productID, $browseType); - - foreach($objects as $object) $projects[$object->id] = $object->name; - - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return isset($projects) ? $projects : array(); - } - } - - /** - * Test get executions by product and project. - * - * @param int $productID - * @param int $projectID - * @access public - * @return array - */ - public function getExecutionPairsByProductTest($productID, $projectID = 0) - { - $objects = $this->objectModel->getExecutionPairsByProduct($productID, 0, 'id_asc', $projectID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get all executions by product. - * - * @param int $productID - * @access public - * @return array - */ - public function getAllExecutionPairsByProductTest($productID) - { - $objects = $this->objectModel->getAllExecutionPairsByProduct($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get roadmap of a proejct. - * - * @param int $productID - * @access public - * @return array - */ - public function getRoadmapTest($productID) - { - $objects = $this->objectModel->getRoadmap($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test process roadmap. - * - * @param int $productID - * @access public - * @return array - */ - public function processRoadmapTest($productID) - { - global $tester; - $releases = $tester->loadModel('release')->getList($productID, '0'); - - $roadmapGroups = array('2022' => array($releases)); - - $objects = $this->objectModel->processRoadmap($roadmapGroups); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get team members of a product from projects. - * - * @param int $productID - * @access public - * @return array - */ - public function getTeamMemberPairsTest($productID) - { - $product = $this->objectModel->getByID($productID); - $objects = $this->objectModel->getTeamMemberPairs($product); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get product stat by id. - * - * @param int $productID - * @access public - * @return array - */ - public function getStatByIDTest($productID) - { - $objects = $this->objectModel->getStatByID($productID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test get product stats. - * - * @access public - * @return array - */ - public function getStatsTest() - { - $objects = $this->objectModel->getStats(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test stats for product kanban. - * - * @param string $type - * @param bool $getCount - * @access public - * @return array - */ - public function getStats4KanbanTest($type, $getCount = false) - { - $objects = $this->objectModel->getStats4Kanban(); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $getCount ? count($objects[$type]) : $objects[$type]; - } - } - - /** - * Test get product line pairs. - * - * @param int $programID - * @access public - * @return array - */ - public function getLinePairsTest($programID) - { - $objects = $this->objectModel->getLinePairs($programID); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } - } - - /** - * Test statistics program data. - * - * @param object $productStats - * @param int $index - * @access public - * @return array - */ - public function statisticProgramTest($productStats, $index) - { - $objects = $this->objectModel->statisticProgram($productStats); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects[$index][$index]['products']; - } - } - - /** - * Test statistics product data. - * - * @param object $product - * @access public - * @return array - */ - public function statisticDataTest($product) - { - if($product->line) - { - /* Line name. */ - $productStructure[$product->program][$product->line]['lineName'] = $product->lineName; - $data = $this->objectModel->statisticData('line', $productStructure, $product); - } - - if($product->program) - { - /* Init vars. */ - /* Program name. */ - $productStructure[$product->program]['programName'] = $product->programName; - $data = $this->objectModel->statisticData('program', $productStructure, $product); - } - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $data; - } - } - - /** - * Test change the projects set of the program. - * - * @param int $productID - * @access public - * @return object - */ - public function updateProjectsTest($productID) - { - $singleLinkProjects = array(); - $multipleLinkProjects = array(); - - global $tester; - /* Get the projects linked with this product. */ - $projectPairs = $tester->dao->select('t2.id,t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') - ->where('t1.product')->eq($productID) - ->andWhere('t2.type')->eq('project') - ->andWhere('t2.deleted')->eq('0') - ->fetchPairs(); - - $projects = ','; - if(!empty($projectPairs)) - { - foreach($projectPairs as $projectID => $projectName) - { - $projects .= $projectID . ','; - $products = $tester->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs(); - if(count($products) == 1) - { - $singleLinkProjects[$projectID] = $projectName; - } - - if(count($products) > 1) - { - $multipleLinkProjects[$projectID] = $projectName; - } - } - } - - $_POST['changeProjects'] = $projects; - - $product = $this->objectModel->getById($productID); - $_POST['program'] = $product->program == 1 ? 2 : 1; - - $this->objectModel->updateProjects($productID, $singleLinkProjects, $multipleLinkProjects); - - $object = $tester->dao->select('t2.id,t2.parent,t2.path')->from(TABLE_PROJECTPRODUCT)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') - ->where('t1.product')->eq($productID) - ->andWhere('t2.type')->eq('project') - ->andWhere('t2.deleted')->eq('0') - ->fetchAll(); - - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } - } -} diff --git a/test/class/productplan.class.php b/test/class/productplan.class.php deleted file mode 100644 index fc790c2d99..0000000000 --- a/test/class/productplan.class.php +++ /dev/null @@ -1,461 +0,0 @@ -productplan = $tester->loadModel('productplan'); - } - - /** - * Get by ID plan - * - * @param int mixed $planID - * @param bool mixed $setImgSize - * @access public - * @return array - */ - public function getByIDPlan($planID, $setImgSize = false) - { - $productplans = $this->productplan->getByID($planID, $setImgSize = false); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get by ID list - * - * @param array(int) mixed $planIDList - * @access public - * @return array - */ - public function getByIDList($planIDList) - { - $productplans = $this->productplan->getByIDList($planIDList); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get last - * - * @param int mixed $productID - * @param int $branch - * @param int $parent - * @access public - * @return array - */ - public function getLast($productID, $branch = 0, $parent = 0) - { - $productplans = $this->productplan->getLast($productID, $parent); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get list - * - * @param int $product - * @param int $branch - * @param string $browseType - * @param mixed $pager - * @param string $orderBy - * @param string $param - * @access public - * @return array - */ - public function getList($product = 0, $branch = 0, $browseType = 'undone', $pager = null, $orderBy = 'begin_desc', $param = '') - { - $productplans = $this->productplan->getList($product, $branch, $browseType, $pager, $orderBy, $param); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get pairs - * - * @param int $product - * @param string $branch - * @param string $expired - * @param bool mixed $skipParent - * @access public - * @return array - */ - public function getPairs($product, $branch = '', $expired = '', $skipParent = false) - { - $productplans = $this->productplan->getPairs($product, $branch = '', $expired = '', $skipParent = false); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get pairs for story - * - * @param mrray|int mixed $product - * @param int mixed $branch - * @param string mixed $param - * @access public - * @return count - */ - public function getPairsForStory($product, $branch, $param) - { - $productplans = $this->productplan->getPairsForStory($product, $branch, $param); - if(dao::isError()) return dao::getError(); - return count($productplans) - 1; - } - - /** - * Get for products - * - * @param array(int) mixed $products - * @access public - * @return count - */ - public function getForProducts($products) - { - $productplans = $this->productplan->getForProducts($products); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get group by product - * - * @param array(int) mixed $products - * @param string mixed $param - * @param string $field - * @param string $orderBy - * @access public - * @return count - */ - public function getGroupByProduct($products, $param, $field = 'name', $orderBy = 'id_desc') - { - $productplans = $this->productplan->getGroupByProduct($products, $param, $field, $orderBy); - if(dao::isError()) return dao::getError(); - return count($productplans); - } - - /** - * Get children - * - * @param int mixed $planID - * @access public - * @return count - */ - public function getChildren($planID) - { - $productplans = $this->productplan->getChildren($planID); - if(dao::isError()) return dao::getError(); - return count($productplans); - } - - /** - * Get plans by stories - * - * @param array(int) mixed $storyIdList - * @access public - * @return count - */ - public function getPlansByStories($storyIdList) - { - $productplans = $this->productplan->getPlansByStories($storyIdList); - if(dao::isError()) return dao::getError(); - return count($productplans); - } - - /** - * Get branch plan pairs - * - * @param int mixed $productID - * @param int mixed $branches - * @access public - * @return array - */ - public function getBranchPlanPairs($productID, $branches) - { - $productplans = $this->productplan->getBranchPlanPairs($productID, $branches); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Get top plan pairs - * - * @param int $productID - * @param int $branch - * @param int $exclude - * @access public - * @return array - */ - public function getTopPlanPairsTest($param) - { - $productID = $param['productID']; - $branch = $param['branch']; - $exclude = $param['exclude']; - - $planPairs = $this->productplan->getTopPlanPairs($productID, $branch, $exclude); - - if(dao::isError()) return dao::getError(); - - return $planPairs; - } - - /** - * Create - * - * @param array mixed $param - * @access public - * @return array - */ - public function create($param) - { - //初始化传的参数,这里可以设置默认值 - $createPlan = array('title' => '', 'begin' => '', 'end' => '', 'delta' => '', 'desc' => '', 'uid' => '', 'product' => '', 'parent' => ''); - //设置foreach循环,将初始化参数传给全局变量$_POST中,通过此方式将传的参数提供给源码create方法 - foreach($createPlan as $field => $defaultvalue) $_POST[$field] = $defaultvalue; - //二次遍历数组将此方法的形参传入$_POST中,这行可以替换掉初始化参数,做到以传入参数为最终结果的目的。同时不传参数的话取默认值 - foreach($param as $key => $value) $_POST[$key] = $value; - //这行代码的作用是调用源码中的方法(参数通过$_POST直接取,具体原理可以不知道) - $productPlans = $this->productplan->create(); - //将方法返回内容返回 - if(dao::isError()) return dao::getError(); - return $productPlans; - } - - /** - * Update - * - * @param int mixed $planID - * @param array mixed $values - * @access public - * @return array - */ - public function update($planID, $values) - { - $updatePlan = array('title' => '', 'status' => '', 'begin' => '', 'end' => '', 'desc' => '', 'uid' => '', 'product' => ''); - - foreach($updatePlan as $field => $defaultvalue) $_POST[$field] = $defaultvalue; - foreach($values as $key =>$value) $_POST[$key] = $value; - - $productplans = $this->productplan->update($planID); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Update status - * - * @param int mixed $planID - * @param string $status - * @param string $action - * @access public - * @return array - */ - public function updateStatus($planID, $status = '', $action = '') - { - $productplans = $this->productplan->updateStatus($planID, $status, $action); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Update parent status - * - * @param int mixed $parentId - * @access public - * @return bool - */ - public function updateParentStatus($parentId) - { - $productplans = $this->productplan->updateParentStatus($parentId); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Batch update - * - * @param int mixed $productId - * @access public - * @return array(array) - */ - public function batchUpdate($productId, $bratch) - { - $batch = array('id' => array(), 'title' => array(), 'begin' => array(), 'end' => array()); - - foreach($batch as $field => $defaultvalue) $_POST[$field] = $defaultvalue; - foreach($bratch as $key => $value) $_POST[$key] = $value; - - $productplans = $this->productplan->batchUpdate($productId); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Batch change status - * - * @param string mixed $status - * @access public - * @return array - */ - public function batchChangeStatus($status, $planIDList = array('planIDList' => array(4, 5))) - { - $planID = $planIDList; - - foreach($planID as $field => $defaultvalue) $_POST[$field] = $defaultvalue; - - $productplans = $this->productplan->batchChangeStatus($status); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Change parent field - * - * @param int mixed $planID - * @access public - * @return true - */ - public function changeParentField($planID) - { - $productplans = $this->productplan->changeParentField($planID); - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Link story - * - * @param int mixed $planID - * @param array(stories => array())mixed $storyID - * @access public - * @return void - */ - public function linkStory($planID, $storyID) - { - - foreach($storyID as $key => $value) $_POST[$key] = $value; - - $productplans = $this->productplan->linkStory($planID); - - if(dao::isError()) return dao::getError(); - return $productplans; - } - - /** - * Unlink story - * - * @param int mixed $storyID - * @param int mixed $planID - * @access public - * @return void - */ - public function unlinkStory($storyID, $planID) - { - $productPlans = $this->productplan->unlinkStory($storyID, $planID); - - if(dao::isError()) return dao::getError(); - - return $productPlans; - } - - /** - * Link bug - * - * @param int mixed $planID - * @param array mixed $bugID - * @access public - * @return void - */ - public function linkBug($planID, $bugID) - { - - foreach($bugID as $key => $value) $_POST[$key] = $value; - - $productPlans = $this->productplan->linkBug($planID); - - if(dao::isError()) return dao::getError(); - - return $productPlans; - } - - /** - * Unlink bug - * - * @param int mixed $bugID - * @access public - * @return void - */ - public function unlinkBug($bugID) - { - $productplans = $this->productplan->unlinkBug($bugID); - - if(dao::isError()) return dao::getError(); - - return $productplans; - } - - /** - * Link project - * - * @param $projectID mixed $projectID - * @param $newPlans mixed $newPlans - * @access public - * @return void - */ - public function linkProject($projectID, $newPlans) - { - $productplans = $this->productplan->linkProject($projectID, $newPlans); - - if(dao::isError()) return dao::getError(); - - return $productplans; - } - - /** - * Reorder 4 children - * - * @param array mixed $plans - * @access public - * @return array - */ - public function reorder4Children($plans) - { - $plan = $this->productplan->dao->select('*')->from(TABLE_PRODUCTPLAN) - ->where('id')->in($plans) - ->andWhere('deleted')->eq(0) - ->fetchAll('id'); - - $productplans = $this->productplan->reorder4Children($plan); - - if(dao::isError()) return dao::getError(); - - return $productplans; - } - - /** - * Is clickable - * - * @param int mixed $planID - * @param string mixed $action - * @access public - * @return void - */ - public function isClickable($planID, $action) - { - $plan = $this->productplan->dao->select('*')->from(TABLE_PRODUCTPLAN) - ->where('id')->eq($planID) - ->andWhere('deleted')->eq(0) - ->fetchAll('id'); - - $plans = $plan[$planID]; - $productplans = $this->productplan->isClickable($plans, $action); - - if(dao::isError()) return dao::getError(); - - return $productplans; - } - -} -?> diff --git a/test/class/program.class.php b/test/class/program.class.php deleted file mode 100644 index 2871829ce6..0000000000 --- a/test/class/program.class.php +++ /dev/null @@ -1,451 +0,0 @@ -program = $tester->loadModel('program'); - } - - /** - * Get switcher. - * - * @param int $programID - * @access public - * @return string - */ - public function getSwitcherTest($programID = 0) - { - return $this->program->getSwitcher($programID); - } - - /** - * Get list by search. - * - * @param string $orderBy - * @param int $queryID - * @param string $sql - * @access public - * @return array - */ - public function getListBySearchTest($orderBy = 'id_asc', $queryID = 0, $sql = '') - { - if(!empty($sql)) $_SESSION['programQuery'] = $sql; - - return $this->program->getListBySearch($orderBy, $queryID); - } - - /** - * Get pairs. - * - * @param bool $isQueryAll - * @param string $orderBy - * @access public - * @return array - */ - public function getPairsTest($isQueryAll = false, $orderBy = 'id_desc') - { - return $this->program->getPairs($isQueryAll, $orderBy); - } - - /** - * Get pairs by id list. - * - * @param string $programIDList - * @access public - * @return array - */ - public function getPairsByListTest($programIDList = '') - { - return $this->program->getPairsByList($programIDList); - } - - /** - * Get parent pairs. - * - * @param string $model - * @param string $mode - * @param bool $showRoot - * @access public - * @return array - */ - public function getParentPairsTest($model = '', $mode = 'noclosed', $showRoot = true) - { - return $this->program->getParentPairs($model, $mode, $showRoot); - } - - /** - * Get the product associated with the program. - * - * @param int $programID - * @param string $mode - * @param string $status - * @param string|array $append - * @param int|string $shadow - * @param bool $withProgram - * @access public - * @return array - */ - public function getProductPairsTest($programID = 0, $mode = 'assign', $status = 'all', $append = '', $shadow = 0, $withProgram = false) - { - return $this->program->getProductPairs($programID, $mode, $status, $append, $shadow, $withProgram); - } - - /** - * Test create program. - * - * @param array $data - * @access public - * @return object - */ - public function createTest($data) - { - $_POST = $data; - - $programID = $this->program->create(); - - if(dao::isError()) return array('message' => dao::getError()); - - $program = $this->program->getByID($programID); - - return $program; - } - - /** - * Get parent PM. - * - * @param array $programIdList - * @access public - * @return array - */ - public function getParentPMTest($programIdList) - { - return $this->program->getParentPM($programIdList); - } - - /** - * Create stakeholder. - * - * @param int $programID - * @param array $accounts - * @access public - * @return void - */ - public function createStakeholderTest($programID, $accounts = array()) - { - $_POST['accounts'] = $accounts; - $stakeHolder = $this->program->createStakeholder($programID); - - return $this->program->getStakeholdersByPrograms($programID); - } - - /** - * Create default program. - * - * @access public - * @return void - */ - public function createDefaultProgramTest() - { - $programID = $this->program->createDefaultProgram(); - - return $programID > 0; - } - - /** - * Test get list. - * - * @param mixed $status - * @param string $orderBy - * @param object $pager - * @param string $type top|child - * @param mixed $idList - * @access public - * @return void - */ - public function getListTest($status = 'all', $orderBy = 'id_asc', $pager = NULL, $type = '', $idList = '') - { - $this->program->cookie->showClosed = 'ture'; - $programs = $this->program->getList($status, $orderBy, $pager, $type, $idList); - - if(dao::isError()) return array('message' => dao::getError()); - - return $programs; - } - - - /** - * Test update program. - * - * @param mixed $proguamID - * @param mixed $data - * @access public - * @return void - */ - public function updateTest($programID, $data) - { - $_POST = $data; - $this->program->update($programID); - if(dao::isError()) return array('message' => dao::getError()); - - return $this->program->getByID($programID); - } - - /** - * Get program by id. - * - * @param int $proguamID - * @access public - * @return object - */ - public function getByIDTest($programID) - { - $program = $this->program->getByID($programID); - if(dao::isError()) return array('message' => dao::getError()); - - return $program; - } - - /** - * Get budget left. - * - * @param int $programID - * @access public - * @return int - */ - public function getBudgetLeftTest($programID) - { - $program = $this->program->getByID($programID); - $budget = $this->program->getBudgetLeft($program); - - if(dao::isError()) return array('message' => dao::getError()); - - return $budget; - } - - /** - * Set tree path. - * - * @param int $programID - * @access public - * @return void - */ - public function setTreePathTest($programID) - { - $this->program->setTreePath($programID); - $program = $this->program->getByID($programID); - - return $program; - } - - /** - * Get children. - * - * @param int $programID - * @access public - * @return int - */ - public function getChildrenTest($programID) - { - return $this->program->getChildren($programID); - } - - /** - * Check clickable. - * - * @param int $programID - * @param string $status - * @access public - * @return int - */ - public function isClickableTest($programID, $status) - { - return $this->program->isClickable($programID, $status); - } - - /** - * Has unfinished. - * - * @param int $programID - * @access public - * @return int - */ - public function hasUnfinishedTest($programID) - { - $program = $this->program->getByID($programID); - return $this->program->hasUnfinished($program); - } - - /* - * get involved programs. - * - * @param string $account - * @access public - * @return array - */ - public function getInvolvedProgramsTest($account) - { - return $this->program->getInvolvedPrograms($account); - } - - /* - * Get Tree menu. - * - * @param string $programID - * @access public - * @return array - */ - public function getTreeMenuTest($programID) - { - return $this->program->getTreeMenu($programID); - } - - /** - * Get top pairs. - * - * @param string $model - * @param string $mode - * @param bool $isQueryAll - * @access public - * @return array - */ - public function getTopPairsTest($model = '', $mode = '', $isQueryAll = false) - { - return $this->program->getTopPairs($model, $mode, $isQueryAll); - } - - /** - * Get kanban group. - * - * @access public - * @return array - */ - public function getKanbanGroupTest() - { - return $this->program->getKanbanGroup(); - } - - /** - * Get team member pairs . - * - * @param int $programID - * @access public - * @return array - */ - public function getTeamMemberPairsTest($programID) - { - return $this->program->getTeamMemberPairs($programID); - } - - /** - * Get project stats. - * - * @param int $programID - * @param string $browseType - * @param int $queryID - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getProjectStatsTest($programID = 0, $browseType = 'undone', $queryID = 0, $orderBy = 'id_desc', $pager = null) - { - return $this->program->getProjectStats($programID, $browseType, $queryID, $orderBy, $pager); - } - - /** - * Get project list. - * - * @param int $programID - * @param string $browseType - * @param int $queryID - * @param string $orderBy - * @param int $pager - * @param int $programTitle - * @param int $involved - * @access public - * @return array - */ - public function getProjectListTest($programID = 0, $browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null, $programTitle = 0, $involved = 0) - { - return $this->program->getProjectList($programID, $browseType, $queryID, $orderBy, $pager, $programTitle, $involved); - } - - /** - * Get progress list. - * - * @access public - * @return array - */ - public function getProgressListTest() - { - return $this->program->getProgressList(); - } - - /** - * Get stakeholders. - * - * @param int $programID - * @param string $orderBy - * @access public - * @return array - */ - public function getStakeholdersTest($programID, $orderBy = 'id_desc') - { - return $this->program->getStakeholders($programID, $orderBy); - } - - /** - * Test save state. - * - * @param int $programID - * @param array $programs - * @access public - * @return array - */ - public function saveStateTest($programID = 0, $programs = array()) - { - return $this->program->saveState($programID, $programs); - } - - /** - * Test build operate menu. - * - * @param int $programID - * @access public - * @return string - */ - public function buildOperateMenuTest($programID = 0) - { - $program = $this->program->getByID($programID); - if(empty($program)) return '0'; - - return $this->program->buildOperateMenu($program); - } - - /** - * Test set menu. - * - * @param int $programID - * @access public - * @return string - */ - public function setMenuTest($programID = 0) - { - $program = $this->program->getByID($programID); - if(empty($program)) return '0'; - - $this->program->setMenu($programID); - - global $lang; - return strip_tags($lang->switcherMenu); - } -} diff --git a/test/class/programplan.class.php b/test/class/programplan.class.php deleted file mode 100644 index 0ba204b175..0000000000 --- a/test/class/programplan.class.php +++ /dev/null @@ -1,474 +0,0 @@ -objectModel = $tester->loadModel('programplan'); - $tester->dao->delete()->from(TABLE_PROJECTSPEC)->exec(); - } - - /** - * Test get plan by id. - * - * @param int $planID - * @access public - * @return object - */ - public function getByIDTest($planID) - { - $object = $this->objectModel->getByID($planID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get plans list. - * - * @param int $executionID - * @param int $productID - * @param string $browseType - * @param string $orderBy - * @access public - * @return string - */ - public function getStageTest($executionID = 0, $productID = 0, $browseType = 'all', $orderBy = 'id_asc') - { - $objects = $this->objectModel->getStage($executionID, $productID, $browseType, $orderBy); - - if(dao::isError()) return dao::getError(); - - $title = ''; - foreach($objects as $object) $title .= ',' . $object->name; - return $title; - } - - /** - * Test get plans by idList. - * - * @param array $idList - * @access public - * @return array - */ - public function getByListTest($idList = array()) - { - $objects = $this->objectModel->getByList($idList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get plans. - * - * @param int $executionID - * @param int $productID - * @param string $orderBy - * @access public - * @return string - */ - public function getPlansTest($executionID = 0, $productID = 0, $orderBy = 'id_asc') - { - $objects = $this->objectModel->getPlans($executionID, $productID, $orderBy); - - if(dao::isError()) return dao::getError(); - - $title = ''; - foreach($objects as $object) $title .= ',' . $object->name; - return $title; - } - - /** - * Test get pairs. - * - * @param int $executionID - * @param int $productID - * @param string $type - * @access public - * @return string - */ - public function getPairsTest($executionID, $productID = 0, $type = 'all') - { - $objects = $this->objectModel->getPairs($executionID, $productID, $type); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get total percent. - * - * @param int $stageID - * @param bool $parent - * @access public - * @return int - */ - public function getTotalPercentTest($stageID, $parent = false) - { - $stage = $this->objectModel->getByID($stageID); - - $int = $this->objectModel->getTotalPercent($stage, $parent); - - if(dao::isError()) return dao::getError(); - - return $int; - } - - /** - * Test process plans. - * - * @param array $planIDList - * @access public - * @return array - */ - public function processPlansTest($planIDList) - { - $plans = $this->objectModel->getByList($planIDList); - - $objects = $this->objectModel->processPlans($plans); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test process plan. - * - * @param int $planID - * @access public - * @return object - */ - public function processPlanTest($planID) - { - $plan = $this->objectModel->getByID($planID); - - $object = $this->objectModel->processPlan($plan); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get duration. - * - * @param date $begin - * @param date $end - * @access public - * @return int - */ - public function getDurationTest($begin, $end) - { - $count = $this->objectModel->getDuration($begin, $end); - - if(dao::isError()) return dao::getError(); - - return $count; - } - - /** - * Test create a plan. - * - * @param array $param - * @access public - * @return array - */ - public function createTest($param = array()) - { - $_POST['planIDList'] = array('131', '221', '311', '401', '491', '581', '671'); - - global $tester; - $plans = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($_POST['planIDList'])->fetchAll(); - - - $_POST['names'] = array('阶段31', '阶段121', '阶段211', '阶段301', '阶段391', '阶段481', '阶段571', '', '', '', '', ''); - $_POST['PM'] = array('', '', '', '', '', '', '', '', '', '', '', ''); - $_POST['percents'] = array('0', '0', '0', '0', '0', '0', '0', '', '', '', '', ''); - $_POST['attributes'] = array('request', 'request', 'request', 'request', 'request', 'request', 'request', 'request', 'request', 'request', 'request', 'request'); - $_POST['acl'] = array('private', 'open', 'open', 'private', 'private', 'open', 'open', 'open', 'open', 'open', 'open', 'open'); - $_POST['milestone'] = array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); - $_POST['begin'] = (isset($param['begin']) and isset($param['end'])) ? array($plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, '', '', '', '') : array($plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, $plans[0]->begin, '', '', '', '', ''); - $_POST['end'] = (isset($param['begin']) and isset($param['end'])) ? array($plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, '', '', '', '') : array($plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, $plans[0]->end, '', '', '', '', ''); - $_POST['realBegan'] = array('', '', '', '', '', '', '', '', '', '', '', ''); - $_POST['realEnd'] = array('', '', '', '', '', '', '', '', '', '', '', ''); - - foreach($param as $field => $value) - { - if(count($param) == 1 or ($field != 'begin' and $field != 'end')) $_POST[$field] = $value; - } - - $objects = $this->objectModel->create(41, 0, 0); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError()['message'][0]; - $error = strpos($error, '所属项目的') > 0 ? preg_replace('/\d{4}-\d{2}-\d{2}/', '', $error) : $error; - return $error; - } - - $objects = $tester->dao->select('*')->from(TABLE_PROJECT)->where('parent')->eq($plans[0]->parent)->andWhere('type')->eq('stage')->fetchAll(); - return count($objects); - } - - /** - * Test set stage tree path. - * - * @param int $planID - * @access public - * @return object - */ - public function setTreePathTest($planID) - { - $this->objectModel->setTreePath($planID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($planID); - return $object; - } - - /** - * updateTest - * - * @param int $planID - * @param int $projectID - * @param array $param - * @param string $index - * @access public - * @return array - */ - public function updateTest($planID, $projectID, $param = array(), $index = '') - { - $plan = $this->objectModel->getByID($planID); - - $_POST['parent'] = $plan->parent; - $_POST['name'] = $plan->name; - $_POST['percent'] = $plan->percent; - $_POST['attribute'] = $plan->attribute; - $_POST['milestone'] = $plan->milestone; - $_POST['acl'] = $plan->acl; - $_POST['begin'] = $plan->begin; - $_POST['end'] = $plan->end; - $_POST['realBegan'] = $plan->realBegan; - $_POST['realEnd'] = $plan->realEnd; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($planID, $projectID); - - unset($_POST); - - if(dao::isError()) return $index == 'end' ? preg_replace('/『\d{4}-\d{2}-\d{2}』/', '', dao::getError()[$index][0]) : dao::getError()[$index][0]; - - return $objects; - } - - /** - * Test is create task. - * - * @param int $planID - * @access public - * @return int - */ - public function isCreateTaskTest($planID) - { - $object = $this->objectModel->isCreateTask($planID); - - if(dao::isError()) return dao::getError(); - - return $object ? 2 : 1; - } - - /** - * Test get the stage set to milestone. - * - * @param int $projectID - * @access public - * @return string - */ - public function getMilestonesTest($projectID = 0) - { - $objects = $this->objectModel->getMilestones($projectID); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get milestone by product. - * - * @param int $productID - * @param int $projectID - * @access public - * @return string - */ - public function getMilestoneByProductTest($productID, $projectID) - { - $objects = $this->objectModel->getMilestoneByProduct($productID, $projectID); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get parent stage list. - * - * @param int $executionID - * @param int $planID - * @param int $productID - * @access public - * @return string - */ - public function getParentStageListTest($executionID, $planID, $productID) - { - $objects = $this->objectModel->getParentStageList($executionID, $planID, $productID); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get parent stage's children types. - * - * @param int $parentID - * @access public - * @return string - */ - public function getParentChildrenTypesTest($parentID) - { - $objects = $this->objectModel->getParentChildrenTypes($parentID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check code unique. - * - * @param array $codes - * @param array $planIDList - * @access public - * @return string - */ - public function checkCodeUniqueTest($codes, $planIDList = array()) - { - $objects = $this->objectModel->checkCodeUnique($codes, $planIDList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check name unique. - * - * @param array $names - * @access public - * @return string - */ - public function checkNameUniqueTest($names) - { - $objects = $this->objectModel->checkNameUnique($names); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check if the stage is a leaf stage. - * - * @param int $planID - * @access public - * @return string - */ - public function checkLeafStageTest($planID) - { - $objects = $this->objectModel->checkLeafStage($planID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check whether it is the top stage. - * - * @param int $planID - * @access public - * @return string - */ - public function checkTopStageTest($planID) - { - $objects = $this->objectModel->checkTopStage($planID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test update sub-stage attribute. - * - * @param int $planID - * @param string $attribute - * @param int $subStageID - * @access public - * @return string - */ - public function updateSubStageAttrTest($planID, $attribute, $subStageID) - { - global $tester; - - $objects = $this->objectModel->updateSubStageAttr($planID, $attribute); - - if(dao::isError()) return dao::getError(); - - $attribute = $tester->dao->select('attribute')->from(TABLE_EXECUTION)->where('id')->eq($subStageID)->fetch('attribute'); - - return $attribute; - } - - /** - * Test get plan and its children. - * - * @param string|int|array $executionIdList - * @access public - * @return string - */ - public function getSelfAndChildrenListTest($executionIdList) - { - $objects = $this->objectModel->getSelfAndChildrenList($executionIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get plan's siblings. - * - * @param string|int|array $executionIdList - * @access public - * @return string - */ - public function getSiblingsTest($executionIdList) - { - $objects = $this->objectModel->getSiblings($executionIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/projectrelease.class.php b/test/class/projectrelease.class.php deleted file mode 100644 index 14e68da432..0000000000 --- a/test/class/projectrelease.class.php +++ /dev/null @@ -1,195 +0,0 @@ -objectModel = $tester->loadModel('projectrelease'); - } - - /** - * Test get release by id. - * - * @param int $releaseID - * @access public - * @return object - */ - public function getByIDTest($releaseID) - { - $objects = $this->objectModel->getByID($releaseID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - - return $objects; - } - - /** - * Test get list of releases. - * - * @param int $projectID - * @param string $type - * @access public - * @return array - */ - public function getListTest($projectID, $type = 'all') - { - $objects = $this->objectModel->getList($projectID, $type); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - - return $objects; - } - - /** - * Test get last release. - * - * @param int $projectID - * @access public - * @return object - */ - public function getLastTest($projectID) - { - $objects = $this->objectModel->getLast($projectID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - - return $objects; - } - - /** - * Test get released builds from project. - * - * @param int $projectID - * @access public - * @return array - */ - public function getReleasedBuildsTest($projectID) - { - $objects = $this->objectModel->getReleasedBuilds($projectID); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - if(count($objects) == 1) - { - return count($objects); - } - else - { - return $objects; - } - } - - /** - * Test update a release. - * - * @param int $releaseID - * @param string $name - * @param string $date - * @access public - * @return array - */ - public function updateTest($releaseID, $name = '', $date = '') - { - global $app; - $app->loadConfig('release'); - - $updateFields['name'] = $name; - $updateFields['build'] = 1; - $updateFields['date'] = $date; - $updateFields['status'] = 'normal'; - $updateFields['desc'] = ''; - $updateFields['labels'] = array(); - $updateFields['files'] = array(); - $updateFields['uid'] = '62450877d0a27'; - $updateFields['product'] = 1; - foreach($updateFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - $objects = $this->objectModel->update($releaseID); - if($objects == array()) $objects = '没有数据更新'; - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test link stories - * - * @param int $releaseID - * @access public - * @return array - */ - public function linkStoryTest($releaseID) - { - $_POST['stories'] = array(1, 2); - $this->objectModel->linkStory($releaseID); - - global $tester; - $objects = $tester->dao->select('stories')->from(TABLE_RELEASE)->where('id')->eq((int)$releaseID)->fetch(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test unlink stories - * - * @param int $releaseID - * @param int $storyID - * @access public - * @return array - */ - public function unlinkStoryTest($releaseID, $storyID) - { - $this->linkStoryTest($releaseID); - $this->objectModel->unlinkStory($releaseID, $storyID); - - global $tester; - $objects = $tester->dao->select('stories')->from(TABLE_RELEASE)->where('id')->eq((int)$releaseID)->fetch(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test link bugs. - * - * @param int $releaseID - * @param string $type - * @access public - * @return array - */ - public function linkBugTest($releaseID, $type = 'bug') - { - $_POST['bugs'] = array(1, 2); - $this->objectModel->linkBug($releaseID, $type); - - global $tester; - $field = $type == 'bug' ? 'bugs' : 'leftBugs'; - $objects = $tester->dao->select($field)->from(TABLE_RELEASE)->where('id')->eq((int)$releaseID)->fetch(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/projectstory.class.php b/test/class/projectstory.class.php deleted file mode 100644 index 68c2881d6c..0000000000 --- a/test/class/projectstory.class.php +++ /dev/null @@ -1,44 +0,0 @@ -objectModel = $tester->loadModel('projectstory'); - } - - /** - * Set menu test - * - * @param array $products - * @param int $productID - * @param int $branch - * @access public - * @return xml - */ - public function setMenuTest($products = array(), $productID = 0, $branch = 0) - { - $objects = $this->objectModel->setMenu($products, $productID, $branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get execution stories test - * - * @param int mixed $projectID - * @param array $storyIdList - * @access public - * @return array - */ - public function getExecutionStoriesTest($projectID, $storyIdList = array()) - { - $objects = $this->objectModel->getExecutionStories($projectID, $storyIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/release.class.php b/test/class/release.class.php deleted file mode 100644 index e0dbebc20c..0000000000 --- a/test/class/release.class.php +++ /dev/null @@ -1,336 +0,0 @@ -objectModel = $tester->loadModel('release'); - } - - /** - * function getByIDTest by release - * - * @param string $releaseID - * @param beel $setImgSize - * @access public - * @return array - */ - public function getByIDTest($releaseID, $setImgSize = false) - { - $objects = $this->objectModel->getByID($releaseID, $setImgSize); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getListTest by release - * - * @param string $productID - * @param string $branch - * @param string $type - * @access public - * @return array - */ - - public function getListTest($productID, $branch = 'all', $type = 'all', $orderBy = 't1.date_desc', $pager = null) - { - $objects = $this->objectModel->getList($productID, $branch, $type, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * function getLastTest by release - * - * @param string $productID - * @param string $branch - * @access public - * @return array - */ - public function getLastTest($productID, $branch = 0) - { - $objects = $this->objectModel->getLast($productID, $branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get released test builds from product . - * - * @param int $productID - * @param string|int $branch - * @access public - * @return void - */ - public function getReleasedBuildsTest($productID, $branch = 'all') - { - $objects = $this->objectModel->getReleasedBuilds($productID, $branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Create a release. - * - * @param int $productID - * @param int $branch - * @param int $projectID - * @access public - * @return array - */ - - public function createTest($productID = 0, $branch = 0, $projectID = 0, $param = array()) - { - - $date = date('Y-m-d'); - $labels = array(); - $files = array(); - $mailto = array(); - - $createFields = array('name' => '','marker' => '1', 'build' => '', 'date' => $date, 'desc' => '', 'mailto' => $mailto , 'labels' => $labels, 'files' => $files); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectsID = $this->objectModel->create($productID, $branch, $projectID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($objectsID); - - return $objects; - } - /** - * Update a release. - * - * @param int $releaseID - * @access public - * @return array - */ - - public function updateTest($releaseID, $param = array()) - { - $date = date('Y-m-d'); - $labels = array(); - $files = array(); - $mailto = array(); - - $createFields = array('name' => '','marker' => '1', 'build' => '', 'date' => $date, 'desc' => '', 'mailto' => $mailto , 'labels' => $labels, 'files' => $files); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - $this->objectModel->update($releaseID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Get notify persons. - * - * @param string $notfiyList - * @param int $productID - * @param int $buildID - * @param int $releaseID - * @access public - * @return array - */ - - public function getNotifyPersonsTest($releaseID) - { - $release = $this->objectModel->getById($releaseID); - $objects = $this->objectModel->getNotifyPersons($release); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Link stories - * - * @param int $releaseID - * @access public - * @return array - */ - - public function linkStoryTest($releaseID, $stories) - { - $_POST['stories'] = $stories; - $this->objectModel->linkStory($releaseID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Unlink story - * - * @param int $releaseID - * @param int $storyID - * @access public - * @return array - */ - public function unlinkStoryTest($releaseID, $storyID) - { - $_POST['stories'] = $storyID; - $this->objectModel->linkStory($releaseID); - unset($_POST); - - $this->objectModel->unlinkStory($releaseID, $storyID[0]); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Batch unlink story. - * - * @param int $releaseID - * @access public - * @return array - */ - - public function batchUnlinkStoryTest($releaseID, $stories) - { - $_POST['stories'] = $stories; - $this->objectModel->linkStory($releaseID); - unset($_POST); - - $_POST['storyIdList'] = $stories; - $this->objectModel->batchUnlinkStory($releaseID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - - return $objects; - } - - /** - * Link bugs. - * - * @param int $releaseID - * @param string $type - * @param string $bugs - * @access public - * @return array - */ - - public function linkBugTest($releaseID, $type = 'bug', $bugs = '') - { - $_POST['bugs'] = $bugs; - $this->objectModel->linkBug($releaseID, $type); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Unlink bug. - * - * @param int $releaseID - * @param int $bugID - * @param string $type - * @access public - * @return void - */ - - public function unlinkBugTest($releaseID, $bugID, $type = 'bug') - { - $_POST['bugs'] = $bugID; - $this->objectModel->linkBug($releaseID); - unset($_POST); - - $this->objectModel->unlinkBug($releaseID, $bugID[0], $type); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Batch unlink bug. - * - * @param int $releaseID - * @param string $type - * @param string $bugs - * @access public - * @return array - */ - public function batchUnlinkBugTest($releaseID, $type = 'bug', $bugs = '') - { - $_POST['bugs'] = $bugs; - $this->objectModel->linkBug($releaseID); - unset($_POST); - - $_POST['unlinkBugs'] = $bugs; - $this->objectModel->batchUnlinkBug($releaseID, $type); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Change status. - * - * @param int $releaseID - * @param string $status - * @access public - * @return bool - */ - - public function changeStatusTest($releaseID, $status) - { - $this->objectModel->changeStatus($releaseID, $status); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($releaseID); - return $objects; - } - - /** - * Get toList and ccList. - * - * @param object $release - * @access public - * @return bool|array - */ - public function getToAndCcListTest($releaseID) - { - $release = $this->objectModel->getByID($releaseID); - - $objects = $this->objectModel->getToAndCcList($release); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/repo.class.php b/test/class/repo.class.php deleted file mode 100644 index c0ef4b6bc9..0000000000 --- a/test/class/repo.class.php +++ /dev/null @@ -1,559 +0,0 @@ -objectModel = $tester->loadModel('repo'); - } - - /** - * Check priv test. - * - * @param object $repo - * @access public - * @return bool - */ - public function checkPrivTest($repo) - { - $objects = $this->objectModel->checkPriv($repo); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setMenuTest($repos, $repoID = '', $showSeleter = true) - { - $objects = $this->objectModel->setMenu($repos, $repoID, $showSeleter); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get switcher test. - * - * @param int $repoID - * @access public - * @return object - */ - public function getSwitcherTest($repoID) - { - $objects = $this->objectModel->getSwitcher($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getListTest($projectID = 0, $SCM = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($projectID , $SCM, $orderBy , $pager ); - - if(dao::isError()) return dao::getError(); - - if(!empty($objects)) - { - return $objects[1]->name; - } - else - { - return 'empty'; - } - } - - public function getListBySCMTest($scm, $type = 'all') - { - $objects = $this->objectModel->getListBySCM($scm, $type = 'all'); - - if(dao::isError()) return dao::getError(); - - if(!empty($objects)) - { - return $objects[0]->name; - } - else - { - return 'empty'; - } - } - - public function createTest($list) - { - $init = array('SCM' => '', 'serviceHost' => '', 'serviceProject' => '', 'name' => '', 'path' => '', 'encoding' => '', 'client' => '', 'account' => '', 'password' => '', 'encrypt' => '', 'desc' => '', 'uid' => ''); - - foreach($init as $filed => $defaultvalue) $_POST[$filed] = $defaultvalue; - foreach($list as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->create(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function updateTest($id) - { - $objects = $this->objectModel->update($id); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveStateTest($repoID = 0, $objectID = 0) - { - $objects = $this->objectModel->saveState($repoID, $objectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoPairsTest($type, $projectID = 0) - { - $objects = $this->objectModel->getRepoPairs($type, $projectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoGroupTest($type, $projectID = 0) - { - $objects = $this->objectModel->getRepoGroup($type, $projectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoByIDTest($repoID) - { - $objects = $this->objectModel->getRepoByID($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoByUrlTest($url) - { - $objects = $this->objectModel->getRepoByUrl($url); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoListByUrlTest($url = '') - { - $objects = $this->objectModel->getRepoListByUrl($url = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getByIdListTest($idList) - { - $objects = $this->objectModel->getByIdList($idList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getBranchesTest($repo, $printLabel = false) - { - $objects = $this->objectModel->getBranches($repo, $printLabel); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getCommitsTest($repo, $entry, $revision = 'HEAD', $type = 'dir', $pager = null, $begin = 0, $end = 0) - { - $objects = $this->objectModel->getCommits($repo, $entry, $revision, $type, $pager, $begin, $end); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getLatestCommitTest($repoID) - { - $objects = $this->objectModel->getLatestCommit($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRevisionsFromDBTest($repoID, $limit = '', $maxRevision = '', $minRevision = '') - { - $objects = $this->objectModel->getRevisionsFromDB($repoID, $limit = '', $maxRevision = '', $minRevision = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getHistoryTest($repoID, $revisions) - { - $objects = $this->objectModel->getHistory($repoID, $revisions); - - if(dao::isError()) return dao::getError(); - - return !empty($objects) ? array_keys($objects) : 'empty'; - } - - public function getGitRevisionNameTest($revision, $commit) - { - $objects = $this->objectModel->getGitRevisionName($revision, $commit); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getCacheFileTest($repoID, $path, $revision) - { - $objects = $this->objectModel->getCacheFile($repoID, $path, $revision); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getProductsByRepoTest($repoID) - { - $objects = $this->objectModel->getProductsByRepo($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveCommitTest($repoID, $logs, $version, $branch = '') - { - $objects = $this->objectModel->saveCommit($repoID, $logs, $version, $branch = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveOneCommitTest($repoID, $commit, $version, $branch = '') - { - $objects = $this->objectModel->saveOneCommit($repoID, $commit, $version, $branch = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveExistCommits4BranchTest($repoID, $branch) - { - $objects = $this->objectModel->saveExistCommits4Branch($repoID, $branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function updateCommitCountTest($repoID, $count) - { - $objects = $this->objectModel->updateCommitCount($repoID, $count); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getUnsyncedCommitsTest($repo) - { - $objects = $this->objectModel->getUnsyncedCommits($repo); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getPreAndNextTest($repo, $entry, $revision = 'HEAD', $fileType = 'dir', $method = 'view') - { - $objects = $this->objectModel->getPreAndNext($repo, $entry, $revision, $fileType, $method); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function createLinkTest($method, $params = '', $viewType = '', $onlybody = false) - { - $objects = $this->objectModel->createLink($method, $params, $viewType, $onlybody); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setBackSessionTest($type = 'list', $withOtherModule = false) - { - $objects = $this->objectModel->setBackSession($type, $withOtherModule); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function setRepoBranchTest($branch) - { - $objects = $this->objectModel->setRepoBranch($branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function markSyncedTest($repoID) - { - $objects = $this->objectModel->markSynced($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function fixCommitTest($repoID) - { - $objects = $this->objectModel->fixCommit($repoID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function encodePathTest($path = '') - { - $objects = $this->objectModel->encodePath($path); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function decodePathTest($path = '') - { - $objects = $this->objectModel->decodePath($path); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function isBinaryTest($content, $suffix = '') - { - $objects = $this->objectModel->isBinary($content, $suffix); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function checkClientTest() - { - $objects = $this->objectModel->checkClient(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function rmClientVersionFileTest() - { - $objects = $this->objectModel->rmClientVersionFile(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function checkConnectionTest() - { - $objects = $this->objectModel->checkConnection(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function replaceCommentLinkTest($comment) - { - $objects = $this->objectModel->replaceCommentLink($comment); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function addLinkTest($comment, $type) - { - $rules = $this->objectModel->processRules(); - $objectReg = '/' . $rules[$type . 'Reg'] . '/i'; - if(preg_match_all($objectReg, $comment, $result)) - { - $links = $this->objectModel->addLink($result, $type); - foreach($links as $link) return $link; - } - - return 'empty'; - } - - public function parseCommentTest($comment) - { - $objects = $this->objectModel->parseComment($comment); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function iconvCommentTest($comment, $encodings) - { - $objects = $this->objectModel->iconvComment($comment, $encodings); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function processRulesTest() - { - $objects = $this->objectModel->processRules(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveAction2PMSTest($objects, $log, $repoRoot = '', $encodings = 'utf-8', $scm = 'svn', $gitlabAccountPairs = array()) - { - $objects = $this->objectModel->saveAction2PMS($objects, $log, $repoRoot, $encodings, $scm, $gitlabAccountPairs); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function saveRecordTest($action, $changes) - { - $objects = $this->objectModel->saveRecord($action, $changes); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function createActionChangesTest($log, $repoRoot, $scm = 'svn') - { - $objects = $this->objectModel->createActionChanges($log, $repoRoot, $scm); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getTaskProductsAndExecutionsTest($tasks) - { - $objects = $this->objectModel->getTaskProductsAndExecutions($tasks); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getBugProductsAndExecutionsTest($bugs) - { - $objects = $this->objectModel->getBugProductsAndExecutions($bugs); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function buildURLTest($methodName, $url, $revision, $scm = 'svn') - { - $objects = $this->objectModel->buildURL($methodName, $url, $revision, $scm); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function processGitServiceTest($repo) - { - $objects = $this->objectModel->processGitService($repo); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRepoListByClientTest($gitlabID, $projectID = 0) - { - $objects = $this->objectModel->getRepoListByClient($gitlabID, $projectID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function handleWebhookTest($event, $token, $data, $repo) - { - $objects = $this->objectModel->handleWebhook($event, $token, $data, $repo); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getGitlabProductsByProjectsTest($projectIDs) - { - $objects = $this->objectModel->getGitlabProductsByProjects($projectIDs); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function syncCommitTest($repoID, $branchID) - { - $objects = $this->objectModel->syncCommit($repoID, $branchID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getExecutionPairsTest($product, $branch = 0) - { - $objects = $this->objectModel->getExecutionPairs($product, $branch); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getCloneUrlTest($repo) - { - $objects = $this->objectModel->getCloneUrl($repo); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/report.class.php b/test/class/report.class.php deleted file mode 100644 index 1bdf2caa4e..0000000000 --- a/test/class/report.class.php +++ /dev/null @@ -1,542 +0,0 @@ -objectModel = $tester->loadModel('report'); - $tester->dao->delete()->from(TABLE_ACTION)->where('id')->gt(100)->exec(); - } - - /** - * Test compute percent of every item. - * - * @param array $datas - * @access public - * @return string - */ - public function computePercentTest($datas) - { - $objects = $this->objectModel->computePercent($datas); - - if(dao::isError()) return dao::getError(); - - $percents = ''; - foreach($objects as $moduleID => $object) $percents .= "$moduleID:$object->percent;"; - return $percents; - } - - /** - * Test create json data of single charts. - * - * @param int $executionID - * @access public - * @return string - */ - public function createSingleJSONTest($executionID) - { - global $tester; - $this->execution = $tester->loadModel('execution'); - - $execution = $this->execution->getByID($executionID); - $sets = $this->execution->getBurnDataFlot($executionID, 'left'); - $dateList = $this->execution->getDateList($execution->begin, $execution->end, 'noweekend', 0, 'Y-m-d'); - - $objects = $this->objectModel->createSingleJSON($sets, $dateList[0]); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test convert date format. - * - * @param array $dateList - * @param string $format - * @access public - * @return string - */ - public function convertFormatTest($dateList, $format = 'Y-m-d') - { - $objects = $this->objectModel->convertFormat($dateList, $format = 'Y-m-d'); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get executions. - * - * @param int $begin - * @param int $end - * @access public - * @return void - */ - public function getExecutionsTest($begin = 0, $end = 0) - { - global $tester; - $tester->dao->update(TABLE_EXECUTION)->set('`status`')->eq('closed')->where('`id`')->in('101,102,103,107,111,121,151,183')->exec(); - - $begin = $begin != 0 ? date('Y-m-d', strtotime(date('Y-m-d') . $begin)) : 0; - $end = $end != 0 ? date('Y-m-d', strtotime(date('Y-m-d') . $end)) : 0; - $objects = $this->objectModel->getExecutions($begin, $end); - - $tester->dao->update(TABLE_EXECUTION)->set('`status`')->eq('wait')->where('`id`')->in('101,103,107,111,121,151,183')->exec(); - $tester->dao->update(TABLE_EXECUTION)->set('`status`')->eq('doing')->where('`id`')->in('102')->exec(); - - if(dao::isError()) return dao::getError(); - - $executions = ''; - foreach($objects as $executionID => $execution) $executions .= "$executionID:$execution->estimate,$execution->consumed,$execution->projectName;"; - return $executions; - } - - /** - * Test get products. - * - * @param string $conditions - * @param string $storyType - * @access public - * @return string - */ - public function getProductsTest($conditions, $storyType = 'story') - { - $objects = $this->objectModel->getProducts($conditions, $storyType); - - if(dao::isError()) return dao::getError(); - - $planCount = 0; - foreach($objects as $object) - { - if(isset($object->plans)) $planCount += count($object->plans); - } - return 'product:' . count($objects) . ';plan:' . $planCount; - } - - /** - * Test get bugs. - * - * @param string $begin - * @param string $end - * @param int $product - * @param int $execution - * @access public - * @return array - */ - public function getBugsTest($begin, $end, $product, $execution) - { - $begin = date('Y-m-d', strtotime(date('Y-m-d') . $begin)); - $end = date('Y-m-d', strtotime(date('Y-m-d') . $end)); - $objects = $this->objectModel->getBugs($begin, $end, $product, $execution); - - if(dao::isError()) return dao::getError(); - - $count = array(); - foreach($objects as $user => $types) - { - $count[$user] = ''; - foreach($types as $type => $typeCount) $count[$user] .= "$type:$typeCount;"; - } - return $count; - } - - /** - * Test get workload. - * - * @param int $dept - * @param string $assign - * @access public - * @return string - */ - public function getWorkloadTest($dept = 0, $assign = 'assign') - { - $objects = $this->objectModel->getWorkload($dept, $assign); - - if(dao::isError()) return dao::getError(); - - $workload = ''; - foreach($objects as $user => $work) - { - if(strlen($workload) > 40) break; - - $workload .= "$user:"; - foreach($work['total'] as $key => $value) $workload .= "$key:$value,"; - $workload = trim($workload, ','); - $workload .= ';'; - } - return $workload; - } - - /** - * Test get bug assign. - * - * @access public - * @return void - */ - public function getBugAssignTest() - { - $objects = $this->objectModel->getBugAssign(); - - if(dao::isError()) return dao::getError(); - - $count = array(); - foreach($objects as $user => $object) $count[$user] = $object['total']['count']; - return $count; - } - - /** - * Test get user bugs. - * - * @access public - * @return string - */ - public function getUserBugsTest() - { - $objects = $this->objectModel->getUserBugs(); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $user => $bugs) $counts .= "$user:" . count($bugs) . ';'; - return $counts; - } - - /** - * Test get user tasks. - * - * @access public - * @return string - */ - public function getUserTasksTest() - { - $objects = $this->objectModel->getUserTasks(); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $user => $tasks) $counts .= "$user:" . count($tasks) . ';'; - return $counts; - } - - /** - * Test get user todos. - * - * @access public - * @return string - */ - public function getUserTodosTest($userType) - { - $objects = $this->objectModel->getUserTodos(); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $user => $todos) - { - if(strpos($user, $userType) !== false and str_replace($userType, '', $user) < 11) $counts .= "$user:" . count($todos) . ';'; - } - return $counts; - } - - /** - * Test get user test tasks. - * - * @access public - * @return string - */ - public function getUserTestTasksTest() - { - $objects = $this->objectModel->getUserTestTasks(); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $user => $testtasks) $counts .= "$user:" . count($testtasks) . ';'; - return $counts; - } - - /** - * Test get user login count in this year. - * - * @param string $accounts - * @access public - * @return int - */ - public function getUserYearLoginsTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getUserYearLogins($accounts, $year); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get user action count in this year. - * - * @param array $accounts - * @access public - * @return void - */ - public function getUserYearActionsTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getUserYearActions($accounts, $year); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get user contributions in this year. - * - * @param array $accounts - * @access public - * @return string - */ - public function getUserYearContributionsTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getUserYearContributions($accounts, $year); - - if(dao::isError()) return dao::getError(); - - $contributions = ''; - foreach($objects as $type => $contributionTypes) - { - $contributions .= "$type:"; - foreach($contributionTypes as $contributionType => $count) $contributions .= "$contributionType:$count,"; - $contributions = trim($contributions, ',') . ';'; - } - return $contributions; - } - - /** - * Test get user todo stat in this year. - * - * @param array $accounts - * @access public - * @return string - */ - public function getUserYearTodosTest($accounts) - { - $year = date('Y'); - $objects = $this->objectModel->getUserYearTodos($accounts, $year); - - if(dao::isError()) return dao::getError(); - - $count = ''; - foreach($objects as $type => $value) $count .= "$type:$value;"; - return $count; - } - - /** - * Test get user effort stat in this error. - * - * @param string $accounts - * @access public - * @return object - */ - public function getUserYearEffortsTest($accounts) - { - $year = date('Y'); - - $object = $this->objectModel->getUserYearEfforts($accounts, $year); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get count of created story,plan and closed story by accounts every product in this year. - * - * @param mixed $accounts - * @access public - * @return void - */ - public function getUserYearProductsTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getUserYearProducts($accounts, $year); - - if(dao::isError()) return dao::getError(); - - return implode(',', array_keys($objects)); - } - - /** - * Test get count of finished task, story and resolved bug by accounts every executions in this years. - * - * @param string $accounts - * @access public - * @return string - */ - public function getUserYearExecutionsTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getUserYearExecutions($accounts, $year); - - if(dao::isError()) return dao::getError(); - - return implode(',', array_keys($objects)); - } - - /** - * Test get status stat that is all time, include story, task and bug. - * - * @access public - * @return array - */ - public function getAllTimeStatusStatTest() - { - $objects = $this->objectModel->getAllTimeStatusStat(); - - if(dao::isError()) return dao::getError(); - - $types = array(); - foreach($objects as $type => $status) - { - $types[$type] = ''; - foreach($status as $statusType => $statusCount) $types[$type] .= "$statusType:$statusCount;"; - } - return $types; - } - - /** - * Test get year object stat, include status and action stat. - * - * @param string $accounts - * @param string $objectType - * @access public - * @return string - */ - public function getYearObjectStatTest($accounts, $objectType) - { - $year = date('Y'); - - $objects = $this->objectModel->getYearObjectStat($accounts, $year, $objectType); - - if(dao::isError()) return dao::getError(); - - $stats = ''; - foreach($objects['statusStat'] as $stat => $count) $stats .= "$stat:$count;"; - return $stats; - } - - /** - * Test get year case stat, include result and action stat. - * - * @param string $accounts - * @access public - * @return string - */ - public function getYearCaseStatTest($accounts) - { - $year = date('Y'); - - $objects = $this->objectModel->getYearCaseStat($accounts, $year); - - if(dao::isError()) return dao::getError(); - - $result = ''; - foreach($objects['resultStat'] as $type => $value) $result .= "$type:$value;"; - return $result; - } - - /** - * Test get year months. - * - * @param string $year - * @access public - * @return string - */ - public function getYearMonthsTest($year) - { - $objects = $this->objectModel->getYearMonths($year); - - if(dao::isError()) return dao::getError(); - - return implode(',', $objects); - } - - /** - * Test get status overview. - * - * @param string $objectType - * @param array $statusStat - * @access public - * @return string - */ - public function getStatusOverviewTest($objectType, $statusStat) - { - $object = $this->objectModel->getStatusOverview($objectType, $statusStat); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get project status overview. - * - * @param array $accounts - * @access public - * @return string - */ - public function getProjectStatusOverviewTest($accounts = array()) - { - $objects = $this->objectModel->getProjectStatusOverview($accounts); - - if(dao::isError()) return dao::getError(); - - $counts = ''; - foreach($objects as $type => $count) $counts .= "$type:$count;"; - return $counts; - } - - /** - * Test get output data for API. - * - * @param string $accounts - * @param string $year - * @access public - * @return string - */ - public function getOutput4APITest($accounts) - { - $year = date('Y'); - $objects = $this->objectModel->getOutput4API($accounts, $year); - - if(dao::isError()) return dao::getError(); - - $output = ''; - foreach($objects as $objectType => $object) $output .= "$objectType:" . $object['total'] . ";"; - return $output; - } - - /** - * Test get project and execution name. - * - * @param bool $count - * @access public - * @return int|array - */ - public function getProjectExecutionsTest($count = false) - { - $objects = $this->objectModel->getProjectExecutions(); - - if(dao::isError()) return dao::getError(); - - return $count ? count($objects) : $objects; - } -} diff --git a/test/class/score.class.php b/test/class/score.class.php deleted file mode 100644 index cd69a37abc..0000000000 --- a/test/class/score.class.php +++ /dev/null @@ -1,96 +0,0 @@ -objectModel = $tester->loadModel('score'); - } - - /** - * Get user score list. - * - * @param string $account - * @param object $pager - * @param bool $needCount - * - * @access public - * @return array|int - */ - public function getListByAccountTest($account, $pager, $needCount = false) - { - $objects = $this->objectModel->getListByAccount($account, $pager); - - if(dao::isError()) return dao::getError(); - - return $needCount ? count($objects) : $objects; - } - - /** - * Add score logs. - * - * @param string $module - * @param string $method - * @param string $param - * @param string $account - * @param string $time - * - * @access public - * @return string|object - */ - public function createTest($module = '', $method = '', $param = '', $account = '', $time = '') - { - global $tester; - - $object = $this->objectModel->create($module, $method, $param, $account, $time); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = (!empty((array) $object) and is_object($object)) ? $object : ''; - } - - return $object; - } - - /** - * Score reset. - * - * @param int $lastID - * - * @access public - * @return array - */ - public function resetTest($lastID = 0) - { - $result = $this->objectModel->reset($lastID); - while($result['status'] != 'finish') - { - $result = $this->objectModel->reset($result['lastID']); - } - - if(dao::isError()) return dao::getError(); - - return $result; - } - - /** - * Fix action type for score. - * - * @param $string - * - * @access public - * @return string - */ - public function fixKeyTest($string) - { - $objects = $this->objectModel->fixKey($string); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/search.class.php b/test/class/search.class.php deleted file mode 100644 index 9021e13d66..0000000000 --- a/test/class/search.class.php +++ /dev/null @@ -1,281 +0,0 @@ -objectModel = $tester->loadModel('search'); - } - - /** - * Test get query. - * - * @param int $queryID - * @access public - * @return array - */ - public function getQueryTest($queryID) - { - $objects = $this->objectModel->getQuery($queryID); - - global $tester; - $objectType = $objects->module; - if($objects->module == 'executionStory') $objectType = 'story'; - if($objects->module == 'projectBuild') $objectType = 'build'; - if($objects->module == 'executionBuild') $objectType = 'build'; - - $table = $tester->config->objectTables[$objectType]; - $objects->queryCount = $tester->dao->select('count(*) as count')->from($table)->where($objects->sql)->fetch('count'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get by ID. - * - * @param int $queryID - * @access public - * @return array - */ - public function getByIDTest($queryID) - { - $objects = $this->objectModel->getByID($queryID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test delete query. - * - * @param int $queryID - * @access public - * @return int - */ - public function deleteQueryTest($queryID) - { - global $tester; - $this->objectModel->deleteQuery($queryID); - if(dao::isError()) return dao::getError(); - - $count = $tester->dao->select('count(*) as count')->from(TABLE_USERQUERY)->fetch('count'); - if(dao::isError()) return dao::getError(); - return $count; - } - - /** - * Test get query pairs. - * - * @param string $module - * @access public - * @return array - */ - public function getQueryPairsTest($module) - { - $objects = $this->objectModel->getQueryPairs($module); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get list. - * - * @param string $keywords - * @param sreing $type - * @access public - * @return int - */ - public function getListTest($keywords, $type) - { - $result = array(); - while(!isset($result['finished'])) - { - if(empty($result)) - { - $result = $this->objectModel->buildAllIndex(); - } - else - { - $result = $this->objectModel->buildAllIndex($result['type'], $result['lastID']); - } - } - - $objects = $this->objectModel->getList($keywords, $type); - - if(dao::isError()) return dao::getError(); - - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - return count($objects); - } - - /** - * Test save index. - * - * @param string $objectType - * @param int $objectID - * @access public - * @return bool - */ - public function saveIndexTest($objectType, $objectID) - { - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - $table = $tester->config->objectTables[$objectType]; - $object = $tester->dao->select('*')->from($table)->where('id')->eq($objectID)->fetch(); - $object->comment = ''; - - $objects = $this->objectModel->saveIndex($objectType, $object); - if(dao::isError()) return dao::getError(); - - $insertedIndex = $tester->dao->select('*')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->fetch(); - - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - if($insertedIndex) return true; - } - - /** - * Test save dict. - * - * @param string $word - * @access public - * @return int - */ - public function saveDictTest($word) - { - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - $spliter = $tester->app->loadClass('spliter'); - $titleSplited = $spliter->utf8Split($word); - - $objects = $this->objectModel->saveDict($titleSplited['dict']); - if(dao::isError()) return dao::getError(); - - $count = $tester->dao->select("count('*') as count")->from(TABLE_SEARCHDICT)->fetch('count'); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - return $count; - } - - /** - * Test decode. - * - * @param int $key - * @access public - * @return string - */ - public function decodeTest($key) - { - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - $result = array(); - while(!isset($result['finished'])) - { - if(empty($result)) - { - $result = $this->objectModel->buildAllIndex(); - } - else - { - $result = $this->objectModel->buildAllIndex($result['type'], $result['lastID']); - } - } - - $objects = $this->objectModel->decode($key); - if(dao::isError()) return dao::getError(); - - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - return $objects; - } - - /** - * Test get summary. - * - * @param int $indexID - * @param string $words - * @access public - * @return array - */ - public function getSummaryTest($indexID, $words) - { - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - $result = array(); - while(!isset($result['finished'])) - { - if(empty($result)) - { - $result = $this->objectModel->buildAllIndex(); - } - else - { - $result = $this->objectModel->buildAllIndex($result['type'], $result['lastID']); - } - } - - $searchIndex = $tester->dao->select('*')->from(TABLE_SEARCHINDEX)->where('id')->eq($indexID)->fetch(); - - $objects = $this->objectModel->getSummary($searchIndex->content, $words); - if(dao::isError()) return dao::getError(); - - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - return $objects; - } - - /** - * Test mark keywords. - * - * @param int $indexID - * @param string $keywords - * @access public - * @return string - */ - public function markKeywordsTest($indexID, $keywords) - { - global $tester; - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - $result = array(); - while(!isset($result['finished'])) - { - if(empty($result)) - { - $result = $this->objectModel->buildAllIndex(); - } - else - { - $result = $this->objectModel->buildAllIndex($result['type'], $result['lastID']); - } - } - - $searchIndex = $tester->dao->select('*')->from(TABLE_SEARCHINDEX)->where('id')->eq($indexID)->fetch(); - - $objects = $this->objectModel->markKeywords($searchIndex->content, $keywords); - if(dao::isError()) return dao::getError(); - - $tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec(); - $tester->dao->delete()->from(TABLE_SEARCHDICT)->exec(); - - return $objects; - } -} diff --git a/test/class/setting.class.php b/test/class/setting.class.php deleted file mode 100644 index bd3fb39806..0000000000 --- a/test/class/setting.class.php +++ /dev/null @@ -1,273 +0,0 @@ -objectModel = $tester->loadModel('setting'); - } - - /** - * Get value of an item. - * - * @param string $paramString see parseItemParam(); - * @access public - * @return bool - */ - public function getItemTest($paramString) - { - $objects = $this->objectModel->getItem($paramString); - - if(dao::isError()) return dao::getError(); - - if($objects or $objects === 0 or $objects === '0') return true; - return false; - } - - /** - * Get some items. - * - * @param string $paramString see parseItemParam(); - * @access public - * @return array|string - */ - public function getItemsTest($paramString) - { - $objects = $this->objectModel->getItems($paramString); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Set value of an item. - * - * @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd - * @param string $value - * @access public - * @return misc - */ - public function setItemTest($path, $value = '') - { - $this->objectModel->setItem($path, $value); - - if(dao::isError()) return dao::getError(); - - /* Determine vision of config item. */ - $pathVision = explode('@', $path); - $vision = isset($pathVision[1]) ? $pathVision[1] : ''; - $path = $pathVision[0]; - $level = substr_count($path, '.'); - $section = ''; - - if($level <= 1) return false; - if($level == 2) list($owner, $module, $key) = explode('.', $path); - if($level == 3) list($owner, $module, $section, $key) = explode('.', $path); - $paramString = "vision=$vision&owner=$owner&module=$module§ion=$section&key=$key"; - $objects = $this->objectModel->getItem($paramString); - - return $objects; - } - - /** - * Batch set items, the example: - * - * $path = 'system.mail'; - * $items->turnon = true; - * $items->smtp->host = 'localhost'; - * - * @param string $path like system.mail - * @param array|object $items the items array or object, can be mixed by one level or two levels. - * @access public - * @return bool|string - */ - public function setItemsTest($path, $items) - { - $result = $this->objectModel->setItems($path, $items); - - if(dao::isError()) return dao::getError(); - - return $result; - } - - /** - * Delete items. - * - * @param string $paramString see parseItemParam(); - * @access public - * @return misc - */ - public function deleteItemsTest($paramString) - { - $this->objectModel->deleteItems($paramString); - - if(dao::isError()) return dao::getError(); - - $object = $this->getItemTest($paramString); - return $object; - } - - /** - * Parse item path test. - * - * @param string $path - * @access public - * @return object - */ - public function parseItemPathTest($path) - { - $object = $this->objectModel->parseItemPath($path); - return $object; - } - - /** - * Parse the param string for select or delete items. - * - * @param string $paramString owner=xxx&key=sn and so on. - * @access public - * @return array - */ - public function parseItemParamTest($paramString) - { - $objects = $this->objectModel->parseItemParam($paramString); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test create a DAO object to select or delete one or more records. - * - * @param string $paramString - * @param string $method select|delete. - * @access public - * @return array|int - */ - public function createDAOTest($paramString, $method = 'select') - { - $params = $this->objectModel->parseItemParam($paramString); - if($method == 'delete') - { - $objects = $this->objectModel->createDAO($params, $method)->exec(); - } - else - { - $objects = $this->objectModel->createDAO($params, $method)->orderBy('key')->fetch(); - } - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get config of system and one user. - * - * @param string $account - * @access public - * @return bool - */ - public function getSysAndPersonalConfigTest($account = '') - { - $objects = $this->objectModel->getSysAndPersonalConfig($account); - - if(dao::isError()) return dao::getError(); - - return !empty($objects) ? true : false; - } - - /** - * Test get the version of current zentaopms. - * - * Since the version field not saved in db. So if empty, return 0.3 beta. - * - * @access public - * @return void - */ - public function getVersionTest() - { - $objects = $this->objectModel->getVersion(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get URSR. - * - * @access public - * @return int - */ - public function getURSRTest() - { - $objects = $this->objectModel->getURSR(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test update version - * - * @param string $version - * @access public - * @return array - */ - public function updateVersionTest($version) - { - $this->objectModel->updateVersion($version); - - if(dao::isError()) return dao::getError(); - - $params['owner'] = 'system'; - $params['module'] = 'common'; - $params['section'] = 'global'; - $params['key'] = 'version'; - - $objects = $this->objectModel->createDAO($params)->fetchAll(); - - return $objects; - } - - /** - * Test set the sn of current zentaopms. - * - * @access public - * @return bool - */ - public function setSNTest() - { - $this->objectModel->setSN(); - - if(dao::isError()) return dao::getError(); - - $params['owner'] = 'system'; - $params['module'] = 'common'; - $params['section'] = 'global'; - $params['key'] = 'sn'; - - $objects = $this->objectModel->createDAO($params)->fetchAll(); - - return !empty($objects) ? true : false; - } - - /** - * Test judge a sn needed update or not. - * - * @param string $sn - * @access public - * @return bool - */ - public function snNeededUpdateTest($sn) - { - $objects = $this->objectModel->snNeededUpdate($sn); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/sonarqube.class.php b/test/class/sonarqube.class.php deleted file mode 100644 index 16abf5082f..0000000000 --- a/test/class/sonarqube.class.php +++ /dev/null @@ -1,99 +0,0 @@ -objectModel = $tester->loadModel('sonarqube'); - } - - public function apiCreateProjectTest($sonarqubeID, $project = array()) - { - $result = $this->objectModel->apiCreateProject($sonarqubeID, (object)$project); - - if($result === false) $result = 'return false'; - if(isset($result->errors)) $result = $result->errors; - return $result; - } - - public function createProjectTest($sonarqubeID, $post) - { - $_POST['projectName'] = $post['projectName']; - $_POST['projectKey'] = $post['projectKey']; - - $result = $this->objectModel->createProject($sonarqubeID); - $errors = dao::getError(); - if($errors) - { - if(current($errors) == "项目标识的格式不正确。允许的字符为字母、数字、'-'、''、'.'和“:”,至少有一个非数字。") return 'return error'; - if(current($errors) == false) return 'return false'; - return $errors; - } - else - { - if(empty($result)) $result = 'return false'; - return $result; - } - } - - public function apiDeleteProjectTest($sonarqubeID, $projectKey) - { - $result = $this->objectModel->apiDeleteProject($sonarqubeID, $projectKey); - - if($result === false) $result = 'return false'; - if($result === null) $result = 'return true'; - if(isset($result->errors)) $result = $result->errors; - return $result; - } - - public function apiGetIssuesTest($sonarqubeID, $projectKey = '') - { - $result = $this->objectModel->apiGetIssues($sonarqubeID, $projectKey); - - if(empty($result)) $result = 'return empty'; - if(isset($result[0]->message)) $result = true; - return $result; - } - - public function apiGetProjectsTest($sonarqubeID, $keyword = '') - { - $result = $this->objectModel->apiGetProjects($sonarqubeID, $keyword); - - if(empty($result)) $result = 'return empty'; - if($keyword == '' and isset($result[0]->name)) $result = true; - if($keyword != '' and strpos($result[0]->name, $keyword) !== false) $result = true; - return $result; - } - - public function apiValidateTest($sonarqubeID, $url = '', $token = '') - { - global $tester; - $sonarqubeServer = $tester->loadModel('pipeline')->getByID($sonarqubeID); - $url = $url ? $url : $sonarqubeServer->url; - $token = $token ? $token : $sonarqubeServer->token; - - $result = $this->objectModel->apiValidate($url, $token); - - if(empty($result)) $result = 'success'; - if(isset($result['password'])) $result = 'return false'; - if(isset($result['account'])) $result = 'return false'; - return $result; - } - - public function getApiBaseTest($sonarqubeID) - { - list($apiRoot, $header) = $this->objectModel->getApiBase($sonarqubeID); - - if(empty($apiRoot)) return 'return empty'; - return $apiRoot; - } - - public function getCacheFile($sonarqubeID, $projectKey) - { - $result = $this->objectModel->getCacheFile($sonarqubeID, $projectKey); - - if(strPos($result, '/' . $sonarqubeID . '-' ) !== false) return true; - return $result; - } -} diff --git a/test/class/sso.class.php b/test/class/sso.class.php deleted file mode 100644 index 57753a8b63..0000000000 --- a/test/class/sso.class.php +++ /dev/null @@ -1,29 +0,0 @@ -objectModel = $tester->loadModel('sso'); - } - - /** - * Test create a user. - * - * @param array $param - * @access public - * @return void - */ - public function createTest($param = array()) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $result = $this->objectModel->createUser(); - - unset($_POST); - if($result['status'] == 'fail') return 'fail'; - - $object = $this->objectModel->getBindUser($param['account']); - return $object; - } -} diff --git a/test/class/stage.class.php b/test/class/stage.class.php deleted file mode 100644 index 13901a41a6..0000000000 --- a/test/class/stage.class.php +++ /dev/null @@ -1,137 +0,0 @@ -objectModel = $tester->loadModel('stage'); - } - - /** - * Test create a stage. - * - * @param object $stage - * @param string $type - * @access public - * @return object - */ - public function createTest($stage, $type = 'waterfall') - { - foreach($stage as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create($type); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($objectID, $type); - return $object; - } - - /** - * Test batch create stages. - * - * @param array $param - * @param string $type - * @access public - * @return int - */ - public function batchCreateTest($param ,$type = 'waterfall') - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->batchCreate($type); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getStages('id_desc', 0, $type); - return count($objects); - } - - /** - * Test update a stage. - * - * @param int $stageID - * @param array $param - * @access public - * @return array - */ - public function updateTest($stageID, $param) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->update($stageID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get stages. - * - * @param string $orderBy - * @access public - * @return array - */ - public function getStagesTest($orderBy = 'id_desc') - { - $objects = $this->objectModel->getStages($orderBy = 'id_desc'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get pairs of stage. - * - * @access public - * @return array - */ - public function getPairsTest() - { - $objects = $this->objectModel->getPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get a stage by id. - * - * @param int $stageID - * @access public - * @return object - */ - public function getByIDTest($stageID) - { - $object = $this->objectModel->getByID($stageID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get a stage by id. - * - * @param string $projectType - * @access public - * @return object - */ - public function getTotalPercentTest($projectType) - { - $object = $this->objectModel->getTotalPercent($projectType); - - if(dao::isError()) return dao::getError(); - - return $object; - } -} diff --git a/test/class/stakeholder.class.php b/test/class/stakeholder.class.php deleted file mode 100644 index 22a70a6087..0000000000 --- a/test/class/stakeholder.class.php +++ /dev/null @@ -1,113 +0,0 @@ -objectModel = $tester->loadModel('stakeholder'); - } - - /** - * Function create test by stakeholder - * - * @param int $objectID - * @param array $param - * @access public - * @return array - */ - public function createTest($objectID, $param = array()) - { - $createFields = array('from' => '', 'key' => '', 'user' => '', 'name' => '', 'phone' => '', 'qq' => '', 'weixin' => '', - 'email' => '', 'company' => '', 'nature' => '', 'analysis' => '', 'strategy' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create($objectID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($objectID); - - return $objects; - } - - /** - * Function batchCreate test by stakeholder - * - * @param int $projectID - * @param array $param - * @access public - * @return array - */ - public function batchCreateTest($projectID, $param = array()) - { - $realnames = array(); - $accounts = array(); - - $createFields = array('realnames' => $realnames, 'accounts' => $accounts); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->batchCreate($projectID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function edit test by stakeholder - * - * @param int $stakeholderID - * @param array $param - * @access public - * @return array - */ - public function editTest($stakeholderID, $param = array()) - { - $createFields = array('key' => '', 'nature' => '', 'analysis' => '', 'strategy' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->edit($stakeholderID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Function communicate test by stakeholder - * - * @param int $stakeholderID - * @param array $param - * @access public - * @return array - */ - public function communicateTest($stakeholderID, $param = array()) - { - global $tester; - $createFields = array('comment' => ''); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->communicate($stakeholderID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_ACTION)->where('objectID')->eq($stakeholderID)->andwhere('objectType')->eq('stakeholder')->fetchAll(); - return $objects; - } -} diff --git a/test/class/story.class.php b/test/class/story.class.php deleted file mode 100644 index 18d111159c..0000000000 --- a/test/class/story.class.php +++ /dev/null @@ -1,530 +0,0 @@ -objectModel = $tester->loadModel('story'); - } - - /** - * Test get by id. - * - * @param int $storyID - * @param int $version - * @access public - * @return void - */ - public function getByIdTest($storyID, $version = 0) - { - $story = $this->objectModel->getById($storyID, $version); - - if(dao::isError()) return dao::getError(); - - return $story; - } - - /** - * Test get by list. - * - * @param int $storyIdList - * @param string $type - * @access public - * @return void - */ - public function getByListTest($storyIdList = 0, $type = 'story') - { - $stories = $this->objectModel->getByList($storyIdList, $type); - - if(dao::isError()) return dao::getError(); - - return $stories; - } - - /** - * Test get test stories. - * - * @param array $storyIdList - * @param int $executionID - * @access public - * @return void - */ - public function getTestStoriesTest($storyIdList, $executionID) - { - $objects = $this->objectModel->getTestStories($storyIdList, $executionID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get story specs. - * - * @param array $storyIdList - * @access public - * @return void - */ - public function getStorySpecsTest($storyIdList) - { - $objects = $this->objectModel->getStorySpecs($storyIdList); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get affected scope. - * - * @param int $storyID - * @access public - * @return void - */ - public function getAffectedScopeTest($storyID) - { - global $tester; - $story = $tester->loadModel('story')->getById($storyID); - $scope = $this->objectModel->getAffectedScope($story); - - if(dao::isError()) return dao::getError(); - - return $scope; - } - - /** - * Test get requierements. - * - * @param int $productID - * @access public - * @return void - */ - public function getRequierementsTest($productID) - { - $requirements = $this->objectModel->getRequierements($productID); - - if(dao::isError()) return dao::getError(); - - return $requirements; - } - - /** - * Test create story. - * - * @param int $executionID - * @param int $bugID - * @param string $from - * @param string $extra - * @param string $params - * @access public - * @return void - */ - public function createTest($executionID = 0, $bugID = 0, $from = '', $extra = '', $params = '') - { - $_POST = $params; - $result = $this->objectModel->create($executionID, $bugID, $from, $extra); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $storyID = $result['id']; - return $tester->loadModel('story')->getById($storyID); - } - - /** - * Test create story from gitlab issue. - * - * @param int $story - * @param int $executionID - * @access public - * @return void - */ - public function createStoryFromGitlabIssueTest($story, $executionID) - { - $storyID = $this->objectModel->createStoryFromGitlabIssue($story, $executionID); - - if(dao::isError()) return dao::getError(); - - global $tester; - return $tester->loadModel('story')->getById($storyID); - } - - /** - * Test batch create stories. - * - * @param int $productID - * @param int $branch - * @param string $type - * @param array $params - * @access public - * @return void - */ - public function batchCreateTest($productID = 0, $branch = 0, $type = 'story', $params = '') - { - $_POST = $params; - $results = $this->objectModel->batchCreate($productID, $branch, $type); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - foreach($results as $result) $storyIdList[] = $result->storyID; - - global $tester; - $stories = $tester->loadModel('story')->getByList($storyIdList); - return $stories; - } - - /** - * Test change story. - * - * @param int $storyID - * @param array $params - * @access public - * @return void - */ - public function changeTest($storyID, $params) - { - $_POST = $params; - $this->objectModel->change($storyID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - return $tester->loadModel('story')->getById($storyID); - } - - /** - * Test update story. - * - * @param int $storyID - * @param array $params - * @access public - * @return void - */ - public function updateTest($storyID, $params) - { - $_POST = $params; - $this->objectModel->update($storyID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $this->objectModel->getById($storyID); - } - - /** - * Test update story order of plan. - * - * @param int $storyID - * @param string $planIDList - * @param string $oldPlanIDList - * @access public - * @return void - */ - public function updateStoryOrderOfPlanTest($storyID, $planIDList = '', $oldPlanIDList = '') - { - $this->objectModel->updateStoryOrderOfPlan($storyID, $planIDList, $oldPlanIDList); - - if(dao::isError()) return dao::getError(); - - global $tester; - return $tester->dao->select('*')->from(TABLE_PLANSTORY)->where('plan')->in($planIDList)->fetchAll(); - } - - /** - * Test compute estimate. - * - * @param int $storyID - * @access public - * @return void - */ - public function computeEstimateTest($storyID) - { - $this->objectModel->computeEstimate($storyID); - - if(dao::isError()) return dao::getError(); - - return $this->objectModel->getByID($storyID); - } - - /** - * Test batch update stories. - * - * @access public - * @return void - */ - public function batchUpdateTest($params) - { - $_POST = $params; - $allStories = $this->objectModel->batchUpdate(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($allStories); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test review story. - * - * @param int $storyID - * @param array $params - * @access public - * @return void - */ - public function reviewTest($storyID, $params) - { - $_POST = $params; - $changes = $this->objectModel->review($storyID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $this->objectModel->getByID($storyID); - } - - /** - * Test batch review. - * - * @param int $storyIdList - * @param int $result - * @param int $reason - * @access public - * @return void - */ - public function batchReviewTest($storyIdList, $result, $reason) - { - $actions = $this->objectModel->batchReview($storyIdList, $result, $reason); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($actions); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test story subdivide. - * - * @param int $storyID - * @param array $stories - * @access public - * @return void - */ - public function subdivideTest($storyID, $stories, $type) - { - $this->objectModel->subdivide($storyID, $stories); - - if(dao::isError()) return dao::getError(); - - global $tester; - if($type == 'requirement') - { - return $tester->dao->select('*')->from(TABLE_RELATION)->where('AID')->eq($storyID)->andWhere('AType')->eq($type)->fetchAll(); - } - else - { - return $this->objectModel->getById($storyID); - } - } - - /** - * Test close a story. - * - * @param int $storyID - * @param array $params - * @access public - * @return void - */ - public function closeTest($storyID, $params) - { - $_POST = $params; - $changes = $this->objectModel->close($storyID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $changes; - } - - /** - * Test batch close story. - * - * @param array $params - * @access public - * @return void - */ - public function batchCloseTest($params) - { - $_POST = $params; - $changes = $this->objectModel->batchClose(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test batch change story module. - * - * @param int $storyIdList - * @param int $moduleID - * @access public - * @return void - */ - public function batchChangeModuleTest($storyIdList, $moduleID) - { - $changes = $this->objectModel->batchChangeModule($storyIdList, $moduleID); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test batch change story plan. - * - * @param arary $storyIdList - * @param int $planID - * @param int $oldPlanID - * @access public - * @return void - */ - public function batchChangePlanTest($storyIdList, $planID, $oldPlanID = 0) - { - $changes = $this->objectModel->batchChangePlan($storyIdList, $planID, $oldPlanID); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test batch change story branch. - * - * @param arary $storyIdList - * @param int $branchID - * @param string $confirm - * @param array $plans - * @access public - * @return void - */ - public function batchChangeBranchTest($storyIdList, $branchID, $confirm = '', $plans = array()) - { - $changes = $this->objectModel->batchChangeBranch($storyIdList, $branchID, $confirm, $plans); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test batch change stage. - * - * @param arrau $storyIdList - * @param string $stage - * @access public - * @return void - */ - public function batchChangeStageTest($storyIdList, $stage) - { - $changes = $this->objectModel->batchChangeStage($storyIdList, $stage); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test story batch to task. - * - * @param int $executionID - * @param int $projectID - * @param array $params - * @access public - * @return void - */ - public function batchToTaskTest($executionID, $projectID = 0, $params = '') - { - $_POST = $params; - $taskIdList = $this->objectModel->batchToTask($executionID, $projectID); - unset($params); - - if(dao::isError()) return dao::getError(); - - global $tester; - return $tester->loadModel('task')->getByList($taskIdList); - } - - /** - * Test assign a story. - * - * @param int $storyID - * @param string $assignedTo - * @access public - * @return void - */ - public function assignTest($storyID, $assignedTo) - { - $_POST['assignedTo'] = $assignedTo; - $this->objectModel->assign($storyID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $this->objectModel->getById($storyID); - } - - /** - * Test batch assign story. - * - * @param array $params - * @access public - * @return void - */ - public function batchAssignToTest($params) - { - $_POST = $params; - $changes = $this->objectModel->batchAssignTo(); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $storyIdList = array_keys($changes); - return $this->objectModel->getByList($storyIdList); - } - - /** - * Test get stories by assignedBy. - * - * @param int $productID - * @param int $branch - * @access public - * @return string - */ - public function getByAssignedByTest($productID, $branch) - { - global $tester; - $stories = $this->objectModel->getByAssignedBy($productID, $branch, $modules = array(), $account = $tester->app->user->account, $type = 'story', $orderBy = '', $pager = null); - - $title = ''; - foreach($stories as $story) - { - $title .= ',' . $story->title; - } - $title = trim($title, ','); - $title = str_replace("'", '', $title); - - if(dao::isError()) return dao::getError(); - - return $title; - } -} diff --git a/test/class/testcase.class.php b/test/class/testcase.class.php deleted file mode 100644 index 73723830a0..0000000000 --- a/test/class/testcase.class.php +++ /dev/null @@ -1,755 +0,0 @@ -objectModel = $tester->loadModel('testcase'); - } - - /** - * Test create a case. - * - * @param array $param - * @access public - * @return array - */ - public function createTest($param) - { - $bugID = 0; - - $_POST['product'] = '1'; - $_POST['module'] = '1821'; - $_POST['type'] = 'feature'; - $_POST['stage'] = array('', 'unittest'); - $_POST['story'] = '4'; - $_POST['color'] = ''; - $_POST['pri'] = '3'; - $_POST['precondition'] = '前置条件'; - $_POST['steps'] = array('1' => '1','1.1' => '1.1', '1.2' => '1.2', '2' => '2', '3' => '3', '4' => ''); - $_POST['stepType'] = array('1' => 'group','1.1' => 'item', '1.2' => 'item', '2' => 'step', '3' => 'item', '4' => 'step'); - $_POST['expects'] = array('1' => '','1.1' => '', '1.2' => '', '2' => '', '3' => '', '4' => ''); - $_POST['keywords'] = '关键词1,关键词2'; - $_POST['status'] = 'normal'; - $_POST['labels'] = array(''); - $_POST['files'] = array(''); - - foreach($param as $field => $value) $_POST[$field] = $value; - - $objects = $this->objectModel->create($bugID); - - unset($_POST); - - if(dao::isError()) return isset($param['type']) ? dao::getError()['type'][0] : dao::getError()['title'][0]; - - return $objects; - } - - /** - * Test batch create cases. - * - * @param array $param - * @access public - * @return int - */ - function batchCreateTest($param) - { - $productID = 1; - $branch = 0; - $storyID = 0; - - $module = array(0, 0, 0); - $story = array(0, 0, 0); - $title = array('测试批量创建1', '测试批量创建2', '测试批量创建3'); - $color = array('#3da7f5', '', '#ffaf38'); - $type = array('performance', 'config', 'install'); - $pri = array('1', '2', '3'); - $precondition = array('测试批量创建前置1', '测试批量创建前置2', '测试批量创建前置3'); - $keywords = array('测试批量创建关键词1', '测试批量创建关键词2', '测试批量创建关键词3'); - $stage = array(array('smoke'), array('bvt'), array('intergrate')); - $needReview = array(0, 0, 0); - - $_POST['module'] = $module; - $_POST['story'] = $story; - $_POST['title'] = $title; - $_POST['color'] = $color; - $_POST['type'] = $type; - $_POST['pri'] = $pri; - $_POST['precondition'] = $precondition; - $_POST['keywords'] = $keywords; - $_POST['stage'] = $stage; - $_POST['needReview'] = $needReview; - - foreach($param as $field => $value) $_POST[$field] = $value; - - $objects = $this->objectModel->batchCreate($productID, $branch, $storyID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get cases of a module. - * - * @param int $productID - * @param int $branch - * @param int $moduleIdList - * @param string $browseType - * @param string $auto - * @param string $caseType - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getModuleCasesTest($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getModuleCases($productID, $branch, $moduleIdList, $browseType, $auto, $caseType, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get project cases of a module. - * - * @param int $productID - * @param int $branch - * @param int $moduleIdList - * @param string $browseType - * @param string $auto - * @param string $caseType - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getModuleProjectCasesTest($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getModuleProjectCases($productID, $branch, $moduleIdList, $browseType, $auto, $caseType, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get execution cases. - * - * @param int $executionID - * @param string $orderBy - * @param object $pager - * @param string $browseType - * @access public - * @return string - */ - public function getExecutionCasesTest($executionID, $orderBy = 'id_desc', $pager = null, $browseType = '') - { - $objects = $this->objectModel->getExecutionCases($executionID, $orderBy, $pager, $browseType); - - if(dao::isError()) return dao::getError(); - - return $browseType == 'all' ? $objects : count($objects); - } - - /** - * Test get cases by suite. - * - * @param int $productID - * @param int $branch - * @param int $suiteID - * @param int $moduleIdList - * @param string $orderBy - * @param object $pager - * @param string $auto - * @access public - * @return array - */ - public function getBySuiteTest($productID, $branch = 0, $suiteID = 0, $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $auto = 'no') - { - $objects = $this->objectModel->getBySuite($productID, $branch, $suiteID, $moduleIdList, $orderBy, $pager, $auto); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get case info by ID. - * - * @param int $caseID - * @param int $version - * @access public - * @return object - */ - public function getByIdTest($caseID, $version = 0) - { - $object = $this->objectModel->getById($caseID, $version = 0); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get case list. - * - * @param string $caseIDList - * @access public - * @return array - */ - public function getByListTest($caseIDList = 0) - { - $objects = $this->objectModel->getByList($caseIDList = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get test cases. - * - * @param int $productID - * @param string $browseType - * @param int $queryID - * @param string $auto - * @access public - * @return array - */ - public function getTestCasesTest($productID, $browseType, $queryID, $auto = 'no') - { - $objects = $this->objectModel->getTestCases($productID, 0, $browseType, $queryID, $moduleID, '', 'id_desc', null, $auto); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get cases by assignedTo. - * - * @param string $account - * @param string $orderBy - * @param object $pager - * @param string $auto - * @access public - * @return string - */ - public function getByAssignedToTest($account, $orderBy = 'id_desc', $pager = null, $auto = 'no') - { - $objects = $this->objectModel->getByAssignedTo($account, $orderBy = 'id_desc', $pager = null, $auto = 'no'); - - if(dao::isError()) return dao::getError(); - - $ids = implode(array_keys($objects), ','); - return $ids; - } - - /** - * Test get cases by openedBy - * - * @param string $account - * @param string $orderBy - * @param object $pager - * @param string $auto - * @access public - * @return array - */ - public function getByOpenedByTest($account, $orderBy = 'id_desc', $pager = null, $auto = 'no') - { - $objects = $this->objectModel->getByOpenedBy($account, $orderBy = 'id_desc', $pager = null, $auto = 'no'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get cases by type. - * - * @param int $productID - * @param int $branch - * @param string $type - * @param string $status - * @param int $moduleID - * @param string $orderBy - * @param object $pager - * @param string $auto - * @access public - * @return int - */ - public function getByStatusTest($productID = 0, $branch = 0, $type = 'all', $status = 'all', $moduleID = 0, $orderBy = 'id_desc', $pager = null, $auto = 'no') - { - $objects = $this->objectModel->getByStatus($productID, $branch, $type, $status, $moduleID, $orderBy, $pager, $auto); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get stories' cases. - * - * @param int $storyID - * @access public - * @return array - */ - public function getStoryCasesTest($storyID) - { - $objects = $this->objectModel->getStoryCases($storyID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get case pairs by product id and branch. - * - * @param int $productID - * @param int $branch - * @access public - * @return array - */ - public function getPairsByProductTest($productID = 0, $branch = 0) - { - $objects = $this->objectModel->getPairsByProduct($productID, $branch); - - if(dao::isError()) return dao::getError(); - - if(empty($objects)) return 'empty'; - return $objects; - } - - /** - * Test get counts of some stories' cases. - * - * @param array $stories - * @access public - * @return void - */ - public function getStoryCaseCountsTest($stories) - { - $counts = $this->objectModel->getStoryCaseCounts($stories); - - if(dao::isError()) return dao::getError(); - - return $counts; - } - - /** - * Test update a case. - * - * @param array $param - * @access public - * @return int - */ - public function updateTest($param = array()) - { - $caseId = 1; - $case = $this->objectModel->getById($caseId); - - $_POST['title'] = $case->title; - $_POST['color'] = $case->color; - $_POST['precondition'] = $case->precondition; - $_POST['steps'] = array('用例步骤描述1'); - $_POST['stepType'] = array('step'); - $_POST['expects'] = array('这是用例预期结果1'); - $_POST['comment'] = ''; - $_POST['labels'] = ''; - $_POST['lastEditedDate'] = $case->lastEditedDate; - $_POST['product'] = $case->product; - $_POST['module'] = $case->module; - $_POST['story'] = $case->story; - $_POST['type'] = $case->type; - $_POST['stage'] = $case->stage; - $_POST['pri'] = $case->pri; - $_POST['status'] = $case->status; - $_POST['keywords'] = $case->keywords; - - foreach($param as $field => $value) $_POST[$field] = $value; - - $change = $this->objectModel->update('1'); - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test review case. - * - * @param int $caseID - * @param object $case - * @access public - * @return array - */ - public function reviewTest($caseID, $case) - { - foreach($case as $field => $value) $_POST[$field] = $value; - - $objects = $this->objectModel->review($caseID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test batch review cases. - * - * @param array $caseIdList - * @param string $result - * @access public - * @return array - */ - public function batchReviewTest($caseIdList, $result) - { - $objects = $this->objectModel->batchReview($caseIdList, $result); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test batch update cases. - * - * @param array $param - * @access public - * @return array - */ - public function batchUpdateTest($index, $param = array()) - { - $batchUpdateField['caseIDList'] = array('1' => 1, '2' => 2, '3' => 3, '4' => 4); - $batchUpdateField['pris'] = array('1' => 1, '2' => 2, '3' => 3, '4' => 4); - $batchUpdateField['statuses'] = array('1' => 'wait', '2' => 'normal', '3' => 'blocked', '4' => 'investigate'); - $batchUpdateField['modules'] = array('1' => 0, '2' => 0, '3' => 0, '4' => 0); - $batchUpdateField['branches'] = array('1' => 0, '2' => 0, '3' => 0, '4' => 0); - $batchUpdateField['story'] = array('1' => 2, '2' => 2, '3' => 2, '4' => 2); - $batchUpdateField['product'] = array('1' => 1, '2' => 1, '3' => 1, '4' => 1); - $batchUpdateField['title'] = array('1' => '这个是测试用例1', '2' => '这个是测试用例2', '3' => '这个是测试用例3', '4' => '这个是测试用例4'); - $batchUpdateField['color'] = array('1' => '#3da7f5', '2' => '#75c941', '3' => '#2dbdb2', '4' => '#797ec9'); - $batchUpdateField['types'] = array('1' => 'feature', '2' => 'performance', '3' => 'config', '4' => 'install'); - $batchUpdateField['precondition'] = array('1' => '这是前置条件1', '2' => '这是前置条件2', '3' => '这是前置条件3', '4' => '这是前置条件4'); - $batchUpdateField['keywords'] = array('1' => '这是关键词1', '2' => '这是关键词2', '3' => '这是关键词3', '4' => '这是关键词4'); - $batchUpdateField['stages'] = array('1' => array('unittest'), '2' => array('feature'), '3' => array('intergrate'), '4' => array('system')); - - foreach($batchUpdateField as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->batchUpdate(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects[$index][0]; - } - - /** - * Test batch change branch. - * - * @param array $caseIDList - * @param int $branchID - * @access public - * @return array - */ - public function batchChangeBranchTest($caseIDList, $branchID) - { - $this->objectModel->batchChangeBranch($caseIDList, $branchID); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByList($caseIDList); - return $objects; - } - - /** - * Test batch change module. - * - * @param array $caseIDList - * @param int $moduleID - * @access public - * @return array - */ - public function batchChangeModuleTest($caseIDList, $moduleID) - { - $this->objectModel->batchChangeModule($caseIDList, $moduleID); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByList($caseIDList); - return $objects; - } - - /** - * Test batch case type change. - * - * @param array $caseIdList - * @param string $result - * @access public - * @return array - */ - public function batchCaseTypeChangeTest($caseIdList, $result) - { - $this->objectModel->batchCaseTypeChange($caseIdList, $result); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByList($caseIdList); - return $objects; - } - - /** - * Test join steps to a string, thus can diff them. - * - * @param array $stepIDList - * @access public - * @return string - */ - public function joinStepTest($stepIDList) - { - global $tester; - $steps = $tester->dao->select('*')->from(TABLE_CASESTEP)->where('id')->in($stepIDList)->fetchAll(); - - $string = $this->objectModel->joinStep($steps); - - if(dao::isError()) return dao::getError(); - - $string = str_replace("\n", ' ', $string); - return $string; - } - - /** - * Test create from import. - * - * @param int $productID - * @param array $param - * @access public - * @return string - */ - public function createFromImportTest($productID, $param = array()) - { - global $tester; - - $_POST['product'] = array('1' => '1', '2' => '1'); - $_POST['keywords'] = array('1' => '这是关键词1', '2' => '这是关键词2'); - $_POST['title'] = array('1' => '导入测试用例1', '2' => '导入测试用例2'); - $_POST['module'] = array('1' => '0', '2' => '0'); - $_POST['story'] = array('1' => '2', '2' => '2'); - $_POST['pri'] = array('1' => '1', '2' => '2'); - $_POST['type'] = array('1' => 'performance', '2' => 'feature'); - $_POST['stage'] = array('1' => array('0' => 'feature'), '2' => array('0' => 'unittest')); - $_POST['precondition'] = array('1' => '这是前置条件1', '2' => '这是前置条件2'); - $_POST['stepType'] = array('1' => array('1' => 'step'), '2' => array('1' => 'step')); - $_POST['desc'] = array('1' => array('1' => '用例步骤描述1'), '2' => array('1' => '用例步骤描述2')); - $_POST['expect'] = array('1' => array('1' => '这是用例预期结果1'), '2' => array('1' => '这是用例预期结果2')); - $_POST['isEndPage'] = '1'; - $_POST['pagerID'] = '1'; - - foreach($param as $field => $value) $_POST[$field] = $value; - - $fileName = __DIR__ . DS . 'a.txt'; - fopen($fileName, 'a'); - $tester->session->fileImport = $fileName; - - $this->objectModel->createFromImport($productID, 0); - - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_CASE)->where('product')->eq(1)->andWhere('lib')->eq(0)->markLeft()->andWhere('id')->gt(560)->orWhere('id')->in('1,2')->markRight()->fetchAll('title'); - $titles = implode(',', array_keys($objects)); - return $titles; - } - - /** - * Test get fields for import. - * - * @param int $productID - * @access public - * @return array - */ - public function getImportFieldsTest($productID = 0) - { - $object = $this->objectModel->getImportFields($productID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test import case from Lib. - * - * @param int $productID - * @param array $caseIdList - * @access public - * @return array - */ - public function importFromLibTest($productID, $caseIdList = array()) - { - $_POST['module'] = array('410' => 0, '409' => 'ditto', '408' => 'ditto', '407' => 'ditto', '406' => 'ditto', '405' => 'ditto', '404' => 'ditto', '403' => 'ditto', '402' => 'ditto', '401' => 'ditto'); - $_POST['caseIdList'] = $caseIdList; - - $this->objectModel->importFromLib($productID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_CASE)->where('fromCaseID')->in($caseIdList)->orderBy('id_asc')->fetchAll(); - return $objects; - } - - /** - * Test append bugs and results. - * - * @param array $cases - * @param string $type - * @access public - * @return array - */ - public function appendDataTest($cases, $type = 'case') - { - $objects = $this->objectModel->appendData($cases, $type = 'case'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test check whether force not review. - * - * @access public - * @return int - */ - public function forceNotReviewTest() - { - $object = $this->objectModel->forceNotReview(); - - if(dao::isError()) return dao::getError(); - - return $object ? 1 : 2; - } - - /** - * Test sync case to project. - * - * @param int $caseID - * @access public - * @return int - */ - public function syncCase2ProjectTest($caseID) - { - global $tester; - $tester->dao->delete()->from(TABLE_PROJECTCASE)->where('`case`')->eq($caseID)->exec(); - $case = $this->objectModel->getByID($caseID); - $this->objectModel->syncCase2Project($case, $caseID); - - if(dao::isError()) return dao::getError(); - - $objects = $tester->dao->select('*')->from(TABLE_PROJECTCASE)->where('`case`')->eq($caseID)->fetchAll(); - return count($objects); - } - - /** - * Test deal with the relationship between the case and project when edit the case. - * - * @param int $caseID - * @param string $objectType - * @param int $objectID - * @access public - * @return array - */ - public function updateCase2ProjectTest($caseID, $objectType, $objectID) - { - $oldCase = $this->objectModel->getByID($caseID); - - $case = new stdclass(); - $case->title = $oldCase->title; - $case->color = $oldCase->color; - $case->precondition = $oldCase->precondition; - $case->lastEditedDate = $oldCase->lastEditedDate; - $case->product = $objectType == 'product' ? $objectID : $oldCase->product; - $case->module = $oldCase->module; - $case->story = $objectType == 'story' ? $objectID : $oldCase->story; - $case->type = $oldCase->type; - $case->stage = $oldCase->stage; - $case->pri = $oldCase->pri; - $case->status = $oldCase->status; - $case->keywords = $oldCase->keywords; - $case->version = $oldCase->version + 1; - $case->linkCase = $oldCase->linkCase; - $case->lastEditedBy = $oldCase->lastEditedBy; - $case->branch = $oldCase->branch; - - $this->objectModel->updateCase2Project($oldCase, $case, $caseID); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_PROJECTCASE)->where('`case`')->eq($caseID)->fetchAll(); - return $objects; - } - - /** - * Test get status for different method. - * - * @param string $methodName - * @param object $case - * @param array $param - * @access public - * @return array - */ - public function getStatusTest($methodName, $case = null, $param = array()) - { - if($methodName == 'update') - { - $case = $this->objectModel->getByID(1); - $_POST['title'] = $case->title; - $_POST['color'] = $case->color; - $_POST['precondition'] = $case->precondition; - $_POST['steps'] = array('用例步骤描述1'); - $_POST['stepType'] = array('step'); - $_POST['expects'] = array('这是用例预期结果1'); - $_POST['comment'] = ''; - $_POST['labels'] = ''; - $_POST['lastEditedDate'] = $case->lastEditedDate; - $_POST['product'] = $case->product; - $_POST['module'] = $case->module; - $_POST['story'] = $case->story; - $_POST['type'] = $case->type; - $_POST['stage'] = $case->stage; - $_POST['pri'] = $case->pri; - $_POST['status'] = $case->status; - $_POST['keywords'] = $case->keywords; - - foreach($param as $field => $value) $_POST[$field] = $value; - } - - $objects = $this->objectModel->getStatus($methodName, $case); - - unset($_POST); - - if(dao::isError()) return dao::getError()[0]; - - return $objects; - } -} diff --git a/test/class/testreport.class.php b/test/class/testreport.class.php deleted file mode 100644 index bcf94153c6..0000000000 --- a/test/class/testreport.class.php +++ /dev/null @@ -1,266 +0,0 @@ -objectModel = $tester->loadModel('testreport'); - $this->testtask = $tester->loadModel('testtask'); - $this->build = $tester->loadModel('build'); - $app->loadLang('bug'); - } - - /** - * Create report. - * - * @access public - * @return int - */ - public function createTest($param) - { - $begin_date = date('Y-m-d'); - $end_date = date('Y-m-d',strtotime("+7 day")); - $builds = array('11'); - $labels = array(); - - $createFields = array('begin' => $begin_date, 'end' => $end_date, 'product' => '1', 'execution' => '101', 'tasks' => '1', 'objectID' => '1', 'objectType' => 'testtask', 'owner' => '', 'title' => '', 'report' => '', 'labels' => $labels, 'builds' => $builds, 'cases' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $reportID = $this->objectModel->create(); - unset($_POST); - if(dao::isError()) return dao::getError(); - $objects = $this->objectModel->getByID($reportID); - return $objects; - } - - public function updateTest($reportID, $param) - { - $report = $this->objectModel->getByID($reportID); - - $begin_date = $report->begin; - $end_date = $report->end; - $builds = $report->builds; - $labels = array(); - - $createFields = array('begin' => $begin_date, 'end' => $end_date, 'product' => $report->product, 'execution' => $report->execution, 'tasks' => $report->tasks, 'objectID' => $report->objectID, 'objectType' => $report->objectType, 'owner' => '', 'title' => '', 'report' => '', 'labels' => $labels, 'builds' => $builds, 'cases' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->update($reportID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $objects = $this->objectModel->getByID($reportID); - return $objects; - } - - /** - * Get report by id. - * - * @param int $reportID - * @access public - * @return object - */ - - public function getByIdTest($reportID) - { - $objects = $this->objectModel->getById($reportID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get report list. - * - * @param int $objectID - * @param string $objectType - * @access public - * @return array - */ - public function getListTest($objectID, $objectType, $extra = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getList($objectID, $objectType, $extra, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get bug info and summary. - * - * @param array $tasksIDs - * @param array $productIdList - * @param int $reportID - * @param array $buildIDs - * @access public - * @return array - */ - public function getBug4ReportTest($taskIDs, $productIdList, $reportID, $buildIDs) - { - $tasks = $taskIDs ? $this->testtask->getByList($taskIDs) : array(); - $builds = $buildIDs ? $this->build->getByList($buildIDs) : array(); - $report = $this->objectModel->getByID($reportID); - - $objects = $this->objectModel->getBug4Report($tasks, $productIdList, $report->begin, $report->end, $builds); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get task cases. - * - * @param array $taskID - * @param int $reportID - * @access public - * @return array - */ - - public function getTaskCasesTest($taskID, $reportID, $idList = '', $pager = null) - { - $task = $taskID ? $this->testtask->getByList($taskID) : array(); - $report = $this->objectModel->getByID($reportID); - - $objects = $this->objectModel->getTaskCases($task, $report->begin, $report->end, $idList, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get caseID list. - * - * @param int $reportID - * @access public - * @return array - */ - - public function getCaseIdListTest($reportID) - { - $objects = $this->objectModel->getCaseIdList($reportID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get result summary. - * - * @param int $taskID - * @param int $reportID - * @access public - * @return string - */ - - public function getResultSummaryTest($taskID, $reportID) - { - $tasks = $taskID ? $this->testtask->getByList($taskID) : array(); - $report = $this->objectModel->getByID($reportID); - $cases = $this->objectModel->getTaskCases($tasks, $report->begin, $report->end); - - $objects = $this->objectModel->getResultSummary($tasks, $cases, $report->begin, $report->end); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get per run result for testreport. - * - * @param int $taskID - * @param int $reportID - * @access public - * @return string - */ - - public function getPerCaseResult4ReportTest($taskID, $reportID) - { - $tasks = $taskID ? $this->testtask->getByList($taskID) : array(); - $report = $this->objectModel->getByID($reportID); - - $objects = $this->objectModel->getPerCaseResult4Report($tasks, $report->cases, $report->begin, $report->end); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get per case runner for testreport. - * - * @param int $taskID - * @param int $reportID - * @access public - * @return string - */ - - public function getPerCaseRunner4ReportTest($taskID, $reportID) - { - $tasks = $taskID ? $this->testtask->getByList($taskID) : array(); - $report = $this->objectModel->getByID($reportID); - $objects = $this->objectModel->getPerCaseRunner4Report($tasks, $report->cases, $report->begin, $report->end); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get bugs for test - * - * @param array $builds - * @param array $product - * @param string $begin - * @param string $end - * @param string $type - * @access public - * @return void - */ - - public function getBugs4TestTest($buildIdList, $product, $taskID, $type = 'build') - { - $task = $this->testtask->getByID($taskID); - $builds = $this->build->getByList($buildIdList); - $begin = !empty($begin) ? date("Y-m-d", strtotime($begin)) : $task->begin; - $end = !empty($end) ? date("Y-m-d", strtotime($end)) : $task->end; - $objects = $this->objectModel->getBugs4Test($builds, $product, $begin, $end, $type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get stories for test - * - * @param array $builds - * @return void - */ - public function getStories4TestTest($buildIdList) - { - $builds = $this->build->getByList($buildIdList); - $objects = $this->objectModel->getStories4Test($builds); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** - * Get pairs. - * - * @param int $productID - * @access public - * @return array - */ - public function getPairsTest($productID = 0) - { - $objects = $this->objectModel->getPairs($productID); - if(dao::isError()) return dao::getError(); - if($objects) $objects = array_keys($objects); - return $objects; - } -} diff --git a/test/class/testsuite.class.php b/test/class/testsuite.class.php deleted file mode 100644 index 9c92031e1a..0000000000 --- a/test/class/testsuite.class.php +++ /dev/null @@ -1,218 +0,0 @@ -objectModel = $tester->loadModel('testsuite'); - } - - public function selectTest($products, $productID, $currentModule, $currentMethod, $extra = '') - { - $objects = $this->objectModel->select($products, $productID, $currentModule, $currentMethod, $extra); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test create a test suite. - * - * @param int $productID - * @param string $name - * @param string $type - * @access public - * @return array|int - */ - public function createTest($productID, $name, $type) - { - $_POST['name'] = $name; - $_POST['desc'] = ''; - $_POST['type'] = $type; - $_POST['uid'] = '62538b850bb9d'; - - $objects = $this->objectModel->create($productID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get test suites of a product. - * - * @param int $productID - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getSuitesTest($productID, $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getSuites($productID, $orderBy, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get unit suite. - * - * @param int $productID - * @param string $orderBy - * @access public - * @return array - */ - public function getUnitSuitesTest($productID, $orderBy = 'id_desc') - { - $objects = $this->objectModel->getUnitSuites($productID, $orderBy); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get test suite info by id. - * - * @param int $suiteID - * @param bool $setImgSize - * @access public - * @return object - */ - public function getByIdTest($suiteID, $setImgSize = false) - { - $objects = $this->objectModel->getById($suiteID, $setImgSize); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test update a test suite. - * - * @param int $suiteID - * @access public - * @return bool|array - */ - public function updateTest($suiteID, $name, $type) - { - $_POST['name'] = $name; - $_POST['desc'] = ''; - $_POST['type'] = $type; - $_POST['uid'] = '62538b850bb9d'; - - $objects = $this->objectModel->update($suiteID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test link cases. - * - * @param int $suiteID - * @param array $cases - * @access public - * @return void - */ - public function linkCaseTest($suiteID, $cases) - { - $_POST['cases'] = $cases; - foreach($cases as $case) - { - $_POST['versions'][$case] = 1; - } - - $this->objectModel->linkCase($suiteID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_SUITECASE)->where('suite')->eq($suiteID)->andWhere('`case`')->in($cases)->fetchAll(); - - return $objects; - } - - /** - * Test get linked cases for suite. - * - * @param int $suiteID - * @param string $orderBy - * @param object $pager - * @param bool $append - * @access public - * @return array - */ - public function getLinkedCasesTest($suiteID, $orderBy = 'id_desc', $pager = null, $append = true) - { - $objects = $this->objectModel->getLinkedCases($suiteID, $orderBy, $pager, $append); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get unlinked cases for suite. - * - * @param int $suiteID - * @param int $param - * @param object $pager - * @access public - * @return array - */ - public function getUnlinkedCasesTest($suiteID, $param = 0, $pager = null) - { - - $suite = $this->objectModel->getById($suiteID); - $objects = $this->objectModel->getUnlinkedCases($suite, $param, $pager); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test delete suite and library. - * - * @param int $suiteID - * @param string $table - * @access public - * @return int - */ - public function deleteTest($suiteID, $table = '') - { - $objects = $this->objectModel->delete($suiteID, $table); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test get not imported cases. - * - * @param int $productID - * @param int $libID - * @param string $orderBy - * @param object $pager - * @access public - * @return array - */ - public function getNotImportedCasesTest($productID, $libID, $orderBy = 'id_desc', $pager = null, $browseType = '', $queryID = 0) - { - $objects = $this->objectModel->getNotImportedCases($productID, $libID, $orderBy, $pager, $browseType, $queryID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/testtask.class.php b/test/class/testtask.class.php deleted file mode 100644 index df515abc6b..0000000000 --- a/test/class/testtask.class.php +++ /dev/null @@ -1,226 +0,0 @@ -objectModel = $tester->loadModel('testtask'); - } - - /** - * Test create testtask. - * - * @param int $projectID - * @param array $params - * @access public - * @return void - */ - public function create($projectID, $params) - { - $_POST = $params; - $taskID = $this->objectModel->create($projectID); - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $this->objectModel->getById($taskID); - } - - public function update($taskID) - { - $objects = $this->objectModel->update($taskID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function startTest($taskID) - { - $objects = $this->objectModel->start($taskID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function closeTest($taskID) - { - $objects = $this->objectModel->close($taskID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function blockTest($taskID) - { - $objects = $this->objectModel->block($taskID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function activateTest($taskID) - { - $objects = $this->objectModel->activate($taskID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function linkCaseTest($taskID, $type) - { - $objects = $this->objectModel->linkCase($taskID, $type); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRunsTest($taskID, $moduleID, $orderBy, $pager = null) - { - $objects = $this->objectModel->getRuns($taskID, $moduleID, $orderBy, $pager = null); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getUserRunsTest($taskID, $user, $modules = '', $orderBy = 'id_desc', $pager = null) - { - $objects = $this->objectModel->getUserRuns($taskID, $user, $modules = '', $orderBy = 'id_desc', $pager = null); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getTaskCasesTest($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task) - { - $objects = $this->objectModel->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getUserTestTaskPairsTest($account, $limit = 0, $status = 'all', $skipProductIDList = array(), $skipExecutionIDList = array()) - { - $objects = $this->objectModel->getUserTestTaskPairs($account, $limit = 0, $status = 'all', $skipProductIDList = array(), $skipExecutionIDList = array()); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getRunByIdTest($runID) - { - $objects = $this->objectModel->getRunById($runID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function createResultTest($runID = 0) - { - $objects = $this->objectModel->createResult($runID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function batchRunTest($runCaseType = 'testcase', $taskID = 0) - { - $objects = $this->objectModel->batchRun($runCaseType = 'testcase', $taskID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getResultsTest($runID, $caseID = 0) - { - $objects = $this->objectModel->getResults($runID, $caseID = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function printCellTest($col, $run, $users, $task, $branches, $mode = 'datatable') - { - $objects = $this->objectModel->printCell($col, $run, $users, $task, $branches, $mode = 'datatable'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getToAndCcListTest($testtask) - { - $objects = $this->objectModel->getToAndCcList($testtask); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function importUnitResultTest($productID) - { - $objects = $this->objectModel->importUnitResult($productID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function processAutoResultTest($testtaskID, $productID, $suites, $cases, $results, $suiteNames = array(), $caseTitles = array(), $auto = 'unit') - { - $objects = $this->objectModel->processAutoResult($testtaskID, $productID, $suites, $cases, $results, $suiteNames = array(), $caseTitles = array(), $auto = 'unit'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function parseCppXMLResultTest($fileName, $productID, $frame) - { - $objects = $this->objectModel->parseCppXMLResult($fileName, $productID, $frame); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function parseXMLResultTest($fileName, $productID, $frame) - { - $objects = $this->objectModel->parseXMLResult($fileName, $productID, $frame); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function parseZTFUnitResultTest($caseResults, $frame, $productID, $jobID, $compileID) - { - $objects = $this->objectModel->parseZTFUnitResult($caseResults, $frame, $productID, $jobID, $compileID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function parseZTFFuncResultTest($caseResults, $frame, $productID, $jobID, $compileID) - { - $objects = $this->objectModel->parseZTFFuncResult($caseResults, $frame, $productID, $jobID, $compileID); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/todo.class.php b/test/class/todo.class.php deleted file mode 100755 index 9ba0799c57..0000000000 --- a/test/class/todo.class.php +++ /dev/null @@ -1,367 +0,0 @@ -objectModel = $tester->loadModel('todo'); - $tester->app->loadClass('dao'); - $_SERVER['HTTP_HOST'] = 'test.zentao.net'; - } - - /** - * Test create a todo. - * - * @param string $account - * @param array $param - * @access public - * @return object - */ - public function createTest($account, $param = array()) - { - $config = array('day' => '', 'specify' => array('month' => 0, 'day' => 1), 'type' => 'day', 'beforeDays' => 0, 'end' => ''); - if(isset($param->date)) $param->date = $param->date == 'today' ? date('Y-m-d',time()) : date('Y-m-d',strtotime('+3 days')); - - $createFields['config'] = $config; - $createFields['type'] = 'custom'; - $createFields['name'] = ''; - $createFields['pri'] = 3; - $createFields['desc'] = ''; - $createFields['status'] = 'wait'; - $createFields['begin'] = '0830'; - $createFields['end'] = '0900'; - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objectID = $this->objectModel->create(date('Y').date('m'), $account); - - unset($_POST); - - if(dao::isError()) return array_values(dao::getError())[0][0]; - - $object = $objectID ? $this->objectModel->getByID($objectID) : 0; - return $object; - } - - /** - * Test batch create todos. - * - * @param array $param - * @access public - * @return array - */ - public function batchCreateTest($param = array()) - { - $createFields['date'] = date('Y-m-d',time()); - - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $objects = $this->objectModel->batchCreate(); - - $todos = $this->objectModel->getByList($objects); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $todos; - } - - /** - * Test update a todo. - * - * @param int $todoID - * @param array $param - * @access public - * @return array - */ - public function updateTest($todoID, $param) - { - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_TODO ." WHERE id = $todoID")->fetch(); - - foreach($object as $field => $value) - { - if(in_array($field, array_keys($param))) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $value; - } - } - - $change = $this->objectModel->update($todoID); - if($change == array()) $change = '没有数据更新'; - - unset($_POST); - if(dao::isError()) return dao::getError(); - - return $change; - } - - /** - * Test batch update todos. - * - * @param array $param - * @param int $todoID - * @access public - * @return array - */ - public function batchUpdateTest($param, $todoID) - { - $todoIDList = array('1' => '1', '2' => '2', '3' => '3'); - $dates = array('1' => date('Y-m-d',strtotime('+1 month')), '2' => date('Y-m-d',strtotime('-1 month +1 day')), '3' => date('Y-m-d',strtotime('-1 month +2 day'))); - $types = array('1' => 'custom', '2' => 'bug', '3' => 'task'); - $pris = array('1' => '1', '2' => '2', '3' => '3'); - $names = array('1' => '自定义1的待办', '2' => 'BUG2的待办', '3' => '任务3的待办'); - $descs = array('1' => '这是一个待办的描述1', '2' => '这是一个待办的描述2', '3' => '这是一个待办的描述3'); - $begins = array('1' => '1000', '2' => '1002', '3' => '1004'); - $ends = array('1' => '1400', '2' => '1402', '3' => '1404'); - $status = array('1' => 'wait', '2' => 'doing', '3' => 'done'); - - $batchUpdateFields['todoIDList'] = $todoIDList; - $batchUpdateFields['dates'] = $dates; - $batchUpdateFields['types'] = $types; - $batchUpdateFields['pris'] = $pris; - $batchUpdateFields['names'] = $names; - $batchUpdateFields['descs'] = $descs; - $batchUpdateFields['begins'] = $begins; - $batchUpdateFields['ends'] = $ends; - $batchUpdateFields['status'] = $status; - - foreach($batchUpdateFields as $field => $value) $_POST[$field] = $value; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $changes = $this->objectModel->batchUpdate(); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - return $changes[$todoID]; - } - - /** - * Test start a todo. - * - * @param int $todoID - * @access public - * @return object - */ - public function startTest($todoID) - { - $this->objectModel->start($todoID); - $object = $this->objectModel->getByID($todoID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test finish a todo. - * - * @param int $todoID - * @access public - * @return object - */ - public function finishTest($todoID) - { - $this->objectModel->finish($todoID); - $object = $this->objectModel->getByID($todoID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get info of a todo. - * - * @param int $todoID - * @param bool $setImgSize - * @access public - * @return object - */ - public function getByIdTest($todoID, $setImgSize = false) - { - $object = $this->objectModel->getById($todoID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get todo list of a user. - * - * @param string $type - * @param string $account - * @param string $status - * @param int $limit - * @param mixed $pager - * @param string $orderBy - * @param status $status - * @param begin" $begin" - * @access public - * @return void - */ - public function getListTest($type = 'today', $account = '', $status = 'all', $limit = 0, $pager = null, $orderBy = "date, status, begin") - { - $objects = $this->objectModel->getList($type, $account, $status, $limit, $pager, $orderBy); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test get todo by id list. - * - * @parami array $todoIDList - * @access public - * @return void - */ - public function getByListTest($todoIDList = 0) - { - $objects = $this->objectModel->getByList($todoIDList); - - $name = ''; - foreach($objects as $todo) $name .= ',' . $todo->name; - $name = trim($name, ','); - - if(dao::isError()) return dao::getError(); - - return $name; - } - - /** - * isClickableTest - * - * @param object $todo - * @param string $action - * @access public - * @return int - */ - public function isClickableTest($todo, $action) - { - $object = $this->objectModel->isClickable($todo, $action); - - if(dao::isError()) return dao::getError(); - - return $object ? 1 : 2; - } - - public function createByCycleTest($todo) - { - $todo->cycle = '1'; - $todo->type = 'cycle'; - $todo->pri = 3; - $todo->desc = ''; - $todo->status = 'wait'; - $todo->begin = '0830'; - $todo->end = '0900'; - $todo->account = 'admin'; - $todo->idvalue = '0'; - $todo->vision = 'rnd'; - $todo->assignedTo = 'admin'; - $todo->assignedBy = 'admin'; - $todo->assignedDate = date('Y-m-d', time()); - $todo->date = date('Y-m-d', time()); - - $todo->config = str_replace('2022-03-23', date('Y-m-d', time()), $todo->config); - - global $tester; - $tester->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->exec(); - $todoID = $tester->dao->lastInsertID(); - - $this->objectModel->createByCycle(array($todoID => $todo)); - - $objects = $tester->dao->select('id')->from(TABLE_TODO)->where('idvalue')->eq($todoID)->andWhere('deleted')->eq('0')->fetchAll(); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test activate todo. - * - * @param int $todoID - * @access public - * @return object - */ - public function activateTest($todoID) - { - $this->objectModel->activate($todoID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($todoID); - return $object; - } - - /** - * Test close a todo. - * - * @param int $todoID - * @access public - * @return object - */ - public function closeTest($todoID) - { - $this->objectModel->close($todoID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($todoID); - return $object; - } - - /** - * Test assign todo. - * - * @param int $todoID - * @param array $param - * @access public - * @return object - */ - public function assignToTest($todoID, $param = array()) - { - foreach($param as $key => $value) $_POST[$key] = $value; - - if(!isset($_POST['future']) and !isset($_POST['date'])) $_POST['date'] = date('Y-m-d', time()); - - $this->objectModel->assignTo($todoID); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getById($todoID); - return $object; - } - - /** - * Test get todo count. - * - * @param string $account - * @access public - * @return int - */ - public function getCountTest($account = '') - { - $count = $this->objectModel->getCount($account); - - if(dao::isError()) return dao::getError(); - - return $count; - } -} diff --git a/test/class/tree.class.php b/test/class/tree.class.php deleted file mode 100644 index ac893f8880..0000000000 --- a/test/class/tree.class.php +++ /dev/null @@ -1,828 +0,0 @@ -objectModel = $tester->loadModel('tree'); - } - - /** - * Test get module by id. - * - * @param int $moduleID - * @access public - * @return object - */ - public function getByIDTest($moduleID) - { - $object = $this->objectModel->getByID($moduleID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * get all module pairs with path. - * - * @param string $type - * @access public - * @return int - */ - public function getAllModulePairsTest($type = 'task') - { - $objects = $this->objectModel->getAllModulePairs($type); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test build the sql query. - * - * @param int $rootID - * @param string $type - * @param int $startModule - * @param string $branch - * @access public - * @return string - */ - public function buildMenuQueryTest($rootID, $type, $startModule = 0, $branch = 'all') - { - $string = $this->objectModel->buildMenuQuery($rootID, $type, $startModule, $branch); - - if(dao::isError()) return dao::getError(); - - return $string; - } - - /** - * Test create an option menu in html. - * - * @param int $rootID - * @param string $type - * @param int $startModule - * @param int $branch - * @access public - * @return int - */ - public function getOptionMenuTest($rootID, $type = 'story', $startModule = 0, $branch = 0) - { - $objects = $this->objectModel->getOptionMenu($rootID, $type, $startModule, $branch); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * getModulePairsTest - * - * @param int $rootID - * @param string $viewType - * @param string $showModule - * @param string $extra - * @access public - * @return int - */ - public function getModulePairsTest($rootID, $viewType = 'story', $showModule = 'end', $extra = '') - { - $objects = $this->objectModel->getModulePairs($rootID, $viewType, $showModule, $extra); - - if(dao::isError()) return dao::getError(); - - return count($objects); - } - - /** - * Test create an option menu of task in html. - * - * @param int $rootID - * @param int $productID - * @param int $startModule - * @param string $extra - * @access public - * @return string - */ - public function getTaskOptionMenuTest($rootID, $productID = 0, $startModule = 0, $extra = '') - { - $objects = $this->objectModel->getTaskOptionMenu($rootID, $productID = 0, $startModule = 0, $extra = ''); - - if(dao::isError()) return dao::getError(); - - $names = ''; - foreach($objects as $object) $names .= ',' . $object; - return $names; - } - - /** - * Test build tree array. - * - * @param array & $&treeMenu - * @param array $modules - * @param int $moduleID - * @param string $moduleName - * @access public - * @return array - */ - public function buildTreeArrayTest(& $treeMenu, $modules, $moduleID, $moduleName = '/') - { - $module = $this->objectModel->getByID($moduleID); - $moduleName = $module->name; - - $this->objectModel->buildTreeArray($treeMenu, $modules, $module, $moduleName); - - if(dao::isError()) return dao::getError(); - - $objects = array(); - foreach($treeMenu as $id => $string) $objects[$id] = strlen($string); - return $objects; - } - - /** - * Test get full task tree. - * - * @param int $rootID - * @param int $productID - * @access public - * @return string - */ - public function getTaskStructureTest($rootID, $productID = 0) - { - $objects = $this->objectModel->getTaskStructure($rootID, $productID = 0); - - if(dao::isError()) return dao::getError(); - - $child = ''; - foreach($objects as $object) - { - if(is_array($object)) $child .= isset($object['children']) ? $object['name'] . ':' . count($object['children']) . ';' : $object['name'] . ':0'; - if(is_object($object)) $child .= isset($object->children) ? "$object->name:" . count($object->children) . ';' : "$object->name:0"; - } - return $child; - } - - /** - * Test get tree structure. - * - * @param int $rootID - * @param string $type - * @access public - * @return string - */ - public function getTreeStructureTest($rootID, $type) - { - $objects = $this->objectModel->getTreeStructure($rootID, $type); - - if(dao::isError()) return dao::getError(); - - $child = ''; - foreach($objects as $object) $child .= isset($object->children) ? "$object->id:" . count($object->children) . ';' : "$object->id:0;"; - return $child; - } - - /** - * Test get execution modules. - * - * @param int $executionID - * @param bool $parent - * @param string $linkObject - * @access public - * @return string - */ - public function getTaskTreeModulesTest($executionID, $parent = false, $linkObject = 'story') - { - $objects = $this->objectModel->getTaskTreeModules($executionID, $parent, $linkObject); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object; - return $ids; - } - - /** - * Test create story link. - * - * @param int $moduleID - * @param array $extra - * @access public - * @return string - */ - public function createStoryLinkTest($moduleID, $extra = array()) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createStoryLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(projectstory|execution|product).*(title='.*').*/", '$1 $2', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create task link. - * - * @param int $moduleID - * @param int $extra - * @access public - * @return string - */ - public function createTaskLinkTest($moduleID, $extra) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createTaskLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*task.(\d*).*byModule.(\d*).*(title='.*').*/", '$1 $2 $3', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create requirment link. - * - * @param int $moduleID - * @access public - * @return string - */ - public function createRequirementLinkTest($moduleID) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createBugLink($type, $module); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create manage link. - * - * @param int $moduleID - * @param array $extra - * @access public - * @return string - */ - public function createManageLinkTest($moduleID, $extra) - { - $type = 0; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createManageLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - return substr($link, 0, 15); - } - - /** - * Test create task manage link. - * - * @param int $moduleID - * @param array $extra - * @access public - * @return string - */ - public function createTaskManageLinkTest($moduleID, $extra) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createTaskManageLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/((.*) ([\x{4e00}-\x{9fa5}]*)<\/a>.*)|( )/u", '$2 $3 $4', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test reate link of a bug. - * - * @param int $moduleID - * @access public - * @return string - */ - public function createBugLinkTest($moduleID) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createBugLink($type, $module); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Create case link. - * - * @param int $moduleID - * @param array $extra - * @access public - * @return string - */ - public function createCaseLinkTest($moduleID, $extra = array('branchID' => 0)) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createCaseLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create test task link. - * - * @param int $moduleID - * @param int $extra - * @access public - * @return string - */ - public function createTestTaskLinkTest($moduleID, $extra) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createTestTaskLink($type, $module, $extra); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create case lib link. - * - * @param int $moduleID - * @access public - * @return string - */ - public function createCaseLibLinkTest($moduleID) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createCaseLibLink($type, $module); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test create feedback link. - * - * @param int $moduleID - * @access public - * @return string - */ - public function createFeedbackLinkTest($moduleID) - { - $type = ''; - $module = $this->objectModel->getByID($moduleID); - - $link = $this->objectModel->createFeedbackLink($type, $module); - - if(dao::isError()) return dao::getError(); - - $string = preg_replace("/.*(title='.*').*/", '$1', $link); - $string = str_replace("\n", '', $string); - return $string; - } - - /** - * Test get sons of a module. - * - * @param int $rootID - * @param int $moduleID - * @param string $type - * @param int $branch - * @access public - * @return string - */ - public function getSonsTest($rootID, $moduleID, $type = 'root', $branch = 0) - { - $objects = $this->objectModel->getSons($rootID, $moduleID, $type, $branch); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test get sons of a task module. - * - * @param int $rootID - * @param int $productID - * @param int $moduleID - * @access public - * @return string - */ - public function getTaskSonsTest($rootID, $productID, $moduleID) - { - $objects = $this->objectModel->getTaskSons($rootID, $productID, $moduleID); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test get id list of a module's childs. - * - * @param int $moduleID - * @access public - * @return string - */ - public function getAllChildIdTest($moduleID) - { - $objects = $this->objectModel->getAllChildId($moduleID); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $objectID) $ids .= ',' . $objectID; - return $ids; - } - - /** - * Test get project module. - * - * @param int $projectID - * @param int $productID - * @access public - * @return string - */ - public function getProjectModuleTest($projectID, $productID = 0) - { - $objects = $this->objectModel->getProjectModule($projectID, $productID); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $objectID) $ids .= ',' . $objectID; - return $ids; - } - - /** - * Test get parents of a module. - * - * @param int $moduleID - * @access public - * @return string - */ - public function getParentsTest($moduleID) - { - $objects = $this->objectModel->getParents($moduleID); - - if(dao::isError()) return dao::getError(); - - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test get product by moduleID. - * - * @param int $moduleID - * @access public - * @return object - */ - public function getProductTest($moduleID) - { - $object = $this->objectModel->getProduct($moduleID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get the module that its type == 'story'. - * - * @param int $moduleID - * @access public - * @return int - */ - public function getStoryModuleTest($moduleID) - { - $object = $this->objectModel->getStoryModule($moduleID); - - if(dao::isError()) return dao::getError(); - - return $object; - } - - /** - * Test get modules name. - * - * @param array $moduleIdList - * @param bool $allPath - * @param bool $branchPath - * @access public - * @return array - */ - public function getModulesNameTest($moduleIdList, $allPath = true, $branchPath = false) - { - $objects = $this->objectModel->getModulesName($moduleIdList, $allPath, $branchPath); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Test update modules' order. - * - * @param array $orders - * @access public - * @return string - */ - public function updateOrderTest($orders) - { - $objects = $this->objectModel->updateOrder($orders); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_MODULE)->where('id')->in(array_keys($orders))->orderBy('`order` asc')->fetchAll(); - $ids = ''; - foreach($objects as $object) $ids .= ',' . $object->id; - return $ids; - } - - /** - * Test manage childs of a module. - * - * @param int $rootID - * @param string $type - * @param array $param - * @access public - * @return string - */ - public function manageChildTest($rootID, $type, $param) - { - $_POST['allProduct'] = 100; - $_POST['productModule'] = 0; - - foreach($param as $key => $value) $_POST[$key] = $value; - - $this->objectModel->manageChild($rootID, $type); - - unset($_POST); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_MODULE)->where('parent')->eq($param['parentModuleID'])->andWhere('deleted')->eq(0)->fetchAll(); - - $names = ''; - foreach($objects as $object) $names .= ',' . $object->name; - return $names; - } - - /** - * Test update a module. - * - * @param int $moduleID - * @param array $param - * @access public - * @return object - */ - public function updateTest($moduleID, $param) - { - $fields = array('root', 'branch', 'parent', 'name', 'short'); - $module = $this->objectModel->getByID($moduleID); - foreach($fields as $field) - { - if(isset($param[$field])) - { - $_POST[$field] = $param[$field]; - } - else - { - $_POST[$field] = $module->$field; - } - } - - $this->objectModel->update($moduleID); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($moduleID); - return $object; - } - - /** - * Test change root. - * - * @param int $moduleID - * @param int $oldRoot - * @param int $newRoot - * @param string $type - * @access public - * @return int - */ - public function changeRootTest($moduleID, $oldRoot, $newRoot, $type) - { - $this->objectModel->changeRoot($moduleID, $oldRoot, $newRoot, $type); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_STORY)->where('module')->eq($oldRoot)->andWhere('deleted')->eq(0)->fetchAll(); - return $type == 'story' ? count($objects) : 0; - } - - /** - * Test delete a module. - * - * @param int $moduleID - * @param object $null - * @access public - * @return object - */ - public function deleteTest($moduleID, $null = null) - { - $this->objectModel->delete($moduleID, $null); - - if(dao::isError()) return dao::getError(); - - $object = $this->objectModel->getByID($moduleID); - return $object; - } - - /** - * Test fix the path, grade fields according to the id and parent fields. - * - * @param int $root - * @param string $type - * @access public - * @return object - */ - public function fixModulePathTest($root, $type) - { - $this->objectModel->fixModulePath($root, $type); - - if(dao::isError()) return dao::getError(); - - global $tester; - $objects = $tester->dao->select('*')->from(TABLE_MODULE)->where('root')->eq($root)->andWhere('type')->eq($type)->andWhere('deleted')->eq(0)->fetchAll('id'); - return $objects; - } - - /** - * Test check unique module name. - * - * @param object $module - * @param array $modules - * @param array $branches - * @access public - * @return string - */ - public function checkUniqueTest($module, $modules = array(), $branches = array()) - { - global $tester; - $modules = $tester->dao->select('id,name')->from(TABLE_MODULE)->where('id')->in($modules)->fetchPairs(); - - $repeatName = $this->objectModel->checkUnique($module, $modules, $branches); - - if(dao::isError()) return dao::getError(); - - return $repeatName; - } - - /** - * Test check merge module version. - * - * @param int $rootID - * @param string $viewType - * @access public - * @return int - */ - public function isMergeModuleTest($rootID, $viewType) - { - $object = $this->objectModel->isMergeModule($rootID, $viewType); - - if(dao::isError()) return dao::getError(); - - return $object ? 1 : 2; - } - - /** - * Test get full trees. - * - * @param int $rootID - * @param string $viewType - * @param string $branchID - * @param int $currentModuleID - * @access public - * @return string - */ - public function getProductStructureTest($rootID, $viewType, $branchID = 'all', $currentModuleID = 0) - { - $objects = $this->objectModel->getProductStructure($rootID, $viewType, $branchID, $currentModuleID); - - if(dao::isError()) return dao::getError(); - - $child = ''; - foreach($objects as $object) $child .= isset($object->children) ? "$object->id:" . count($object->children) . ';' : "$object->id:0;"; - return $child; - } - - /** - * Test get full task tree. - * - * @param int $root - * @param string $viewType - * @param array $keepModules - * @access public - * @return string - */ - public function getDataStructureTest($root, $viewType, $keepModules = array()) - { - global $tester; - - $stmt = $tester->dbh->query($this->objectModel->buildMenuQuery($root, $viewType)); - - $objects = $this->objectModel->getDataStructure($stmt, $viewType, $keepModules); - - if(dao::isError()) return dao::getError(); - - $child = ''; - foreach($objects as $object) $child .= isset($object->children) ? "$object->id:" . count($object->children) . ';' : "$object->id:0;"; - return $child; - } - - /** - * Test get all doc structure. - * - * @access public - * @return string - */ - public function getDocStructureTest() - { - $objects = $this->objectModel->getDocStructure(); - - if(dao::isError()) return dao::getError(); - - $child = ''; - foreach($objects as $object) $child .= isset($object[0]->children) ? $object[0]->id . ':' . count($object[0]->children) . ';' : "$object[0]->id:0;"; - return $child; - } - - /** - * Create module. - * - * @param array $postData - * @access public - * @return object|bool - */ - public function createModuleTest($postData) - { - global $tester; - foreach($postData as $key => $value) $_POST[$key] = $value; - $object = $this->objectModel->createModule(); - - unset($_POST); - - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - return $object; - } -} diff --git a/test/class/tutorial.class.php b/test/class/tutorial.class.php deleted file mode 100644 index b7c646167f..0000000000 --- a/test/class/tutorial.class.php +++ /dev/null @@ -1,281 +0,0 @@ -objectModel = $tester->loadModel('tutorial'); - } - - /** - * Check novice. - * - * @access public - * @return void - */ - public function checkNoviceTest() - { - $this->app->user->modifyPassword = 1; - $objects = $this->objectModel->checkNovice(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial product pairs. - * - * @access public - * @return void - */ - public function getProductPairsTest() - { - $objects = $this->objectModel->getProductPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get module pairs for tutorial. - * - * @access public - * @return void - */ - public function getModulePairsTest() - { - $objects = $this->objectModel->getModulePairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial product. - * - * @access public - * @return void - */ - public function getProductTest() - { - $objects = $this->objectModel->getProduct(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get product stats for tutorial. - * - * @access public - * @return void - */ - public function getProductStatsTest() - { - $objects = $this->objectModel->getProductStats(); - - if(dao::isError()) return dao::getError(); - - return $objects[0][0]['products']; - } - - /** - * Get project for tutorial. - * - * @access public - * @return void - */ - public function getProjectTest() - { - $objects = $this->objectModel->getProject(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial project pairs. - * - * @access public - * @return void - */ - public function getProjectPairsTest() - { - $objects = $this->objectModel->getProjectPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get project stats for tutorial. - * - * @param string $browseType - * @access public - * @return void - */ - public function getProjectStatsTest($browseType = '') - { - $objects = $this->objectModel->getProjectStats($browseType = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial stories. - * - * @access public - * @return void - */ - public function getStoriesTest() - { - $objects = $this->objectModel->getStories(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial Execution pairs. - * - * @access public - * @return void - */ - public function getExecutionPairsTest() - { - $objects = $this->objectModel->getExecutionPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial execution. - * - * @access public - * @return void - */ - public function getExecutionTest() - { - $objects = $this->objectModel->getExecution(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial execution products. - * - * @access public - * @return void - */ - public function getExecutionProductsTest() - { - $objects = $this->objectModel->getExecutionProducts(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial execution stories. - * - * @access public - * @return void - */ - public function getExecutionStoriesTest() - { - $objects = $this->objectModel->getExecutionStories(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial execution story pairs. - * - * @access public - * @return void - */ - public function getExecutionStoryPairsTest() - { - $objects = $this->objectModel->getExecutionStoryPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial team members. - * - * @access public - * @return void - */ - public function getTeamMembersTest() - { - $objects = $this->objectModel->getTeamMembers(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get team members pairs. - * - * @access public - * @return void - */ - public function getTeamMembersPairsTest() - { - $objects = $this->objectModel->getTeamMembersPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorial user pairs. - * - * @access public - * @return void - */ - public function getUserPairsTest() - { - $objects = $this->objectModel->getUserPairs(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - /** - * Get tutorialed. - * - * @access public - * @return void - */ - public function getTutorialedTest() - { - $objects = $this->objectModel->getTutorialed(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } -} diff --git a/test/class/user.class.php b/test/class/user.class.php deleted file mode 100755 index 2d562ddf00..0000000000 --- a/test/class/user.class.php +++ /dev/null @@ -1,1144 +0,0 @@ -objectModel = $tester->loadModel('user'); - } - - /** - * Test get user list. - * - * @param bool $count - * @access public - * @return void - */ - public function getListTest($params = 'nodeleted', $count = false) - { - $objects = $this->objectModel->getList($params); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $count ? count($objects) : $objects; - } - } - - /** - * Test get user information by accounts. - * - * @param array $accounts - * @param string $keyField - * @param bool $count - * @access public - * @return void - */ - public function getListByAccountsTest($accounts = array(), $keyField = 'id', $count = false) - { - $objects = $this->objectModel->getListByAccounts($accounts, $keyField); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $count ? count($objects) : $objects; - } - } - - /** - * Test user get pairs. - * - * @param string $params - * @param string $usersToAppended - * @param int $maxCount - * @param array $accounts - * @access public - * @return void - */ - public function getPairsTest($params = '', $usersToAppended = '', $maxCount = 0, $accounts = array()) - { - $objects = $this->objectModel->getPairs($params, $usersToAppended, $maxCount, $accounts); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get avatar pairs. - * - * @param string $params - * @access public - * @return array - */ - public function getAvatarPairsTest($param = 'nodeleted') - { - $objects = $this->objectModel->getAvatarPairs($param); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user commiters. - * - * @access public - * @return void - */ - public function getCommitersTest() - { - $objects = $this->objectModel->getCommiters(); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user realname and emails. - * - * @param array $accounts - * @access public - * @return void - */ - public function getRealNameAndEmailsTest($accounts) - { - $objects = $this->objectModel->getRealNameAndEmails($accounts); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user roles. - * - * @param array $accounts - * @param bool $needRole - * @access public - * @return void - */ - public function getUserRolesTest($accounts, $needRole = false) - { - $objects = $this->objectModel->getUserRoles($accounts, $needRole); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user display infos. - * - * @param int $accounts - * @param int $deptID - * @param string $type - * @access public - * @return void - */ - public function getUserDisplayInfosTest($accounts, $deptID = 0, $type = 'inside') - { - $objects = $this->objectModel->getUserDisplayInfos($accounts, $deptID, $type); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user by id. - * - * @param int|string $userID - * @param string $field - * @access public - * @return void - */ - public function getByIdTest($userID, $field = 'account') - { - $objects = $this->objectModel->getById($userID, $field); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test get user by query. - * - * @param string $browseType - * @param string $query - * @param string $orderBy - * @access public - * @return void - */ - public function getByQueryTest($browseType = 'inside', $query = '', $orderBy = 'id') - { - $objects = $this->objectModel->getByQuery($browseType, $query, null, $orderBy); - if(dao::isError()) - { - $error = dao::getError(); - return $error[0]; - } - else - { - return $objects; - } - } - - /** - * Test create a user. - * - * @param array $params - * @access public - * @return void - */ - public function createUserTest($params = array()) - { - $_POST = $params; - $_POST['verifyPassword'] = 'bac0bbaaf7192f219bebd5387e88c5d7'; - - $userID = $this->objectModel->create(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $this->objectModel->getByID($userID, 'id'); - } - } - - /** - * Test batch create users. - * - * @access public - * @return void - */ - public function batchCreateUserTest($params = array()) - { - $_POST = $params; - $_POST['verifyPassword'] = 'bac0bbaaf7192f219bebd5387e88c5d7'; - $_POST['userType'] = 'inside'; - - global $tester; - $tester->config->user->batchCreate = count($_POST['account']); - - $userIDList = $this->objectModel->batchCreate(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $users = array(); - foreach($userIDList as $userID) $users[] = $this->objectModel->getByID($userID, 'id'); - - return $users; - } - } - - /** - * Test edit a user. - * - * @param int $userID - * @param array $params - * @access public - * @return void - */ - public function updateUserTest($userID, $params = array()) - { - $_POST = $params; - $_POST['verifyPassword'] = 'bac0bbaaf7192f219bebd5387e88c5d7'; - - $this->objectModel->update($userID); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $this->objectModel->getByID($userID, 'id'); - } - } - - /** - * Test batch edit users. - * - * @param array $params - * @access public - * @return void - */ - public function batchEditUserTest($params = array()) - { - $_POST = $params; - $_POST['verifyPassword'] = 'bac0bbaaf7192f219bebd5387e88c5d7'; - - $this->objectModel->batchEdit(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $users = array(); - $userIDList = array_keys($params['account']); - foreach($userIDList as $userID) - { - $user = $this->objectModel->getByID($userID, 'id'); - $users[$user->id] = $user; - } - - return $users; - } - } - - /** - * Test edit a user password. - * - * @param int $userID - * @param array $params - * @access public - * @return void - */ - public function updatePasswordTest($userID, $params = array()) - { - $_POST = $params; - - $this->objectModel->updatePassword($userID); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $this->objectModel->getByID($userID, 'id'); - } - } - - /** - * Reset user password. - * - * @param array $params - * @access public - * @return void - */ - public function resetPasswordTest($params = array()) - { - $_POST = $params; - - $this->objectModel->resetPassword(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - $account = $params['account']; - return $this->objectModel->getByID($account, 'account'); - } - } - - /** - * Check user password. - * - * @param array $params - * @access public - * @return void - */ - public function checkPasswordTest($params = array()) - { - $_POST = $params; - - $this->objectModel->checkPassword(); - unset($_POST); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return '无报错'; - } - } - - /** - * Identify user. - * - * @param string $account - * @param string $password - * @access public - * @return void - */ - public function identifyTest($account, $password) - { - $_POST = $params; - - $user = $this->objectModel->identify($account, $password); - unset($_POST); - - return $user; - } - - /** - * Test authorize user. - * - * @param string $account - * @access public - * @return void - */ - public function authorizeTest($account) - { - $user = $this->objectModel->authorize($account); - - return $user; - } - - /** - * Test login user. - * - * @param object $user - * @access public - * @return void - */ - public function loginTest($user) - { - $user = $this->objectModel->login($user); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $user; - } - } - - /** - * Test get groups by user. - * - * @param string $account - * @param string $password - * @access public - * @return void - */ - public function getGroupsTest($account) - { - $groups = $this->objectModel->getGroups($account); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $groups; - } - } - - /** - * Test get groups by visions. - * - * @param string $visions - * @access public - * @return void - */ - public function getGroupsByVisionsTest($visions) - { - $groups = $this->objectModel->getGroupsByVisions($visions); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $groups; - } - } - - /** - * Test get my objects. - * - * @param string $account - * @param string $type - * @param string $status - * @param string $orderBy - * @access public - * @return void - */ - public function getObjectsTest($account, $type, $status, $orderBy) - { - $myObjects = $this->objectModel->getObjects($account, $type, $status, $orderBy); - - if(dao::isError()) return dao::getError(); - return $myObjects; - } - - /** - * Test clean user locked time. - * - * @param string $account - * @access public - * @return string - */ - public function cleanLockedTest($account) - { - global $tester; - - $this->objectModel->cleanLocked($account); - - if(dao::isError()) return dao::getError(); - - $locked = $tester->dao->select('locked')->from(TABLE_USER)->where('account')->eq($account)->fetch('locked'); - - $result = $locked === '0000-00-00 00:00:00' ? 'success' : 'fail'; - - return $result; - } - - /** - * Test unbind Ranzhi. - * - * @param string $account - * @access public - * @return string - */ - public function unbindTest($account) - { - global $tester; - - $this->objectModel->unbind($account); - - if(dao::isError()) return dao::getError(); - - $ranzhi = $tester->dao->select('ranzhi')->from(TABLE_USER)->where('account')->eq($account)->fetch('ranzhi'); - - $result = empty($ranzhi) ? 'success' : 'fail'; - - return $result; - } - - /** - * Test get contact list. - * - * @param string $account - * @param string $params - * @access public - * @return void - */ - public function getContactListsTest($account = '', $params = '') - { - $contacts = $this->objectModel->getContactLists($account, $params); - - if(dao::isError()) return dao::getError(); - - return $contacts ? $contacts : 0; - } - - /** - * Test get list by account method. - * - * @param string $account - * @access public - * @return void - */ - public function getListByAccountTest($account) - { - return $this->objectModel->getListByAccount($account); - } - - /** - * Test get parent stage authed users. - * - * @param int $stageID - * @access public - * @return void - */ - public function getParentStageAuthedUsersTest($stageID) - { - return $this->objectModel->getParentStageAuthedUsers($stageID); - } - - /** - * Test get contact list by id. - * - * @param int $listID - * @access public - * @return void - */ - public function getContactListByIDTest($listID) - { - return $this->objectModel->getContactListByID($listID); - } - - /** - * Test get contact user pairs. - * - * @param array $accountList - * @access public - * @return void - */ - public function getContactUserPairsTest($accountList) - { - return $this->objectModel->getContactUserPairs($accountList); - } - - /** - * Test create contact list. - * - * @param string $listName - * @param array $userList - * @access public - * @return void - */ - public function createContactListTest($listName = '', $userList = array()) - { - ob_start(); - $listID = $this->objectModel->createContactList($listName, $userList); - $message = ob_get_clean(); - - if($message) return array('message' => array('listName' => array(1))); - if(dao::isError()) return array('message' => dao::getError()); - return $this->objectModel->getContactListByID($listID); - } - - /** - * Test update contact list. - * - * @param int $listID - * @param string $listName - * @param array $userList - * @access public - * @return void - */ - public function updateContactListTest($listID = 0, $listName = '', $userList = array()) - { - $this->objectModel->updateContactList($listID, $listName, $userList); - - if(dao::isError()) return array('message' => dao::getError()); - return $this->objectModel->getContactListByID($listID); - } - - /** - * Test delete a contact list. - * - * @param int $listID - * @access public - * @return void - */ - public function deleteContactListTest($listID) - { - $this->objectModel->deleteContactList($listID); - - if(dao::isError()) return dao::getError(); - return $this->objectModel->getContactListByID($listID); - } - - /** - * Test get user data in json. - * - * @param object $user - * @access public - * @return void - */ - public function getDataInJSONTest($user) - { - $user = $this->objectModel->getDataInJSON($user); - - if(dao::isError()) return dao::getError(); - return $user; - } - - /** - * Test get weak users. - * - * @access public - * @return void - */ - public function getWeakUsersTest() - { - $users = $this->objectModel->getWeakUsers(); - - if(dao::isError()) return dao::getError(); - return $users; - } - - /** - * Test compute password strength. - * - * @access public - * @return void - */ - public function computePasswordStrengthTest($password) - { - $strength = $this->objectModel->computePasswordStrength($password); - - if(dao::isError()) return dao::getError(); - return $strength; - } - - /** - * Test compute user view. - * - * @param string $account - * @param bool $force - * @access public - * @return void - */ - public function computeUserViewTest($account, $force = false) - { - $userview = $this->objectModel->computeUserView($account, $force); - - if(dao::isError()) return dao::getError(); - return $userview; - } - - /** - * Test get product members. - * - * @param string $account - * @param bool $force - * @access public - * @return void - */ - public function getProductMembersTest($allProducts) - { - $members = $this->objectModel->getProductMembers($allProducts); - - if(dao::isError()) return dao::getError(); - return $members; - } - - /** - * Test get product members. - * - * @param string $account - * @param bool $force - * @access public - * @return void - */ - public function grantUserViewTest($account = '', $acls = array(), $projects = '') - { - $userView = $this->objectModel->grantUserView($account, $acls, $projects); - - if(dao::isError()) return dao::getError(); - return $userView; - } - - /** - * Test update program view. - * - * @param array $programIdList - * @param array $users - * @access public - * @return void - */ - public function updateProgramViewTest($programIdList = array(), $users = array()) - { - $this->objectModel->updateProgramView($programIdList, $users); - - if(dao::isError()) return dao::getError(); - return $this->objectModel->grantUserView(current($users)); - } - - /** - * Test check program priv. - * - * @param object $program - * @param string $account - * @param array $stakeholders - * @param array $whiteList - * @access public - * @return void - */ - public function checkProgramPrivTest($program, $account, $stakeholders, $whiteList) - { - return $this->objectModel->checkProgramPriv($program, $account, $stakeholders, $whiteList); - } - - /** - * Test check project priv. - * - * @param object $project - * @param string $account - * @param array $stakeholders - * @param array $teams - * @param array $whiteList - * @access public - * @return void - */ - public function checkProjectPrivTest($project, $account, $stakeholders, $teams, $whiteList) - { - return $this->objectModel->checkProjectPriv($project, $account, $stakeholders, $teams, $whiteList); - } - /** - * Test check sprint priv. - * - * @param object $sprint - * @param string $account - * @param array $stakeholders - * @param array $teams - * @param array $whiteList - * @access public - * @return void - */ - public function checkSprintPrivTest($sprint, $account, $stakeholders, $teams, $whiteList) - { - return $this->objectModel->checkSprintPriv($sprint, $account, $stakeholders, $teams, $whiteList); - } - /** - * Test check product priv. - * - * @param object $program - * @param string $account - * @param array $groups - * @param array $teams - * @param array $stakeholders - * @param array $whiteList - * @access public - * @return void - */ - public function checkProductPrivTest($product, $account, $groups = '', $teams = '', $stakeholders = '', $whiteList = '') - { - return $this->objectModel->checkProductPriv($product, $account, $groups, $teams, $stakeholders, $whiteList); - } - - /** - * Test get project authed users. - * - * @param int $projectID - * @param array $stakeholders - * @param array $teams - * @param array $whiteList - * @access public - * @return void - */ - public function getProjectAuthedUsersTest($projectID, $stakeholders, $teams, $whiteList) - { - global $tester; - $project = $tester->loadModel('project')->getByID($projectID); - return $this->objectModel->getProjectAuthedUsers($project, $stakeholders, $teams, $whiteList); - } - - /** - * Test get program authed users. - * - * @param int $projectID - * @param array $stakeholders - * @param array $whiteList - * @param array $admins - * @access public - * @return void - */ - public function getProgramAuthedUsersTest($programID, $stakeholders, $whiteList, $admins) - { - global $tester; - $program = $tester->loadModel('program')->getByID($programID); - return $this->objectModel->getProgramAuthedUsers($program, $stakeholders, $whiteList, $admins); - } - - /** - * getSprintAuthedUsersTest - * - * @param int $sprintID - * @param array $stakeholders - * @param array $teams - * @param array $whiteList - * @param array $admins - * @access public - * @return void - */ - public function getSprintAuthedUsersTest($sprintID, $stakeholders, $teams, $whiteList, $admins) - { - global $tester; - $sprint = $tester->loadModel('execution')->getByID($sprintID); - return $this->objectModel->getSprintAuthedUsers($sprint, $stakeholders, $teams, $whiteList, $admins); - } - - /** - * Test get product view list users. - * - * @param int $productID - * @param array $teams - * @param array $stakeholders - * @param array $whiteList - * @access public - * @return void - */ - public function getProductViewListUsersTest($productID, $teams, $stakeholders, $whiteList, $admins) - { - global $tester; - $product = $tester->loadModel('product')->getByID($productID); - return $this->objectModel->getProductViewListUsers($product, $teams, $stakeholders, $whiteList, $admins); - } - - /** - * Test get product view list users. - * - * @param int $productID - * @param string $type - * @param string $params - * @param array $usersToAppended - * @access public - * @return void - */ - public function getTeamMemberPairsTest($objectID, $type, $params = '', $usersToAppended = array()) - { - return $this->objectModel->getTeamMemberPairs($objectID, $type, $params, $usersToAppended); - } - - /** - * Test save user template. - * - * @param string $type - * @access public - * @return void - */ - public function saveUserTemplate($type) - { - global $tester; - $this->objectModel->saveUserTemplate($type); - - if(dao::isError()) return dao::getError(); - return $this->objectModel->getUserTemplates($type); - } - - /** - * Test get user templates. - * - * @param string $type - * @access public - * @return array - */ - public function getUserTemplatesTest($type) - { - return $this->objectModel->getUserTemplates($type); - } - - /** - * Test get person data. - * - * @param string $account - * @access public - * @return void - */ - public function getPersonalDataTest($account) - { - return $this->objectModel->getPersonalData($account); - } - - /** - * Test get user details for api. - * - * @param array $userList - * @access public - * @return void - */ - public function getUserDetailsForAPITest($userList) - { - return $this->objectModel->getUserDetailsForAPI($userList); - } - - /** - * Test get vision list. - * - * @access public - * @return void - */ - public function getVisionListTest() - { - return $this->objectModel->getVisionList(); - } - - /** - * Get users who have authority to create stories. - * - * @access public - * @return array - */ - public function getCanCreateStoryUsersTest() - { - return $this->objectModel->getCanCreateStoryUsers(); - } - - /** - * Put the current user first - * - * @param array $users - * @access public - * @return array - */ - public function processAccountSortTest($users = array()) - { - return $this->objectModel->processAccountSort($users); - } - - /** - * Set users list. - * - * @param array $users - * @param string $account - * @access public - * @return string - */ - public function setUserListTest($users, $account) - { - $string = $this->objectModel->setUserList($users, $account); - return strpos($string, "