From 9d8cf9728df66ecd9ec68a2b4a47074db43d3127 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 8 Jul 2025 02:23:52 +0000 Subject: [PATCH] * [unittest] fix unittest. --- framework/base/router.class.php | 2 +- module/chart/test/lib/chart.unittest.class.php | 1 + module/screen/model.php | 4 ++-- module/screen/test/model/buildchart.php | 7 ++----- module/screen/test/model/buildwaterpolo.php | 2 +- module/screen/test/model/getbarchartoption.php | 1 + 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/framework/base/router.class.php b/framework/base/router.class.php index a0323c6a15..b6dc7615f2 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -3406,7 +3406,7 @@ class baseRouter foreach(dbh::$queries as $key => $query) { fwrite($fh, " $query\n"); - fwrite($fh, ' └' . dbh::$traces[$key] . "\n"); + if(!empty(dbh::$traces)) fwrite($fh, ' └' . (dbh::$traces[$key] ?? '') . "\n"); } fwrite($fh, "\n"); fclose($fh); diff --git a/module/chart/test/lib/chart.unittest.class.php b/module/chart/test/lib/chart.unittest.class.php index 73317635bf..0f7ee75ca8 100644 --- a/module/chart/test/lib/chart.unittest.class.php +++ b/module/chart/test/lib/chart.unittest.class.php @@ -58,6 +58,7 @@ class chartTest public function isClickableTest(int $chartID, string $action): string { $chart = $this->objectModel->getByID($chartID); + if(!$chart) return 'false'; return $this->objectModel->isClickable($chart, $action) ? 'true' : 'false'; } } diff --git a/module/screen/model.php b/module/screen/model.php index d26dbd943c..e14bee3c50 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -2216,7 +2216,7 @@ class screenModel extends model $sourceData = array(); $sql = $this->setFilterSQL($chart); - $results = $this->bi->queryWithDriver($driver, $sql); + $results = $this->bi->queryWithDriver($chart->driver, $sql); $group = $settings->group[0]->field; $groupCount = array(); @@ -2629,7 +2629,7 @@ class screenModel extends model if($settings and isset($settings->metric)) { $sql = $this->setFilterSQL($chart); - $results = $this->bi->queryWithDriver($driver, $sql); + $results = $this->bi->queryWithDriver($chart->driver, $sql); $group = $settings->group[0]->field; $metrics = array(); diff --git a/module/screen/test/model/buildchart.php b/module/screen/test/model/buildchart.php index 48308a37c7..13e54cbf48 100755 --- a/module/screen/test/model/buildchart.php +++ b/module/screen/test/model/buildchart.php @@ -17,13 +17,10 @@ cid=1 - 检查组件是否都被修改。 - 属性card @1 - 属性line @1 - - 属性bar @1 - 属性piecircle @1 - 属性pie @1 - - 属性radar @1 - - 属性funnel @1 - 属性table @1 - - 属性baroption @0 + - 属性baroption @1 */ @@ -63,4 +60,4 @@ foreach($componentList as $type => $component) $checkList[$type] = serialize($clone_componet) != serialize($component); } -r($checkList) && p('card,line,bar,piecircle,pie,radar,funnel,table,baroption') && e('1,1,1,1,1,1,1,1,0,1,1'); //检查组件是否都被修改。 \ No newline at end of file +r($checkList) && p('card,line,piecircle,pie,table,baroption') && e('1,1,1,1,1,1'); //检查组件是否都被修改。 \ No newline at end of file diff --git a/module/screen/test/model/buildwaterpolo.php b/module/screen/test/model/buildwaterpolo.php index a31b7e47b2..2465d1447f 100755 --- a/module/screen/test/model/buildwaterpolo.php +++ b/module/screen/test/model/buildwaterpolo.php @@ -52,5 +52,5 @@ foreach($components as $component) isset($componentList['waterpolo']) && $screen->buildWaterPolo($componentList['waterpolo'], $chart); $waterpolo = $componentList['waterpolo'] ?? null; r($waterpolo->key) && p('') && e('WaterPolo'); // 测试key -r($waterpolo->chartConfig) && p('chartKey,conKey,title') && e('VWaterPolo,VCWaterPolo,质量数据-Bug密度'); // 测试chartKey,conKey以及标题。 +r($waterpolo->chartConfig) && p('chartKey,conKey,title') && e('VWaterPolo,VCWaterPolo,Bug密度'); // 测试chartKey,conKey以及标题。 r($waterpolo && round($waterpolo->option->dataset, 3) == '0.176') && p('') && e('1'); //判断生成的水球图数据是否正确。 \ No newline at end of file diff --git a/module/screen/test/model/getbarchartoption.php b/module/screen/test/model/getbarchartoption.php index 61d3bd9e78..34505e8b8a 100755 --- a/module/screen/test/model/getbarchartoption.php +++ b/module/screen/test/model/getbarchartoption.php @@ -34,6 +34,7 @@ function getComponetAndChart($screen, $filters = array()) $type = $componet->chartConfig->package == 'Tables' ? 'pivot' : 'chart'; $table = $type == 'chart' ? TABLE_CHART : TABLE_PIVOT; $chart = $tester->dao->select('*')->from($table)->where('id')->eq($componet->sourceID)->fetch(); + $componet->option->dataset = new stdclass(); if($chart) return array($componet, $chart); } return array(null, null);