From 5d23a8ebb8fdd68a9b22448d92ca45f4d682df79 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 8 Sep 2025 22:56:25 +0800 Subject: [PATCH] + [misc] Add unit tests for metricModel::getDataset() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../metric/test/lib/metric.unittest.class.php | 29 +++++++++++++++++++ module/metric/test/model/getdataset.php | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 module/metric/test/model/getdataset.php diff --git a/module/metric/test/lib/metric.unittest.class.php b/module/metric/test/lib/metric.unittest.class.php index c3ccc6a95f..7142d19d81 100644 --- a/module/metric/test/lib/metric.unittest.class.php +++ b/module/metric/test/lib/metric.unittest.class.php @@ -562,4 +562,33 @@ class metricTest return $beforeCount - $afterCount; } + + /** + * Test getDataset method. + * + * @param mixed $dao + * @access public + * @return mixed + */ + public function getDatasetTest($dao = null) + { + if($dao === null) { + global $tester; + $dao = $tester->dao; + } + + $result = $this->objectModel->getDataset($dao); + if(dao::isError()) return dao::getError(); + + if(is_object($result)) { + $info = new stdClass(); + $info->className = get_class($result); + $info->dao = is_object($result->dao) ? gettype($result->dao) : 'null'; + $info->config = is_object($result->config) ? gettype($result->config) : 'null'; + $info->vision = isset($result->vision) ? gettype($result->vision) : 'null'; + return $info; + } + + return $result; + } } \ No newline at end of file diff --git a/module/metric/test/model/getdataset.php b/module/metric/test/model/getdataset.php new file mode 100755 index 0000000000..2e30400308 --- /dev/null +++ b/module/metric/test/model/getdataset.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getDatasetTest()) && p('className') && e('dataset'); +r($metricTest->getDatasetTest()) && p('dao') && e('object'); +r($metricTest->getDatasetTest()) && p('config') && e('object'); +r($metricTest->getDatasetTest()) && p('vision') && e('string'); +r($metricTest->getDatasetTest(null)) && p('className') && e('dataset'); \ No newline at end of file