* [misc] Fix unit tests for caselibModel::setLibMenu() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-10-11 09:36:10 +08:00
co-authored by Claude
parent 34fafc886f
commit c7164fd649
2 changed files with 11 additions and 6 deletions
@@ -273,7 +273,11 @@ class caselibTest
*/
public function setLibMenuTest(array $libraries = array(), int $libID = 0): bool
{
// Capture any warnings/errors that might occur during cookie setting
ob_start();
$result = $this->objectModel->setLibMenu($libraries, $libID);
$output = ob_get_clean();
if(dao::isError()) return dao::getError();
return $result;
+7 -6
View File
@@ -18,15 +18,16 @@ cid=0
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/caselib.unittest.class.php';
// Skip database operations and user login for this test
// Initialize test environment
global $tester;
if(!isset($tester->app->user)) $tester->app->user = new stdClass();
$tester->app->user->account = 'admin';
if(!isset($tester->session)) $tester->session = new stdClass();
$caselibTest = new caselibTest();
r($caselibTest->setLibMenuTest(array(1 => '用例库1', 2 => '用例库2'), 1)) && p() && e(1);
r($caselibTest->setLibMenuTest(array(), 1)) && p() && e(1);
r($caselibTest->setLibMenuTest(array(), 999)) && p() && e(1);
r($caselibTest->setLibMenuTest(array(1 => '用例库1', 2 => '用例库2'), 999)) && p() && e(1);
r($caselibTest->setLibMenuTest(array(), 0)) && p() && e(1);
r($caselibTest->setLibMenuTest(array(1 => '用例库1', 2 => '用例库2'), 1)) && p() && e('1');
r($caselibTest->setLibMenuTest(array(), 1)) && p() && e('1');
r($caselibTest->setLibMenuTest(array(), 999)) && p() && e('1');
r($caselibTest->setLibMenuTest(array(1 => '用例库1', 2 => '用例库2'), 999)) && p() && e('1');
r($caselibTest->setLibMenuTest(array(), 0)) && p() && e('1');