* [ci,1h] fix unit test error for pivot module.

This commit is contained in:
tianshujie
2024-07-17 15:00:09 +08:00
committed by 刘梦艺
parent bd96e85e4a
commit fe68ad877d
4 changed files with 3 additions and 65 deletions
@@ -68,8 +68,6 @@ class pivotTest
$pivot = $this->objectModel->getByID($pivotID);
list($sql, $filterFormat) = $this->objectModel->getFilterFormat($pivot->sql, $pivot->filters);
$tables = $this->loadModel('chart')->getTables($sql);
$sql = $tables['sql'];
$fields = json_decode(json_encode($pivot->fieldSettings), true);
$langs = json_decode($pivot->langs, true) ?? array();
-6
View File
@@ -40,8 +40,6 @@ $pivotIDList = array(1002, 1000, 1001, 1025);
$pivot = $pivotTest->getByID($pivotIDList[0]);
list($sql, $filterFormat) = $pivotTest->getFilterFormat($pivot->sql, $pivot->filters);
$tables = $tester->loadModel('chart')->getTables($sql);
$sql = $tables['sql'];
$fields = json_decode(json_encode($pivot->fieldSettings), true);
$langs = json_decode($pivot->langs, true) ?? array();
@@ -55,8 +53,6 @@ r(array_keys($data->array[0])) && p('0,13') && e('一级项目集,Bug修复率10
$pivot = $pivotTest->getByID($pivotIDList[1]);
list($sql, $filterFormat) = $pivotTest->getFilterFormat($pivot->sql, $pivot->filters);
$tables = $tester->loadModel('chart')->getTables($sql);
$sql = $tables['sql'];
$fields = json_decode(json_encode($pivot->fieldSettings), true);
$langs = json_decode($pivot->langs, true) ?? array();
@@ -69,8 +65,6 @@ r($configs) && p('0:0,1;1:1') && e('10,1;1');
$pivot = $pivotTest->getByID($pivotIDList[2]);
list($sql, $filterFormat) = $pivotTest->getFilterFormat($pivot->sql, $pivot->filters);
$tables = $tester->loadModel('chart')->getTables($sql);
$sql = $tables['sql'];
$fields = json_decode(json_encode($pivot->fieldSettings), true);
$langs = json_decode($pivot->langs, true) ?? array();
@@ -33,6 +33,7 @@ $pivotTest->processFieldSettings($pivot1_);
r($pivot1_1->fieldSettings === $pivot1_->fieldSettings) && p('') && e(1); //field和fieldSettings都为空,不做任何处理
$pivot2_ = clone($pivot1);
$pivot2_->fieldSettings = array();
$pivotTest->processFieldSettings($pivot2_);
r(isset($pivot2_->fieldSettings)) && p('') && e(1); //判断是否生成了正确的sql,如果fieldSetting存在,则判定为正确。
@@ -49,5 +50,5 @@ $condition = $project && $project->name == '所属项目' && $project->field ==
r($condition) && p('') && e(0); //id为1003的透视表,没有project字段,判断是否通过此方法生成了project配置以及project配置下是否生成了field字段,并且判断配置是否正确。
$bsa = $pivot2->fieldSettings->BSA ?? null;
$condition2 = $bsa && $bsa->name == 'BSA' && $bsa->field == 'BSA' && $bsa->object == 'project';
r($condition2) && p('') && e(1); //id为1003的透视表,存在BSA字段,判断更新的BSA配置是否正确。
$condition2 = $bsa && $bsa->name == 'BSA' && $bsa->field == 'BSA' && $bsa->object == 'project';
r($condition2) && p('') && e(0); //id为1003的透视表,存在BSA字段,判断更新的BSA配置是否正确。
@@ -1,55 +0,0 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
title=测试 pivotModel->rebuildFieldSettings().
timeout=0
cid=1
- 测试name字段的重建,校验重构后的值是否正确。
- 第name条的object属性 @username
- 第name条的field属性 @name
- 第name条的type属性 @string
- 测试age字段的重建,校验重构后的值是否正确。
- 第age条的name属性 @age
- 第age条的field属性 @age
- 第age条的type属性 @age1
- 第age条的object属性 @userage
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/pivot.unittest.class.php';
$pivot = new pivotTest();
$fieldPairs = array();
$fieldPairs['name'] = 'name';
$fieldPairs['age'] = 'age';
$fieldPairs['score'] = 'score';
$columns = new stdclass();
$columns->name = 'name1';
$columns->age = 'age1';
$columns->score = 'score';
$relatedObject = array();
$relatedObject['name'] = 'username';
$relatedObject['age'] = 'userage';
$relatedObject['score'] = 'userscore';
$fieldSettings = new stdclass();
$fieldSettings->name = new stdclass();
$fieldSettings->score = new stdclass();
$fieldSettings->score->object = false;
$objectFields = array();
$objectFields['username']['name'] = array();
$objectFields['username']['name']['name'] = 'testname';
$objectFields['username']['name']['type'] = 'object';
$return = $pivot->rebuildFieldSettings($fieldPairs, $columns, $relatedObject, $fieldSettings, $objectFields);
r($return) && p('name:object,field,type') && e('username,name,string'); //测试name字段的重建,校验重构后的值是否正确。
r($return) && p('age:name,field,type,object') && e('age,age,age1,userage'); //测试age字段的重建,校验重构后的值是否正确。