diff --git a/module/branch/model.php b/module/branch/model.php index 5ea7207c1f..ff54cb859b 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -504,7 +504,6 @@ class branchModel extends model } else { - $branchGroups[$branch->product][0] = $this->lang->branch->main; $branchGroups[$branch->product][$branch->id] = htmlspecialchars_decode($branch->name); } } diff --git a/test/class/branch.class.php b/test/class/branch.class.php new file mode 100644 index 0000000000..ef719e8bf7 --- /dev/null +++ b/test/class/branch.class.php @@ -0,0 +1,405 @@ +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; + } + + public function manageTest($productID) + { + $objects = $this->objectModel->manage($productID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function unlinkBranch4ProjectTest($productIDList) + { + $objects = $this->objectModel->unlinkBranch4Project($productIDList); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function linkBranch4ProjectTest($productID) + { + $this->objectModel->unlinkBranch4Project($productID); + + $objects = $this->objectModel->linkBranch4Project($productID); + + if(dao::isError()) return dao::getError(); + + return $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; + } + + public function setParamsForLinkTest($module, $link, $projectID, $productID, $branch) + { + $objects = $this->objectModel->setParamsForLink($module, $link, $projectID, $productID, $branch); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setDefaultTest($productID, $branchID) + { + $objects = $this->objectModel->setDefault($productID, $branchID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getPairsByProjectProductTest($projectID, $productID) + { + $objects = $this->objectModel->getPairsByProjectProduct($projectID, $productID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * 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/data/branch.yaml b/test/data/branch.yaml index b41657f7ef..6617f10ca2 100644 --- a/test/data/branch.yaml +++ b/test/data/branch.yaml @@ -8,7 +8,7 @@ fields: range: 1-10000 - field: product note: "所属产品" - range: 41-120{2},141-180{2} + range: 41-120{2},1-3{2}, 141-180{2} - field: name note: "名称" fields: diff --git a/test/model/branch/activate.php b/test/model/branch/activate.php new file mode 100755 index 0000000000..ddb55ee377 --- /dev/null +++ b/test/model/branch/activate.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +activate(); +cid=1 +pid=1 + +*/ + +$branchID = array(2, 4, 6, 8, 10, 1); + +$branch = new branchTest(); + +r($branch->activateTest($branchID[0])) && p('id,status') && e('2,active'); // 测试激活分支 2 +r($branch->activateTest($branchID[1])) && p('id,status') && e('4,active'); // 测试激活分支 4 +r($branch->activateTest($branchID[2])) && p('id,status') && e('6,active'); // 测试激活分支 6 +r($branch->activateTest($branchID[3])) && p('id,status') && e('8,active'); // 测试激活分支 8 +r($branch->activateTest($branchID[4])) && p('id,status') && e('10,active'); // 测试激活分支 10 +r($branch->activateTest($branchID[5])) && p('id,status') && e('1,active'); // 测试激活分支 1 diff --git a/test/model/branch/batchupdate.php b/test/model/branch/batchupdate.php new file mode 100755 index 0000000000..9802c1f9f1 --- /dev/null +++ b/test/model/branch/batchupdate.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +batchUpdate(); +cid=1 +pid=1 + +*/ + +$changeName = array('name' => array('9' => '修改分支9的名称', '10' => '修改后的分支10名称')); +$changeDesc = array('desc' => array('9' => '修改分支9的描述', '10' => '修改后的分支10描述')); +$changeStatus = array('status' => array('9' => 'closed', '10' => 'closed')); + +$branch = new branchTest(); + +r($branch->batchUpdateTest($changeName)) && p('field,old,new') && e('name,分支9,修改分支9的名称'); // 测试批量更新名称 +r($branch->batchUpdateTest($changeDesc)) && p('field,old,new') && e('desc,,修改分支9的描述'); // 测试批量更新描述 +r($branch->batchUpdateTest($changeStatus)) && p('field,old,new') && e('status,active,closed'); // 测试批量更新状态 +system("./ztest init"); diff --git a/test/model/branch/changebranchlanguage.php b/test/model/branch/changebranchlanguage.php new file mode 100755 index 0000000000..046326d015 --- /dev/null +++ b/test/model/branch/changebranchlanguage.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +changeBranchLanguage(); +cid=1 +pid=1 + +*/ +$productID = array(1, 41, 81, 42); + +$branch = new branchTest(); + +r($branch->changeBranchLanguageTest($productID[0])) && p() && e('新建%s'); // 测试修改productID 1 的分支语言项 +r($branch->changeBranchLanguageTest($productID[1])) && p() && e('新建分支'); // 测试修改productID 41 的分支语言项 +r($branch->changeBranchLanguageTest($productID[2])) && p() && e('新建平台'); // 测试修改productID 81 的分支语言项 +r($branch->changeBranchLanguageTest($productID[3])) && p() && e('新建分支'); // 测试修改productID 42 的分支语言项 diff --git a/test/model/branch/checkbranchdata.php b/test/model/branch/checkbranchdata.php new file mode 100755 index 0000000000..8cfffcc98b --- /dev/null +++ b/test/model/branch/checkbranchdata.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +checkBranchData(); +cid=1 +pid=1 + +*/ +$branchID = array(1, 2, 3, 4, 5, 6, 1000001); + +$branch = new branchTest(); + +r($branch->checkBranchDataTest($branchID[0])) && p() && e('2'); // 测试验证branchID 1 的数据 +r($branch->checkBranchDataTest($branchID[1])) && p() && e('2'); // 测试验证branchID 2 的数据 +r($branch->checkBranchDataTest($branchID[2])) && p() && e('2'); // 测试验证branchID 3 的数据 +r($branch->checkBranchDataTest($branchID[3])) && p() && e('2'); // 测试验证branchID 4 的数据 +r($branch->checkBranchDataTest($branchID[4])) && p() && e('2'); // 测试验证branchID 5 的数据 +r($branch->checkBranchDataTest($branchID[5])) && p() && e('2'); // 测试验证branchID 6 的数据 +r($branch->checkBranchDataTest($branchID[6])) && p() && e('1'); // 测试验证branchID 1000001 的数据 diff --git a/test/model/branch/close.php b/test/model/branch/close.php new file mode 100755 index 0000000000..5042d0d9ca --- /dev/null +++ b/test/model/branch/close.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +close(); +cid=1 +pid=1 + +*/ +$branchID = array(1, 2, 3, 4, 5, 6); + +$branch = new branchTest(); + +r($branch->closeTest($branchID[0])) && p('id,status') && e('1,closed'); // 测试关闭branchID 1 +r($branch->closeTest($branchID[1])) && p('id,status') && e('2,closed'); // 测试关闭branchID 2 +r($branch->closeTest($branchID[2])) && p('id,status') && e('3,closed'); // 测试关闭branchID 3 +r($branch->closeTest($branchID[3])) && p('id,status') && e('4,closed'); // 测试关闭branchID 4 +r($branch->closeTest($branchID[4])) && p('id,status') && e('5,closed'); // 测试关闭branchID 5 +r($branch->closeTest($branchID[5])) && p('id,status') && e('6,closed'); // 测试关闭branchID 6 +r($branch->closeTest($branchID[0])) && p('id,status') && e('1,closed'); // 测试重复关闭branchID 1 +system("./ztest init"); diff --git a/test/model/branch/create.php b/test/model/branch/create.php new file mode 100755 index 0000000000..eeaabdfdba --- /dev/null +++ b/test/model/branch/create.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +*/ +$productID = 41; + +$branch1 = array('name' => '新建分支1', 'desc' => '新建分支1的描述'); +$branch2 = array('name' => '新建分支2', 'desc' => '新建分支2的描述'); + +$repeatName1 = array('name' => '新建分支1', 'desc' => '重名新建分支1的描述'); +$repeatName2 = array('name' => '分支1', 'desc' => '重名分支1的描述'); +$emptyName = array('name' => '', 'desc' => '分支名为空的分支描述'); + +$branch = new branchTest(); + +r($branch->createTest($productID, $branch1)) && p('name,desc') && e('新建分支1,新建分支1的描述'); // 测试新建分支1 +r($branch->createTest($productID, $branch2)) && p('name,desc') && e('新建分支2,新建分支2的描述'); // 测试新建分支2 +r($branch->createTest($productID, $repeatName1)) && p() && e('分支名称已存在'); // 测试新建 重名新建分支1 +r($branch->createTest($productID, $repeatName2)) && p() && e('分支名称已存在'); // 测试新建 重名分支1 +r($branch->createTest($productID, $emptyName)) && p() && e('『名称』不能为空。'); // 测试新建 名称为空的分支 +system("./ztest init"); diff --git a/test/model/branch/getallpairs.php b/test/model/branch/getallpairs.php new file mode 100755 index 0000000000..143388707e --- /dev/null +++ b/test/model/branch/getallpairs.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getAllPairs(); +cid=1 +pid=1 + +*/ +$params = 'noempty'; + +$branch = new branchTest(); + +r($branch->getAllPairsTest()) && p() && e('167'); // 测试获取全部分支名 +r($branch->getAllPairsTest($params)) && p() && e('166'); // 测试获取全部分支名 diff --git a/test/model/branch/getbyid.php b/test/model/branch/getbyid.php new file mode 100755 index 0000000000..2bec1caf47 --- /dev/null +++ b/test/model/branch/getbyid.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +getById(); +cid=1 +pid=1 + +*/ +$branchID = array(1, 2, 3, ''); +$productID = array(41, 81, 1); +$field = ''; + +$branch = new branchTest(); + +r($branch->getByIdTest($branchID[0])) && p() && e('分支1'); // 测试获取 branchID 1 的分支信息 +r($branch->getByIdTest($branchID[0], $productID[0])) && p() && e('分支1'); // 测试获取 branchID 1 productID 41 的分支信息 +r($branch->getByIdTest($branchID[0], $productID[0], $field)) && p('name') && e('分支1'); // 测试获取 branchID 1 productID 41 field 空 的分支信息 +r($branch->getByIdTest($branchID[1])) && p() && e('分支2'); // 测试获取 branchID 2 的分支信息 +r($branch->getByIdTest($branchID[1], $productID[0])) && p() && e('分支2'); // 测试获取 branchID 2 productID 41 的分支信息 +r($branch->getByIdTest($branchID[1], $productID[0], $field)) && p('name') && e('分支2'); // 测试获取 branchID 2 productID 41 field 空 的分支信息 +r($branch->getByIdTest($branchID[2])) && p() && e('分支3'); // 测试获取 branchID 3 的分支信息 +r($branch->getByIdTest($branchID[2], $productID[0])) && p() && e('分支3'); // 测试获取 branchID 3 productID 41 的分支信息 +r($branch->getByIdTest($branchID[2], $productID[0], $field)) && p('name') && e('分支3'); // 测试获取 branchID 3 productID 41 field 空 的分支信息 +r($branch->getByIdTest($branchID[3])) && p() && e('0'); // 测试获取 branchID 空 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[0])) && p() && e('主干'); // 测试获取 branchID 空 productID 41 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[1])) && p() && e('主干'); // 测试获取 branchID 空 productID 81 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[2])) && p() && e('主干'); // 测试获取 branchID 空 productID 1 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[0], $field)) && p('name') && e('主干'); // 测试获取 branchID 空 productID 41 field 空 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[1], $field)) && p('name') && e('主干'); // 测试获取 branchID 空 productID 81 field 空 的分支信息 +r($branch->getByIdTest($branchID[3], $productID[2], $field)) && p('name') && e('主干'); // 测试获取 branchID 空 productID 1 field 空 的分支信息 diff --git a/test/model/branch/getbyproducts.php b/test/model/branch/getbyproducts.php new file mode 100755 index 0000000000..efde1efa14 --- /dev/null +++ b/test/model/branch/getbyproducts.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +getByProducts(); +cid=1 +pid=1 + +*/ + +$products = array('1,41,42', '2,81,82', '43,83'); +$params = array('', 'noclosed', 'ignoreNormal', 'noempty', 'noclosed,ignoreNormal', 'ignoreNormal,noempty'); +$appendBranch = ''; + +$branch = new branchTest(); + +r($branch->getByProductsTest($products[0])) && p() && e('1:,0;41:,0,1,2;42:,0,3,4;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[0])) && p() && e('1:,0;41:,0,1,2;42:,0,3,4;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[1])) && p() && e('1:,0;41:,0,1;42:,0,3;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[2])) && p() && e('41:,0,1,2;42:,0,3,4;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[3])) && p() && e('1:,0;41:,1,2;42:,3,4;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[4])) && p() && e('41:,0,1;42:,0,3;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[5])) && p() && e('41:,1,2;42:,3,4;'); // 测试获取产品 41 42 的分支信息 +r($branch->getByProductsTest($products[0], $params[0], $appendBranch)) && p() && e('1:,0;41:,0,1,2;42:,0,3,4;'); // 测试获取产品 41 42 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[0], $params[1], $appendBranch)) && p() && e('1:,0;41:,0,1;42:,0,3;'); // 测试获取产品 41 42 noclosed 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[0], $params[2], $appendBranch)) && p() && e('41:,0,1,2;42:,0,3,4;'); // 测试获取产品 41 42 ignoreNormal 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[0], $params[3], $appendBranch)) && p() && e('1:,0;41:,1,2;42:,3,4;'); // 测试获取产品 41 42 noempty 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[0], $params[4], $appendBranch)) && p() && e('41:,0,1;42:,0,3;'); // 测试获取产品 41 42 noclosed,ignoreNormal 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[0], $params[5], $appendBranch)) && p() && e('41:,1,2;42:,3,4;'); // 测试获取产品 41 42 ignoreNormal,noempty 追加branch20 21 的分支信息 +r($branch->getByProductsTest($products[1])) && p() && e('2:,0;81:,0,81,82;82:,0,83,84;'); // 测试获取产品 81 82 的分支信息 +r($branch->getByProductsTest($products[2])) && p() && e('43:,0,5,6;83:,0,85,86;'); // 测试获取产品 43 83 的分支信息 diff --git a/test/model/branch/getlist.php b/test/model/branch/getlist.php new file mode 100755 index 0000000000..c962a92b06 --- /dev/null +++ b/test/model/branch/getlist.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +getList(); +cid=1 +pid=1 + +*/ +$productID = array(41, 42, 43); +$executionID = array(141, 142, 143, null); +$browseType = array('all', 'closed', 'active'); +$mainBranch = false; + +$branch = new branchTest(); + +r($branch->getListTest($productID[0])) && p() && e(',0,1'); // 测试获取产品 41的分支信息 +r($branch->getListTest($productID[0], $executionID[0])) && p() && e(',0'); // 测试获取产品 41 执行 141的分支信息 +r($branch->getListTest($productID[0], $executionID[0], $browseType[0])) && p() && e(',0'); // 测试获取产品 41 执行 141 all 没有主干 的分支信息 +r($branch->getListTest($productID[0], $executionID[3], $browseType[0])) && p() && e(',0,1,2'); // 测试获取产品 41 all 没有主干 的分支信息 +r($branch->getListTest($productID[0], $executionID[3], $browseType[1])) && p() && e(',2'); // 测试获取产品 41 执行 141 closed 没有主干 的分支信息 +r($branch->getListTest($productID[0], $executionID[3], $browseType[2])) && p() && e(',0,1'); // 测试获取产品 41 执行 141 active 没有主干 的分支信息 +r($branch->getListTest($productID[0], $executionID[3], $browseType[0], $mainBranch)) && p() && e(',1,2'); // 测试获取产品 41 执行 141 all 没有主干 的分支信息 +r($branch->getListTest($productID[1])) && p() && e(',0,3'); // 测试获取产品 42的分支信息 +r($branch->getListTest($productID[1], $executionID[1])) && p() && e(',0'); // 测试获取产品 42 执行 142的分支信息 +r($branch->getListTest($productID[1], $executionID[1], $browseType[0])) && p() && e(',0'); // 测试获取产品 42 执行 142 all 没有主干 的分支信息 +r($branch->getListTest($productID[1], $executionID[3], $browseType[0])) && p() && e(',0,3,4'); // 测试获取产品 42 all 没有主干 的分支信息 +r($branch->getListTest($productID[1], $executionID[3], $browseType[1])) && p() && e(',4'); // 测试获取产品 42 执行 142 closed 没有主干 的分支信息 +r($branch->getListTest($productID[1], $executionID[3], $browseType[2])) && p() && e(',0,3'); // 测试获取产品 42 执行 142 active 没有主干 的分支信息 +r($branch->getListTest($productID[1], $executionID[3], $browseType[0], $mainBranch)) && p() && e(',3,4'); // 测试获取产品 42 执行 142 all 没有主干 的分支信息 +r($branch->getListTest($productID[2])) && p() && e(',0,5'); // 测试获取产品 43的分支信息 +r($branch->getListTest($productID[2], $executionID[2])) && p() && e(',0'); // 测试获取产品 43 执行 143的分支信息 +r($branch->getListTest($productID[2], $executionID[2], $browseType[0])) && p() && e(',0'); // 测试获取产品 43 执行 143 all 没有主干 的分支信息 +r($branch->getListTest($productID[2], $executionID[3], $browseType[0])) && p() && e(',0,5,6'); // 测试获取产品 43 all 没有主干 的分支信息 +r($branch->getListTest($productID[2], $executionID[3], $browseType[1])) && p() && e(',6'); // 测试获取产品 43 执行 143 closed 没有主干 的分支信息 +r($branch->getListTest($productID[2], $executionID[3], $browseType[2])) && p() && e(',0,5'); // 测试获取产品 43 执行 143 active 没有主干 的分支信息 +r($branch->getListTest($productID[2], $executionID[3], $browseType[0], $mainBranch)) && p() && e(',5,6'); // 测试获取产品 43 执行 143 all 没有主干 的分支信息 diff --git a/test/model/branch/getpairs.php b/test/model/branch/getpairs.php new file mode 100755 index 0000000000..6e5785fca6 --- /dev/null +++ b/test/model/branch/getpairs.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +*/ +$productID = array(41, 42, 43); +$param = array('active', 'noempty', 'all', 'withClosed'); +$executionID = array(141, 142, 143, null); +$mergedBranches = '1,4'; + +$branch = new branchTest(); + +r($branch->getPairsTest($productID[0])) && p() && e(',0,1,2'); // 测试获取 产品41 的分支信息对 +r($branch->getPairsTest($productID[0], $param[0])) && p() && e(',0,1'); // 测试获取 产品41 active 的分支信息对 +r($branch->getPairsTest($productID[0], $param[1])) && p() && e(',1,2'); // 测试获取 产品41 noempty 的分支信息对 +r($branch->getPairsTest($productID[0], $param[2])) && p() && e(',all,0,1,2'); // 测试获取 产品41 all 的分支信息对 +r($branch->getPairsTest($productID[0], $param[3])) && p() && e(',0,1,2'); // 测试获取 产品41 withClosed 的分支信息对 +r($branch->getPairsTest($productID[0], $param[0], $executionID[0])) && p() && e(',0'); // 测试获取 产品41 active 执行141 的分支信息对 +r($branch->getPairsTest($productID[0], $param[0], $executionID[0], $mergedBranches)) && p() && e(',0'); // 测试获取 产品41 active 执行141 合并分支1 4 的分支信息对 +r($branch->getPairsTest($productID[1])) && p() && e(',0,3,4'); // 测试获取 产品41 的分支信息对 +r($branch->getPairsTest($productID[1], $param[0])) && p() && e(',0,3'); // 测试获取 产品41 active 的分支信息对 +r($branch->getPairsTest($productID[1], $param[1])) && p() && e(',3,4'); // 测试获取 产品41 noempty 的分支信息对 +r($branch->getPairsTest($productID[1], $param[2])) && p() && e(',all,0,3,4'); // 测试获取 产品41 all 的分支信息对 +r($branch->getPairsTest($productID[1], $param[3])) && p() && e(',0,3,4'); // 测试获取 产品41 withClosed 的分支信息对 +r($branch->getPairsTest($productID[1], $param[0], $executionID[0])) && p() && e('0'); // 测试获取 产品41 active 执行141 的分支信息对 +r($branch->getPairsTest($productID[1], $param[0], $executionID[0], $mergedBranches)) && p() && e('0'); // 测试获取 产品41 active 执行141 合并分支1 4 的分支信息对 +r($branch->getPairsTest($productID[2])) && p() && e(',0,5,6'); // 测试获取 产品41 的分支信息对 +r($branch->getPairsTest($productID[2], $param[0])) && p() && e(',0,5'); // 测试获取 产品41 active 的分支信息对 +r($branch->getPairsTest($productID[2], $param[1])) && p() && e(',5,6'); // 测试获取 产品41 noempty 的分支信息对 +r($branch->getPairsTest($productID[2], $param[2])) && p() && e(',all,0,5,6'); // 测试获取 产品41 all 的分支信息对 +r($branch->getPairsTest($productID[2], $param[3])) && p() && e(',0,5,6'); // 测试获取 产品41 withClosed 的分支信息对 +r($branch->getPairsTest($productID[2], $param[0], $executionID[0])) && p() && e('0'); // 测试获取 产品41 active 执行141 的分支信息对 +r($branch->getPairsTest($productID[2], $param[0], $executionID[0], $mergedBranches)) && p() && e('0'); // 测试获取 产品41 active 执行141 合并分支1 4 的分支信息对 diff --git a/test/model/branch/getproducttype.php b/test/model/branch/getproducttype.php new file mode 100755 index 0000000000..8adbeb24a7 --- /dev/null +++ b/test/model/branch/getproducttype.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getProductType(); +cid=1 +pid=1 + +*/ +$branchID = array(1, 3, 81, 83, 161, 163); + +$branch = new branchTest(); + +r($branch->getProductTypeTest($branchID[0])) && p() && e('branch'); // 测试获取分支 1 的项目类型 +r($branch->getProductTypeTest($branchID[1])) && p() && e('branch'); // 测试获取分支 3 的项目类型 +r($branch->getProductTypeTest($branchID[2])) && p() && e('platform'); // 测试获取分支 81 的项目类型 +r($branch->getProductTypeTest($branchID[3])) && p() && e('platform'); // 测试获取分支 83 的项目类型 +r($branch->getProductTypeTest($branchID[4])) && p() && e('normal'); // 测试获取分支 161 的项目类型 +r($branch->getProductTypeTest($branchID[5])) && p() && e('normal'); // 测试获取分支 163 的项目类型 diff --git a/test/model/branch/mergebranch.php b/test/model/branch/mergebranch.php new file mode 100755 index 0000000000..762883fb40 --- /dev/null +++ b/test/model/branch/mergebranch.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +mergeBranch(); +cid=1 +pid=1 + +*/ +$productID = array(41, 42); +$mergedBranches = array('1', '2', '3,4'); + +$mergeBranch1 = new stdclass(); +$mergeBranch1->createBranch = 0; +$mergeBranch1->mergedBranchIDList = array(1); +$mergeBranch1->targetBranch = 2; + +$mergeBranch2 = new stdclass(); +$mergeBranch2->name = '新建合并的分支'; +$mergeBranch2->desc = '合并分支的描述'; +$mergeBranch2->createBranch = 1; +$mergeBranch2->mergedBranchIDList = array(2); +$mergeBranch2->targetBranch = 0; + +$mergeBranch3 = new stdclass(); +$mergeBranch3->createBranch = 0; +$mergeBranch3->mergedBranchIDList = array(3, 4); +$mergeBranch3->targetBranch = 0; + +$branch = new branchTest(); + +r($branch->mergeBranchTest($productID[0], $mergedBranches[0], $mergeBranch1)) && p() && e('2'); // 测试合并分支 1 到 分支 2 +r($branch->mergeBranchTest($productID[0], $mergedBranches[1], $mergeBranch2)) && p() && e('2'); // 测试合并分支 2 到 新建分支 +r($branch->mergeBranchTest($productID[1], $mergedBranches[2], $mergeBranch3)) && p() && e('12'); // 测试合并分支 3 4 到 主干 +system("./ztest init"); diff --git a/test/model/branch/setdefault.php b/test/model/branch/setdefault.php new file mode 100755 index 0000000000..77cf523450 --- /dev/null +++ b/test/model/branch/setdefault.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +setDefault(); +cid=1 +pid=1 + +*/ + +$branch = new branchTest(); + +r($branch->setDefaultTest()) && p() && e(); diff --git a/test/model/branch/showbranch.php b/test/model/branch/showbranch.php new file mode 100755 index 0000000000..1ef79fa851 --- /dev/null +++ b/test/model/branch/showbranch.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +showBranch(); +cid=1 +pid=1 + +*/ +$productID = array(1, 41, 81); +$moduleID = array(0, 1821, 1981, 2141); +$executionID = array(0, 101, 231, 181); + +$branch = new branchTest(); + +r($branch->showBranchTest($productID[0])) && p() && e('2'); // 测试验证产品 1 是否显示分支标签 +r($branch->showBranchTest($productID[0], $moduleID[1])) && p() && e('2'); // 测试验证产品 1 模块 1821 是否显示分支标签 +r($branch->showBranchTest($productID[0], $moduleID[0], $executionID[1])) && p() && e('2'); // 测试验证产品 1 执行 101 是否显示分支标签 +r($branch->showBranchTest($productID[0], $moduleID[1], $executionID[1])) && p() && e('2'); // 测试验证产品 1 模块 1821 执行 101 是否显示分支标签 +r($branch->showBranchTest($productID[1])) && p() && e('1'); // 测试验证产品 41 是否显示分支标签 +r($branch->showBranchTest($productID[1], $moduleID[2])) && p() && e('1'); // 测试验证产品 41 模块 1981 是否显示分支标签 +r($branch->showBranchTest($productID[1], $moduleID[0], $executionID[2])) && p() && e('1'); // 测试验证产品 41 执行 231 是否显示分支标签 +r($branch->showBranchTest($productID[1], $moduleID[2], $executionID[2])) && p() && e('1'); // 测试验证产品 41 模块 1981 执行 231 是否显示分支标签 +r($branch->showBranchTest($productID[2])) && p() && e('1'); // 测试验证产品 81 是否显示分支标签 +r($branch->showBranchTest($productID[2], $moduleID[3])) && p() && e('1'); // 测试验证产品 81 模块 2141 是否显示分支标签 +r($branch->showBranchTest($productID[2], $moduleID[0], $executionID[3])) && p() && e('1'); // 测试验证产品 81 执行 181 是否显示分支标签 +r($branch->showBranchTest($productID[2], $moduleID[3], $executionID[3])) && p() && e('1'); // 测试验证产品 81 模块 2141 执行 181 是否显示分支标签 diff --git a/test/model/branch/sort.php b/test/model/branch/sort.php new file mode 100755 index 0000000000..d38b96e080 --- /dev/null +++ b/test/model/branch/sort.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +sort(); +cid=1 +pid=1 + +*/ +$branches = array('0,2,1', '0,4,3', '0,6,5', '0,8,7'); +$order = 'order'; + +$branch = new branchTest(); + +r($branch->sortTest($branches[0])) && p() && e('1,2'); // 测试产品 41 排序 +r($branch->sortTest($branches[1])) && p() && e('3,4'); // 测试产品 42 排序 +r($branch->sortTest($branches[2])) && p() && e('5,6'); // 测试产品 43 排序 +r($branch->sortTest($branches[3])) && p() && e('7,8'); // 测试产品 44 排序 +r($branch->sortTest($branches[0], $order)) && p() && e('2,1'); // 测试产品 41 order 排序 +r($branch->sortTest($branches[1], $order)) && p() && e('4,3'); // 测试产品 42 order 排序 +r($branch->sortTest($branches[2], $order)) && p() && e('6,5'); // 测试产品 43 order 排序 +r($branch->sortTest($branches[3], $order)) && p() && e('8,7'); // 测试产品 44 order 排序 +system("./ztest init"); diff --git a/test/model/branch/update.php b/test/model/branch/update.php new file mode 100755 index 0000000000..63854ed9d0 --- /dev/null +++ b/test/model/branch/update.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + +*/ +$changeName = array('name' => '修改后的分支1'); +$changeStatus = array('status' => 'closed'); +$changeDesc = array('desc' => '修改后的分支1描述'); +$emptyName = array('name' => ''); +$repeatName = array('name' => '分支2'); + +$branch = new branchTest(); + +r($branch->updateTest($changeName)) && p('0:field,old,new') && e('name,分支1,修改后的分支1'); // 测试修改分支名称 +r($branch->updateTest($changeStatus)) && p('0:field,old,new') && e('status,active,closed'); // 测试修改分支状态 +r($branch->updateTest($changeDesc)) && p('0:field,old,new') && e('desc,,修改后的分支1描述'); // 测试修改分支描述 +r($branch->updateTest($emptyName)) && p('name:0') && e('『名称』不能为空。'); // 测试修改分支名称 +r($branch->updateTest($repeatName)) && p('name:0') && e('分支名称已存在'); // 测试修改分支名称 +system("./ztest init"); diff --git a/test/ztest b/test/ztest index 9431249a79..ec20e69d85 100755 --- a/test/ztest +++ b/test/ztest @@ -79,6 +79,8 @@ switch($argv[1]) case 'stage': ztfRun('model/stage'); break; + case 'branch': + ztfRun('model/branch'); case 'tree': ztfRun('model/tree'); break;