+ [misc] Add unit tests for commonModel::checkIP() 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:12 +08:00
co-authored by Claude
parent 34dde7b795
commit b984d09db7
2 changed files with 48 additions and 0 deletions
@@ -345,4 +345,19 @@ class commonTest
return $result;
}
/**
* Test checkIP method.
*
* @param string $ipWhiteList
* @access public
* @return mixed
*/
public function checkIPTest($ipWhiteList = '')
{
$result = $this->objectModel->checkIP($ipWhiteList);
if(dao::isError()) return dao::getError();
return $result ? '1' : '0';
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 commonModel::checkIP();
timeout=0
cid=0
- 执行commonTest模块的checkIPTest方法,参数是'*' @1
- 执行commonTest模块的checkIPTest方法,参数是'127.0.0.1' @1
- 执行commonTest模块的checkIPTest方法,参数是'192.168.1.1, 127.0.0.1, 10.0.0.1' @1
- 执行commonTest模块的checkIPTest方法,参数是'127.0.0.1-127.0.0.255' @1
- 执行commonTest模块的checkIPTest方法,参数是'127.0.0.*' @1
- 执行commonTest模块的checkIPTest方法,参数是'127.0.0.0/24' @1
- 执行commonTest模块的checkIPTest方法,参数是'192.168.1.1' @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/common.unittest.class.php';
su('admin');
$commonTest = new commonTest();
r($commonTest->checkIPTest('*')) && p() && e('1');
r($commonTest->checkIPTest('127.0.0.1')) && p() && e('1');
r($commonTest->checkIPTest('192.168.1.1,127.0.0.1,10.0.0.1')) && p() && e('1');
r($commonTest->checkIPTest('127.0.0.1-127.0.0.255')) && p() && e('1');
r($commonTest->checkIPTest('127.0.0.*')) && p() && e('1');
r($commonTest->checkIPTest('127.0.0.0/24')) && p() && e('1');
r($commonTest->checkIPTest('192.168.1.1')) && p() && e('0');