+ [misc] Add unit tests for metricModel::getDataset() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 metricModel::getDataset();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行metricTest模块的getDatasetTest方法 属性className @dataset
|
||||
- 执行metricTest模块的getDatasetTest方法 属性dao @object
|
||||
- 执行metricTest模块的getDatasetTest方法 属性config @object
|
||||
- 执行metricTest模块的getDatasetTest方法 属性vision @string
|
||||
- 执行metricTest模块的getDatasetTest方法,参数是null 属性className @dataset
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/metric.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$metricTest = new metricTest();
|
||||
|
||||
r($metricTest->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');
|
||||
Reference in New Issue
Block a user