Merge branch 'hufangzhou_actionUnit' into 'master'

* Add the action unit testcase.

See merge request easycorp/zentaopms!7070
This commit is contained in:
孙广明
2023-02-27 00:33:36 +00:00
2 changed files with 68 additions and 0 deletions
+20
View File
@@ -567,4 +567,24 @@ class actionTest
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;
}
}
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/action.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->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->deleted->range('0,1{4}');
$execution->gen(5);
$action = zdTable('action');
$action->id->range('1-4');
$action->objectType->range('execution');
$action->objectID->range('2,3,4,5');
$action->project->range('1');
$action->actor->range('admin');
$action->action->range('deleted');
$action->extra->range('1');
$action->gen(4);
/**
title=测试 actionModel->restoreStages();
cid=1
pid=1
测试还原id为2和3的阶段 >> 0
*/
$action = new actionTest();
$hasDeleted = $action->restoreStagesTest(array(2 => 2, 3 => 3), array(1, 2));
r($hasDeleted[2]) && p('extra') && e('0'); // 测试还原id为2和3的阶段