diff --git a/module/metric/test/lib/metric.unittest.class.php b/module/metric/test/lib/metric.unittest.class.php index 2031a7cd8d..1b5a8e2590 100644 --- a/module/metric/test/lib/metric.unittest.class.php +++ b/module/metric/test/lib/metric.unittest.class.php @@ -89,4 +89,18 @@ class metricTest return $result; } + + /** + * Test getDAO method. + * + * @access public + * @return mixed + */ + public function getDAOTest() + { + $result = $this->objectModel->getDAO(); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/metric/test/model/getdao.php b/module/metric/test/model/getdao.php new file mode 100755 index 0000000000..3cb3c7a978 --- /dev/null +++ b/module/metric/test/model/getdao.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php +metricDB->type) ? $config->metricDB->type : 'mysql'; + +// 4. 🔴 强制要求:必须包含至少5个测试步骤 +// 步骤1:正常情况获取DAO对象 +r($metricTest->getDAOTest()) && p('driver') && e('mysql'); + +// 步骤2:设置为mysql类型测试 +if(!isset($config->metricDB)) $config->metricDB = new stdClass(); +$config->metricDB->type = 'mysql'; +r($metricTest->getDAOTest()) && p('driver') && e('mysql'); + +// 步骤3:测试默认情况返回原始dao +$config->metricDB->type = 'other'; +r($metricTest->getDAOTest()) && p('driver') && e('mysql'); + +// 步骤4:测试配置为空字符串时的默认行为 +$config->metricDB = new stdClass(); +$config->metricDB->type = ''; +r($metricTest->getDAOTest()) && p('driver') && e('mysql'); + +// 步骤5:恢复原始配置并再次测试 +$config->metricDB = new stdClass(); +$config->metricDB->type = $originalType; +r($metricTest->getDAOTest()) && p('driver') && e('mysql'); \ No newline at end of file