+ [misc] Add unit tests for metricModel::buildSearchForm() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:18 +08:00
co-authored by Claude
parent 7bae2d4ff5
commit 4f06b42e52
2 changed files with 46 additions and 0 deletions
@@ -621,4 +621,21 @@ class metricTest
return $result;
}
/**
* Test buildSearchForm method.
*
* @param int $queryID
* @param string $actionURL
* @access public
* @return mixed
*/
public function buildSearchFormTest($queryID = 0, $actionURL = '')
{
$this->objectModel->buildSearchForm($queryID, $actionURL);
if(dao::isError()) return dao::getError();
// 验证方法是否正确执行,通过返回成功标志
return true;
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 metricModel::buildSearchForm();
timeout=0
cid=0
- 执行metricTest模块的buildSearchFormTest方法,参数是1, '/metric/browse' @1
- 执行metricTest模块的buildSearchFormTest方法,参数是0, '/test/url' @1
- 执行metricTest模块的buildSearchFormTest方法,参数是5, '' @1
- 执行metricTest模块的buildSearchFormTest方法,参数是-1, '/negative/test' @1
- 执行metricTest模块的buildSearchFormTest方法,参数是999, '/special?param=value&test=1' @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/metric.unittest.class.php';
su('admin');
$metricTest = new metricTest();
r($metricTest->buildSearchFormTest(1, '/metric/browse')) && p() && e('1');
r($metricTest->buildSearchFormTest(0, '/test/url')) && p() && e('1');
r($metricTest->buildSearchFormTest(5, '')) && p() && e('1');
r($metricTest->buildSearchFormTest(-1, '/negative/test')) && p() && e('1');
r($metricTest->buildSearchFormTest(999, '/special?param=value&test=1')) && p() && e('1');