* Fix unit test bug.
This commit is contained in:
@@ -627,53 +627,6 @@ class control extends baseControl
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加工作流新增的字段到表单提交配置。
|
||||
* append workflow form config.
|
||||
*
|
||||
* @param array $config
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function appendExtendFormConfig(array $config, string $moduleName = '', string $methodName = ''): array
|
||||
{
|
||||
if($this->config->edition == 'open') return $config;
|
||||
|
||||
$moduleName = $moduleName ? $moduleName : $this->app->getModuleName();
|
||||
$methodName = $methodName ? $moduleName : $this->app->getMethodName();
|
||||
|
||||
$flow = $this->loadModel('workflow')->getByModule($moduleName);
|
||||
if(!$flow) return $config;
|
||||
|
||||
$action = $this->loadModel('workflowaction')->getByModuleAndAction($flow->module, $methodName);
|
||||
if(!$action) return $config;
|
||||
|
||||
$fieldList = $this->workflowaction->getFields($flow->module, $action->action);
|
||||
$layouts = $this->loadModel('workflowlayout')->getFields($moduleName, $methodName);
|
||||
$notEmptyRule = $this->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty');
|
||||
if($layouts)
|
||||
{
|
||||
foreach($fieldList as $key => $field)
|
||||
{
|
||||
if($field->buildin || !$field->show || !isset($layouts[$field->field])) continue;
|
||||
|
||||
$required = $field->readonly || ($notEmptyRule && strpos(",$field->rules,", ",{$notEmptyRule->id},") !== false);
|
||||
if($field->control == 'multi-select' || $field->control == 'checkbox')
|
||||
{
|
||||
$config[$field->field] = array('required' => $required, 'type' => 'array', 'default' => array(''), 'filter' => 'join');
|
||||
}
|
||||
else
|
||||
{
|
||||
$config[$field->field] = array('required' => $required, 'type' => 'string');
|
||||
if($field->control == 'richtext') $config[$field->field]['control'] = 'editor';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process status of an object according to its subStatus.
|
||||
*
|
||||
|
||||
+55
-4
@@ -71,9 +71,10 @@ class form extends fixer
|
||||
{
|
||||
global $app, $config;
|
||||
|
||||
$form = new form;
|
||||
if($configObject === null) $configObject = $config->{$app->moduleName}->form->{$app->methodName};
|
||||
$configObject = $app->control->appendExtendFormConfig($configObject);
|
||||
return (new form)->config($configObject);
|
||||
$configObject = $form->appendExtendFormConfig($configObject);
|
||||
return $form->config($configObject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,9 +88,59 @@ class form extends fixer
|
||||
{
|
||||
global $app, $config;
|
||||
|
||||
$form = new form;
|
||||
if($configObject === null) $configObject = $config->{$app->moduleName}->form->{$app->methodName};
|
||||
$configObject = $app->control->appendExtendFormConfig($configObject);
|
||||
return (new form)->config($configObject, 'batch');
|
||||
$configObject = $form->appendExtendFormConfig($configObject);
|
||||
return $form->config($configObject, 'batch');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 追加工作流新增的字段到表单提交配置。
|
||||
* append workflow form config.
|
||||
*
|
||||
* @param array $config
|
||||
* @param string $moduleName
|
||||
* @param string $methodName
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function appendExtendFormConfig(array $configObject, string $moduleName = '', string $methodName = ''): array
|
||||
{
|
||||
global $app, $config;
|
||||
if($config->edition == 'open') return $configObject;
|
||||
|
||||
$moduleName = $moduleName ? $moduleName : $app->getModuleName();
|
||||
$methodName = $methodName ? $moduleName : $app->getMethodName();
|
||||
|
||||
$flow = $app->control->loadModel('workflow')->getByModule($moduleName);
|
||||
if(!$flow) return $configObject;
|
||||
|
||||
$action = $app->control->loadModel('workflowaction')->getByModuleAndAction($flow->module, $methodName);
|
||||
if(!$action) return $configObject;
|
||||
|
||||
$fieldList = $app->control->workflowaction->getFields($flow->module, $action->action);
|
||||
$layouts = $app->control->loadModel('workflowlayout')->getFields($moduleName, $methodName);
|
||||
$notEmptyRule = $app->control->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty');
|
||||
if($layouts)
|
||||
{
|
||||
foreach($fieldList as $key => $field)
|
||||
{
|
||||
if($field->buildin || !$field->show || !isset($layouts[$field->field])) continue;
|
||||
|
||||
$required = $field->readonly || ($notEmptyRule && strpos(",$field->rules,", ",{$notEmptyRule->id},") !== false);
|
||||
if($field->control == 'multi-select' || $field->control == 'checkbox')
|
||||
{
|
||||
$configObject[$field->field] = array('required' => $required, 'type' => 'array', 'default' => array(''), 'filter' => 'join');
|
||||
}
|
||||
else
|
||||
{
|
||||
$configObject[$field->field] = array('required' => $required, 'type' => 'string');
|
||||
if($field->control == 'richtext') $configObject[$field->field]['control'] = 'editor';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $configObject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,11 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/my.class.php';
|
||||
|
||||
zdtable('action')->gen('100');
|
||||
zdtable('doc')->gen('0');
|
||||
zdtable('api')->gen('0');
|
||||
zdtable('doclib')->gen('0');
|
||||
zdtable('project')->gen('0');
|
||||
zdtable('product')->gen('0');
|
||||
zdTable('user')->gen('1');
|
||||
|
||||
su('admin');
|
||||
|
||||
@@ -21,13 +21,14 @@ $pivot = new pivotTest();
|
||||
|
||||
$varList = array('', '123123123', '$MONDAY', '$SUNDAY', '$MONTHBEGIN', '$MONTHEND');
|
||||
|
||||
$monday = date('Y-m-d', strtotime('this monday'));
|
||||
$sunday = date('Y-m-d', strtotime('this sunday'));
|
||||
|
||||
$monday = date('Y-m-d', strtotime('monday this week'));
|
||||
$sunday = date('Y-m-d', strtotime('sunday this week'));
|
||||
$monthbegin = date('Y-m-01');
|
||||
$monthend = date('Y-m-t');
|
||||
|
||||
r($pivot->processDateVar($varList[0])) && p('') && e('0'); //测试空值
|
||||
r($pivot->processDateVar($varList[1])) && p('') && e('123123123'); //测试非法值生成是正确
|
||||
r($pivot->processDateVar($varList[0])) && p('') && e('0'); //测试空值
|
||||
r($pivot->processDateVar($varList[1])) && p('') && e('123123123'); //测试非法值生成是正确
|
||||
r($pivot->processDateVar($varList[2]) === $monday) && p('') && e('1'); //测试$MONDAY生成是否正确
|
||||
r($pivot->processDateVar($varList[3]) === $sunday) && p('') && e('1'); //测试$SUNDAY生成是否正确
|
||||
r($pivot->processDateVar($varList[4]) === $monthbegin) && p('') && e('1'); //测试$MONTHBEGIN生成是否正确
|
||||
|
||||
@@ -52,6 +52,8 @@ $bug = zdTable('bug');
|
||||
$bug->execution->range('0');
|
||||
$bug->gen(10);
|
||||
|
||||
zdTable('product')->gen(20);
|
||||
zdTable('user')->gen(20);
|
||||
zdTable('repo')->config('repo')->gen(4);
|
||||
|
||||
global $app;
|
||||
@@ -87,4 +89,4 @@ $log->msg = $log->comment = 'Fix bug#1,2';
|
||||
$repo->saveAction2PMSTest($log, $repoID);
|
||||
$result = $tester->loadModel('bug')->getByIdList(array(1,2));
|
||||
r($result) && p('1:status,resolution') && e('resolved,fixed'); //修复bug1
|
||||
r($result) && p('2:status,resolution') && e('resolved,fixed'); //修复bug2
|
||||
r($result) && p('2:status,resolution') && e('resolved,fixed'); //修复bug2
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/screen.class.php';
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
zdTable('product')->gen(2);
|
||||
zdTable('story')->config('story')->gen(20);
|
||||
zdTable('action')->gen(20);
|
||||
@@ -58,4 +59,4 @@ if($component3) $screen->buildComponentTest($component3);
|
||||
r($component3->styles && $component->status && $component->request) && p('') && e('1'); //非列表的组件判断是否给予了默认的属性。
|
||||
|
||||
if($component4) $screen->buildComponentTest($component4);
|
||||
r($component3->styles && $component->status && $component->request) && p('') && e('1'); //列表的组件判断是否给予了默认的属性。
|
||||
r($component3->styles && $component->status && $component->request) && p('') && e('1'); //列表的组件判断是否给予了默认的属性。
|
||||
|
||||
@@ -24,6 +24,8 @@ cid=1
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/screen.class.php';
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screenTest = new screenTest();
|
||||
$screenIDList = array(1, 5, 8);
|
||||
$screenList = array();
|
||||
@@ -45,4 +47,4 @@ r($editCanvasConfig) && p('width,height') && e('1300, 3267'); // 测试id为1的
|
||||
r($componentList) && p('0:id;43:id') && e('5scfjzqsbzo000;1j55da3c41vk00');
|
||||
|
||||
list($schmea, $filter) = $screenTest->genChartDataTest($screenList[5], $yearList[1], 0, $deptList[1], $accountList[1]);
|
||||
r($filter) && p('year,dept,account') && e('2022,1,admin'); //测试传入的过滤参数是否正常赋值。
|
||||
r($filter) && p('year,dept,account') && e('2022,1,admin'); //测试传入的过滤参数是否正常赋值。
|
||||
|
||||
@@ -14,6 +14,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
global $tester;
|
||||
$screen = new screenTest();
|
||||
|
||||
@@ -54,4 +56,4 @@ $chart2->sql = '';
|
||||
$chart2->filters = '[{"field":"type","type":"int"}]';
|
||||
$screen->genComponentDataTest($chartList[1], $componentList[1], $typeList[1], array());
|
||||
|
||||
r($chart2_->sql !== $chart2->sql) && p('') && e(1); //判断图表的sql字段是否被修改
|
||||
r($chart2_->sql !== $chart2->sql) && p('') && e(1); //判断图表的sql字段是否被修改
|
||||
|
||||
@@ -20,6 +20,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
$screenIDList = array(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
@@ -83,4 +85,4 @@ foreach($result->chartData->componentList as $component)
|
||||
}
|
||||
}
|
||||
|
||||
r($chart2 && $chart2->chartConfig->dataset == $chart2->option->dataset) && p('') && e(1); //测试screenID为6的情况
|
||||
r($chart2 && $chart2->chartConfig->dataset == $chart2->option->dataset) && p('') && e(1); //测试screenID为6的情况
|
||||
|
||||
@@ -18,6 +18,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
$chart = new stdclass();
|
||||
@@ -88,4 +90,4 @@ $result = $screen->getChartFiltersTest($chart3);
|
||||
r($result[0]['default']) && p('0,1') && e('1672502400000,1672588800000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。
|
||||
|
||||
$result = $screen->getChartFiltersTest($chart5);
|
||||
r($result) && p('0:default') && e('1672502400000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。
|
||||
r($result) && p('0:default') && e('1672502400000'); //当from不存在,type为date并且default存在的时候,生成default应该为default的值,检查是否生成了正确的default值。
|
||||
|
||||
@@ -29,6 +29,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
function getComponetAndChart($screen, $filters = array())
|
||||
@@ -124,4 +126,4 @@ r(is_null($component12) && is_null($chart12)) && p('') && e(1);
|
||||
|
||||
list($component13, $chart13) = getComponetAndChart($screen, $filter12);
|
||||
$screen->getChartOptionTest($chart13, $component13);
|
||||
r($component13->option->dataset === '0') && p('') && e(1); //测试type为card的图表是否显示正确,生成的指标项和数据项是否正确。
|
||||
r($component13->option->dataset === '0') && p('') && e(1); //测试type为card的图表是否显示正确,生成的指标项和数据项是否正确。
|
||||
|
||||
@@ -14,6 +14,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
$components = $screen->getAllComponent(array('key' => 'Select'));
|
||||
@@ -35,4 +37,4 @@ foreach($components as $component)
|
||||
}
|
||||
$component2_ = clone($component2);
|
||||
$screen->getLatestChartTest($component2);
|
||||
r($component2 && $component2 == $component2_) && p('') && e(1); //当component的sourceID不存在时,不会修改component
|
||||
r($component2 && $component2 == $component2_) && p('') && e(1); //当component的sourceID不存在时,不会修改component
|
||||
|
||||
@@ -19,6 +19,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
function getComponetAndChart($screen, $filters = array())
|
||||
@@ -42,4 +44,4 @@ list($component9, $chart9) = getComponetAndChart($screen, $filter9);
|
||||
$screen->getChartOptionTest($chart9, $component9);
|
||||
$option = $component9->option;
|
||||
r(isset($option->header[0]) && count($option->header[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的header指标项数量是否正确。
|
||||
r(isset($option->dataset[0]) && count($option->dataset[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的dataset数据项数量是否正确。
|
||||
r(isset($option->dataset[0]) && count($option->dataset[0]) == 10) && p('') && e(1); //测试type为table的图表是否显示正确,生成的dataset数据项数量是否正确。
|
||||
|
||||
@@ -19,6 +19,8 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('screen')->gen(0);
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
$component1 = new stdclass();
|
||||
@@ -56,4 +58,4 @@ $screen->initComponentTest($chartList[1], $typeList[0], $componentList[1]);
|
||||
r(isset($componentList[1]->option)) && p('') && e(1); //当图表为自定义图表时, 判断是否正确生成了option对象。
|
||||
r(isset($componentList[1]->option->dataset)) && p('') && e(1); //当图表为自定义图表时,判断是否正确生成了option->dataset对象。
|
||||
r($componentList[1]->chartConfig->title) && p('') && e('test chart'); //当图表为自定义图表时,组件的设置名称为图表的名称。
|
||||
r($componentList[1]->chartConfig->sourceID) && p('') && e(1); //当图表为自定义图表时,组件的设置id为图表的id。
|
||||
r($componentList[1]->chartConfig->sourceID) && p('') && e(1); //当图表为自定义图表时,组件的设置id为图表的id。
|
||||
|
||||
@@ -27,8 +27,8 @@ zdTable('user')->gen(5);
|
||||
zdTable('action')->gen(0);
|
||||
|
||||
$project = zdTable('project');
|
||||
$project->begin->range('2023-11-01')->type('timestamp')->format('YYYY-MM-DD');
|
||||
$project->end->range('2023-12-31')->type('timestamp')->format('YYYY-MM-DD');
|
||||
$project->begin->range('20231101 000000:0')->type('timestamp')->format('YYYY-MM-DD');
|
||||
$project->end->range('20231231 000000:0')->type('timestamp')->format('YYYY-MM-DD');
|
||||
$project->gen(2);
|
||||
|
||||
su('admin');
|
||||
@@ -62,9 +62,9 @@ $emptyName->PM = 'user1';
|
||||
|
||||
$programID = array(1, 2);
|
||||
|
||||
r($upgrade->createProjectTest($programID[0], $project1)) && p() && e('project:3,项目1,2059-12-31,open; program:2023-12-01,2024-03-12; actionCount:2'); // 测试创建 project1 到项目集 1
|
||||
r($upgrade->createProjectTest($programID[0], $project1)) && p() && e('project:3,项目1,2059-12-31,open; program:2023-11-01,2023-12-31; actionCount:2'); // 测试创建 project1 到项目集 1
|
||||
r($upgrade->createProjectTest($programID[0], $project2)) && p() && e('project:4,项目2,2024-12-31,open; program:2021-12-01,2024-12-31; actionCount:1'); // 测试创建 project2 到项目集 1
|
||||
r($upgrade->createProjectTest($programID[1], $project1)) && p() && e('project:5,项目1,2059-12-31,open; program:2023-12-01,2024-03-12; actionCount:2'); // 测试创建 project1 到项目集 2
|
||||
r($upgrade->createProjectTest($programID[1], $project1)) && p() && e('project:5,项目1,2059-12-31,open; program:2023-11-01,2023-12-31; actionCount:2'); // 测试创建 project1 到项目集 2
|
||||
r($upgrade->createProjectTest($programID[1], $project2)) && p() && e('project:6,项目2,2024-12-31,open; program:2021-12-01,2024-12-31; actionCount:1'); // 测试创建 project2 到项目集 2
|
||||
r($upgrade->createProjectTest($programID[0], $emptyName)) && p('name:0') && e('『项目名称』不能为空。'); // 测试创建 项目名称空 的项目到项目集 1
|
||||
r($upgrade->createProjectTest($programID[1], $project1)) && p('name:0') && e('『项目名称』已经有『项目1』这条记录了。如果您确定该记录已删除,请到后台-系统设置-回收站还原。'); // 测试重复创建 project1 到项目集 2
|
||||
|
||||
Reference in New Issue
Block a user