diff --git a/test/class/branch.class.php b/test/class/branch.class.php index 713abbfaed..2c12d9c7cd 100644 --- a/test/class/branch.class.php +++ b/test/class/branch.class.php @@ -201,24 +201,40 @@ class branchTest return $object; } + /** + * Test unlink branches for projects when product type is normal. + * + * @param string $productIDList + * @access public + * @return int + */ public function unlinkBranch4ProjectTest($productIDList) { - $objects = $this->objectModel->unlinkBranch4Project($productIDList); + $this->objectModel->unlinkBranch4Project($productIDList); if(dao::isError()) return dao::getError(); - return $objects; + 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->unlinkBranch4Project($productID); - - $objects = $this->objectModel->linkBranch4Project($productID); + $this->objectModel->linkBranch4Project($productID); if(dao::isError()) return dao::getError(); - return $objects; + global $tester; + $objects = $tester->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($productID)->andWhere('branch')->gt(0)->fetchAll(); + return count($objects); } /** @@ -302,13 +318,23 @@ class branchTest return $objects ? 1 : 2; } + /** + * 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(); - return $objects; + $names = ''; + foreach($objects as $id => $name) $names .= "$id:$name;"; + return $names; } /** diff --git a/test/data/bug.yaml b/test/data/bug.yaml index dfacec31d1..2628756984 100644 --- a/test/data/bug.yaml +++ b/test/data/bug.yaml @@ -9,7 +9,7 @@ fields: - field: product range: 1-100{3} - field: branch - range: 0 + range: 0{120},0-2,0,3-4,0,5-6,0,7-8,0,9-10,0{100000000} - field: module range: 1821-1823,1825-1827,1831-1833,0{1000000} - field: execution diff --git a/test/data/projectproduct.yaml b/test/data/projectproduct.yaml index 7d5dd08a45..b2f0d8234e 100644 --- a/test/data/projectproduct.yaml +++ b/test/data/projectproduct.yaml @@ -7,6 +7,6 @@ fields: - field: product range: 1-100 - field: branch - range: 0{30},1-10:2,0{165} + range: 0{40},1-10:2,0{155} - field: plan range: 1-360:3 diff --git a/test/model/branch/activate.php b/test/model/branch/activate.php index ddb55ee377..057d5e89d7 100755 --- a/test/model/branch/activate.php +++ b/test/model/branch/activate.php @@ -22,3 +22,4 @@ r($branch->activateTest($branchID[2])) && p('id,status') && e('6,active'); // 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 +system("./ztest init"); diff --git a/test/model/branch/getpairsbyprojectproduct.php b/test/model/branch/getpairsbyprojectproduct.php new file mode 100755 index 0000000000..1ace2929f0 --- /dev/null +++ b/test/model/branch/getpairsbyprojectproduct.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getPairsByProjectProduct(); +cid=1 +pid=1 + +*/ +$projectID = array(51, 52, 53, 54, 55); +$productID = array(41, 42, 43, 44, 45); + +$branch = new branchTest(); + +r($branch->getPairsByProjectProductTest($projectID[0], $productID[0])) && p() && e('1:分支1;'); // 测试获取 项目 51 产品 41 的关联分支 +r($branch->getPairsByProjectProductTest($projectID[1], $productID[1])) && p() && e('3:分支3;'); // 测试获取 项目 52 产品 42 的关联分支 +r($branch->getPairsByProjectProductTest($projectID[2], $productID[2])) && p() && e('5:分支5;'); // 测试获取 项目 53 产品 43 的关联分支 +r($branch->getPairsByProjectProductTest($projectID[3], $productID[3])) && p() && e('7:分支7;'); // 测试获取 项目 54 产品 44 的关联分支 +r($branch->getPairsByProjectProductTest($projectID[4], $productID[4])) && p() && e('9:分支9;'); // 测试获取 项目 55 产品 45 的关联分支 diff --git a/test/model/branch/linkbranch4project.php b/test/model/branch/linkbranch4project.php new file mode 100755 index 0000000000..b13c90b597 --- /dev/null +++ b/test/model/branch/linkbranch4project.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +linkBranch4Project(); +cid=1 +pid=1 + +*/ + +$productID = array(41, 42, 43, 44, 45); + + +$branch = new branchTest(); + +r($branch->linkBranch4ProjectTest($productID[0])) && p() && e('4'); // 测试关联产品 41 的分支到项目 +r($branch->linkBranch4ProjectTest($productID[1])) && p() && e('4'); // 测试关联产品 42 的分支到项目 +r($branch->linkBranch4ProjectTest($productID[2])) && p() && e('4'); // 测试关联产品 43 的分支到项目 +r($branch->linkBranch4ProjectTest($productID[3])) && p() && e('4'); // 测试关联产品 44 的分支到项目 +r($branch->linkBranch4ProjectTest($productID[4])) && p() && e('4'); // 测试关联产品 45 的分支到项目 +system("./ztest init"); diff --git a/test/model/branch/setdefault.php b/test/model/branch/setdefault.php deleted file mode 100755 index 77cf523450..0000000000 --- a/test/model/branch/setdefault.php +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php -setDefault(); -cid=1 -pid=1 - -*/ - -$branch = new branchTest(); - -r($branch->setDefaultTest()) && p() && e(); diff --git a/test/model/branch/unlinkbranch4project.php b/test/model/branch/unlinkbranch4project.php new file mode 100755 index 0000000000..a872f9bd25 --- /dev/null +++ b/test/model/branch/unlinkbranch4project.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +unlinkBranch4Project(); +cid=1 +pid=1 + +*/ +$productIDList = array('41', '42', '43', '44,45'); + +$branch = new branchTest(); + +r($branch->unlinkBranch4ProjectTest($productIDList[0])) && p() && e('0'); // 测试产品 41 转为普通产品接触分支关联 +r($branch->unlinkBranch4ProjectTest($productIDList[1])) && p() && e('0'); // 测试产品 42 转为普通产品接触分支关联 +r($branch->unlinkBranch4ProjectTest($productIDList[2])) && p() && e('0'); // 测试产品 43 转为普通产品接触分支关联 +r($branch->unlinkBranch4ProjectTest($productIDList[3])) && p() && e('0'); // 测试产品 44 45 转为普通产品接触分支关联 +system("./ztest init"); diff --git a/test/ztest b/test/ztest index ec20e69d85..32052a1b45 100755 --- a/test/ztest +++ b/test/ztest @@ -81,6 +81,7 @@ switch($argv[1]) break; case 'branch': ztfRun('model/branch'); + break; case 'tree': ztfRun('model/tree'); break;