* Add unit test of branch.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/branch.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 branchModel->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 的关联分支
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/branch.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 branchModel->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");
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/branch.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 branchModel->setDefault();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$branch = new branchTest();
|
||||
|
||||
r($branch->setDefaultTest()) && p() && e();
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/branch.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 branchModel->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");
|
||||
@@ -81,6 +81,7 @@ switch($argv[1])
|
||||
break;
|
||||
case 'branch':
|
||||
ztfRun('model/branch');
|
||||
break;
|
||||
case 'tree':
|
||||
ztfRun('model/tree');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user