+ [misc] Add unit tests for epicModel::isClickable() 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:15 +08:00
co-authored by Claude
parent 50958ec0fe
commit c78a782027
2 changed files with 77 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
declare(strict_types = 1);
class epicTest
{
public function __construct()
{
global $tester;
$this->objectModel = $tester->loadModel('epic');
$this->objectTao = $tester->loadTao('epic');
}
/**
* Test isClickable method.
*
* @param object $data
* @param string $action
* @access public
* @return mixed
*/
public function isClickableTest($data = null, $action = '')
{
global $app, $tester;
// 确保$app->control存在并能加载story模型
if(!isset($app->control))
{
$app->control = $tester;
}
$result = $this->objectModel->isClickable($data, $action);
if(dao::isError()) return dao::getError();
return $result;
}
}
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env php
<?php
/**
title=测试 epicModel::isClickable();
timeout=0
cid=0
- 步骤1:正常story状态下close动作 @1
- 步骤2:closed状态下close动作 @0
- 步骤3:closed状态下activate动作 @1
- 步骤4:active状态下activate动作 @0
- 步骤5:reviewing状态下recall动作 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/epic.unittest.class.php';
// 2. zendata数据准备(根据需要配置)
$table = zenData('story');
$table->id->range('1-10');
$table->title->range('Epic1,Epic2,Epic3,Epic4,Epic5,Epic6,Epic7,Epic8,Epic9,Epic10');
$table->type->range('epic');
$table->status->range('active{3},closed{2},reviewing{2},changing{1},draft{2}');
$table->assignedTo->range('admin,user1,user2');
$table->gen(10);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$epicTest = new epicTest();
// 5. 🔴 强制要求:必须包含至少5个测试步骤
r($epicTest->isClickableTest((object)array('status' => 'active', 'type' => 'epic'), 'close')) && p() && e('1'); // 步骤1:正常story状态下close动作
r($epicTest->isClickableTest((object)array('status' => 'closed', 'type' => 'epic'), 'close')) && p() && e('0'); // 步骤2:closed状态下close动作
r($epicTest->isClickableTest((object)array('status' => 'closed', 'type' => 'epic'), 'activate')) && p() && e('1'); // 步骤3:closed状态下activate动作
r($epicTest->isClickableTest((object)array('status' => 'active', 'type' => 'epic'), 'activate')) && p() && e('0'); // 步骤4:active状态下activate动作
r($epicTest->isClickableTest((object)array('status' => 'reviewing', 'type' => 'epic'), 'recall')) && p() && e('1'); // 步骤5:reviewing状态下recall动作