* Adjust unit test of programplanModel::updateSubStageAttr().
This commit is contained in:
@@ -2,23 +2,12 @@
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/programplan.class.php';
|
||||
zdTable('user')->gen(5);
|
||||
su('admin');
|
||||
|
||||
$execution = zdTable('project');
|
||||
$execution->id->range('1-5');
|
||||
$execution->name->range('瀑布项目1,阶段a,阶段a子1,阶段a子1子1,阶段b');
|
||||
$execution->type->range('project,stage{4}');
|
||||
$execution->project->range('0,1{4}');
|
||||
$execution->parent->range('0,1,2,3,1');
|
||||
$execution->path->range("`,1,`,`,1,2,`,`,1,2,3,`,`,1,2,3,4,`,`,1,5,`");
|
||||
$execution->status->range('doing,doing,doing,closed,suspended');
|
||||
$execution->attribute->range(" ,mix,request,request,review");
|
||||
$execution->openedBy->range('admin,user1');
|
||||
$execution->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD');
|
||||
$execution->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
|
||||
$execution->realBegan->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
|
||||
$execution->gen(5);
|
||||
function initData()
|
||||
{
|
||||
zdTable('project')->config('project')->gen(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,12 +15,12 @@ title=测试programplanModel->updateSubStageAttr();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试更改id为3的阶段为综合 >> request
|
||||
测试更改id为2的阶段为设计 >> design
|
||||
|
||||
*/
|
||||
|
||||
$plan = new programplanTest();
|
||||
initData();
|
||||
|
||||
r($plan->updateSubStageAttrTest(3, 'mix', 4)) && p('') && e('request'); // 测试更改id为3的阶段为综合
|
||||
r($plan->updateSubStageAttrTest(2, 'design', 3)) && p('') && e('design'); // 测试更改id为2的阶段为设计
|
||||
$plan = new programplanTest();
|
||||
r($plan->updateSubStageAttrTest(1, 'mix')) && p() && e('1'); // 测试更改 id 为 3 存在子阶段的阶段,attribute 更新值为 mix ,结果为 1
|
||||
r($plan->updateSubStageAttrTest(5, 'design')) && p() && e(1); // 测试更改 id 为 5 无子阶段的阶段,更新 attribute 值为 design ,结果为 1
|
||||
r($plan->updateSubStageAttrTest(2, 'design')) && p() && e('design'); // 测试更改 id 为 2 存在子阶段的阶段,更新 attribute 值为 design ,结果为 design
|
||||
r($plan->updateSubStageAttrTest(3, 'design')) && p() && e('design'); // 测试更改 id 为 3 存在子阶段,子阶段下也存在子阶段,更新 attribute 值为 design ,结果为 design
|
||||
|
||||
@@ -409,25 +409,26 @@ class programplanTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试更新子阶段的属性。
|
||||
* Test update sub-stage attribute.
|
||||
*
|
||||
* @param int $planID
|
||||
* @param string $attribute
|
||||
* @param int $subStageID
|
||||
* @access public
|
||||
* @return string
|
||||
* @return bool|string
|
||||
*/
|
||||
public function updateSubStageAttrTest($planID, $attribute, $subStageID)
|
||||
public function updateSubStageAttrTest(int $planID, string $attribute): bool|string
|
||||
{
|
||||
$this->objectModel->updateSubStageAttr($planID, $attribute);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
global $tester;
|
||||
$subStage = $tester->dao->select('attribute')->from(TABLE_PROJECT)->where('parent')->eq($planID)->fetch();
|
||||
if(!$subStage) return true;
|
||||
|
||||
$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;
|
||||
/* Handles the result when the unit test assertion is an empty string. */
|
||||
$attribute = $subStage->attribute == '' ? 'empty string' : $subStage->attribute;
|
||||
return $attribute == 'mix' ? true : $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user