+ [misc] Add unit tests for searchTao::checkExecutionPriv() 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:09:45 +08:00
co-authored by Claude
parent 9c566b153d
commit 9b7329c858
2 changed files with 51 additions and 0 deletions
@@ -933,4 +933,26 @@ class searchTest
return count($result);
}
/**
* Test checkExecutionPriv method.
*
* @param array $results
* @param array $objectIdList
* @param string $executions
* @access public
* @return int
*/
public function checkExecutionPrivTest(array $results, array $objectIdList, string $executions): int
{
// 使用反射访问私有方法
$reflection = new ReflectionClass($this->objectTao);
$method = $reflection->getMethod('checkExecutionPriv');
$method->setAccessible(true);
$result = $method->invokeArgs($this->objectTao, array($results, $objectIdList, $executions));
if(dao::isError()) return -1;
return count($result);
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 searchTao::checkExecutionPriv();
timeout=0
cid=0
- 执行searchTest模块的checkExecutionPrivTest方法,参数是array @2
- 执行searchTest模块的checkExecutionPrivTest方法,参数是array @0
- 执行searchTest模块的checkExecutionPrivTest方法,参数是array @0
- 执行searchTest模块的checkExecutionPrivTest方法,参数是array @2
- 执行searchTest模块的checkExecutionPrivTest方法,参数是array @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/search.unittest.class.php';
su('admin');
$searchTest = new searchTest();
r($searchTest->checkExecutionPrivTest(array(1 => (object)array('id' => 1), 2 => (object)array('id' => 2)), array(1 => 1, 2 => 2), '1,2,3')) && p() && e(2);
r($searchTest->checkExecutionPrivTest(array(1 => (object)array('id' => 1), 2 => (object)array('id' => 2)), array(4 => 1, 5 => 2), '1,2,3')) && p() && e(0);
r($searchTest->checkExecutionPrivTest(array(1 => (object)array('id' => 1), 2 => (object)array('id' => 2)), array(1 => 1, 2 => 2), '')) && p() && e(0);
r($searchTest->checkExecutionPrivTest(array(1 => (object)array('id' => 1), 2 => (object)array('id' => 2), 3 => (object)array('id' => 3)), array(1 => 1, 4 => 2, 2 => 3), '1,2')) && p() && e(2);
r($searchTest->checkExecutionPrivTest(array(1 => (object)array('id' => 1)), array('0' => 1), '1,2,0')) && p() && e(1);