+ [misc] Add unit tests for aiModel::togglePromptStatus() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -994,4 +994,20 @@ class aiTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test togglePromptStatus method.
|
||||
*
|
||||
* @param int|object $prompt prompt (or id) to toggle.
|
||||
* @param string $status optional, will set status to $status if provided.
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function togglePromptStatusTest($prompt = null, $status = '')
|
||||
{
|
||||
$result = $this->objectModel->togglePromptStatus($prompt, $status);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 aiModel::togglePromptStatus();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:使用ID切换draft状态prompt为active @1
|
||||
- 步骤2:使用ID切换active状态prompt为draft @1
|
||||
- 步骤3:使用对象切换prompt状态 @1
|
||||
- 步骤4:指定具体状态进行切换 @1
|
||||
- 步骤5:测试不存在的prompt ID @0
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/ai.unittest.class.php';
|
||||
|
||||
// 2. zendata数据准备(根据需要配置)
|
||||
$table = zenData('ai_prompt');
|
||||
$table->id->range('1-10');
|
||||
$table->name->range('状态切换测试1,状态切换测试2,状态切换测试3,状态切换测试4,状态切换测试5,状态切换测试6,状态切换测试7,状态切换测试8,状态切换测试9,状态切换测试10');
|
||||
$table->desc->range('测试状态切换功能的提示词描述{10}');
|
||||
$table->model->range('1-3');
|
||||
$table->module->range('story{4},task{3},bug{3}');
|
||||
$table->source->range('story.title,task.name,bug.title');
|
||||
$table->targetForm->range('story.edit,task.edit,bug.edit');
|
||||
$table->purpose->range('测试状态切换目的{10}');
|
||||
$table->elaboration->range('测试状态切换详细说明{10}');
|
||||
$table->role->range('测试角色描述{10}');
|
||||
$table->characterization->range('测试角色特征{10}');
|
||||
$table->status->range('draft{5},active{5}');
|
||||
$table->createdBy->range('admin,user1,user2');
|
||||
$table->createdDate->range('`2023-08-10 10:00:00`,`2023-08-11 11:00:00`,`2023-08-12 12:00:00`');
|
||||
$table->deleted->range('0');
|
||||
$table->gen(10);
|
||||
|
||||
// 3. 用户登录(选择合适角色)
|
||||
su('admin');
|
||||
|
||||
// 4. 创建测试实例(变量名与模块名一致)
|
||||
$aiTest = new aiTest();
|
||||
|
||||
// 5. 🔴 强制要求:必须包含至少5个测试步骤
|
||||
r($aiTest->togglePromptStatusTest(1, '')) && p() && e('1'); // 步骤1:使用ID切换draft状态prompt为active
|
||||
r($aiTest->togglePromptStatusTest(6, '')) && p() && e('1'); // 步骤2:使用ID切换active状态prompt为draft
|
||||
r($aiTest->togglePromptStatusTest($aiTest->getPromptByIdTest(2), '')) && p() && e('1'); // 步骤3:使用对象切换prompt状态
|
||||
r($aiTest->togglePromptStatusTest(3, 'active')) && p() && e('1'); // 步骤4:指定具体状态进行切换
|
||||
r($aiTest->togglePromptStatusTest(999, '')) && p() && e('0'); // 步骤5:测试不存在的prompt ID
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
title: AI Prompt状态切换测试数据
|
||||
desc: 为togglePromptStatus方法生成测试数据
|
||||
author: AI
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 提示词ID
|
||||
range: 1-10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: name
|
||||
note: 提示词名称
|
||||
range: 状态切换测试1,状态切换测试2,状态切换测试3,状态切换测试4,状态切换测试5,状态切换测试6,状态切换测试7,状态切换测试8,状态切换测试9,状态切换测试10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: desc
|
||||
note: 提示词描述
|
||||
range: [测试状态切换功能的提示词描述]{10}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: model
|
||||
note: 模型ID
|
||||
range: 1,2,3
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: module
|
||||
note: 所属模块
|
||||
range: story{4},task{3},bug{3}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: source
|
||||
note: 数据源
|
||||
range: ',story.title,story.spec,',',task.name,task.desc,',',bug.title,bug.steps,'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: targetForm
|
||||
note: 目标表单
|
||||
range: story.edit,task.edit,bug.edit
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: purpose
|
||||
note: 目的
|
||||
range: [测试状态切换目的]{10}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: elaboration
|
||||
note: 详细说明
|
||||
range: [测试状态切换详细说明]{10}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: role
|
||||
note: 角色描述
|
||||
range: [测试角色描述]{10}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: characterization
|
||||
note: 角色特征
|
||||
range: [测试角色特征]{10}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: status
|
||||
note: 状态
|
||||
range: draft{5},active{5}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: createdBy
|
||||
note: 创建者
|
||||
range: admin,user1,user2
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: createdDate
|
||||
note: 创建时间
|
||||
range: 2023-08-10 10:00:00,2023-08-11 11:00:00,2023-08-12 12:00:00
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: 0
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
Reference in New Issue
Block a user