+ [misc] Add unit tests for screenZen::commonAction() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-18 13:11:57 +08:00
co-authored by Claude
parent 6439205796
commit 47fb516b89
3 changed files with 60 additions and 1 deletions
@@ -1471,4 +1471,34 @@ class screenTest
);
}
/**
* Test commonAction method.
*
* @param int $dimensionID
* @param bool $setMenu
* @access public
* @return mixed
*/
public function commonActionTest($dimensionID, $setMenu = true)
{
global $tester;
// 包含model.php和zen.php文件
include_once dirname(__FILE__, 3) . '/model.php';
include_once dirname(__FILE__, 3) . '/zen.php';
// 创建zen对象并调用方法
$screenZen = new screenZen();
// 使用反射调用protected方法
$reflection = new ReflectionClass($screenZen);
$method = $reflection->getMethod('commonAction');
$method->setAccessible(true);
$result = $method->invokeArgs($screenZen, array($dimensionID, $setMenu));
if(dao::isError()) return dao::getError();
return $result;
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 screenZen::commonAction();
timeout=0
cid=0
- 执行screenTest模块的commonActionTest方法,参数是1 @1
- 执行screenTest模块的commonActionTest方法 @1
- 执行screenTest模块的commonActionTest方法,参数是-1 @1
- 执行screenTest模块的commonActionTest方法,参数是1, false @1
- 执行screenTest模块的commonActionTest方法,参数是999 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/screen.unittest.class.php';
su('admin');
$screenTest = new screenTest();
r($screenTest->commonActionTest(1)) && p() && e('1');
r($screenTest->commonActionTest(0)) && p() && e('1');
r($screenTest->commonActionTest(-1)) && p() && e('1');
r($screenTest->commonActionTest(1, false)) && p() && e('1');
r($screenTest->commonActionTest(999)) && p() && e('1');