+ [misc] Add unit tests for aiModel::checkDuplicatedAppName() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -867,4 +867,20 @@ class aiTest
|
||||
|
||||
return count($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test checkDuplicatedAppName method.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $appID
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function checkDuplicatedAppNameTest($name = '', $appID = '-1')
|
||||
{
|
||||
$result = $this->objectModel->checkDuplicatedAppName($name, $appID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result ? '1' : '0';
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 aiModel::checkDuplicatedAppName();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行aiTest模块的checkDuplicatedAppNameTest方法,参数是'测试应用1', 5 @1
|
||||
- 执行aiTest模块的checkDuplicatedAppNameTest方法,参数是'不存在的应用', 10 @0
|
||||
- 执行aiTest模块的checkDuplicatedAppNameTest方法,参数是'测试应用2', 3 @0
|
||||
- 执行aiTest模块的checkDuplicatedAppNameTest方法,参数是'', 1 @0
|
||||
- 执行aiTest模块的checkDuplicatedAppNameTest方法,参数是'已删除应用', 1 @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/ai.unittest.class.php';
|
||||
|
||||
$table = zenData('ai_miniprogram');
|
||||
$table->id->range('1-6');
|
||||
$table->name->range('测试应用1{2}, 测试应用2, 测试应用3, 唯一应用, 已删除应用');
|
||||
$table->category->range('工具{3}, 效率{2}, 测试{1}');
|
||||
$table->desc->range('这是一个测试应用{6}');
|
||||
$table->model->range('1{6}');
|
||||
$table->icon->range('writinghand-7{6}');
|
||||
$table->createdBy->range('admin{6}');
|
||||
$table->createdDate->range('`2023-01-01 10:00:00`');
|
||||
$table->editedBy->range('admin{6}');
|
||||
$table->editedDate->range('`2023-01-01 10:00:00`');
|
||||
$table->published->range('0{6}');
|
||||
$table->deleted->range('0{5}, 1{1}');
|
||||
$table->prompt->range('测试提示词{6}');
|
||||
$table->builtIn->range('0{6}');
|
||||
$table->gen(6);
|
||||
|
||||
su('admin');
|
||||
|
||||
$aiTest = new aiTest();
|
||||
|
||||
r($aiTest->checkDuplicatedAppNameTest('测试应用1', 5)) && p() && e('1');
|
||||
r($aiTest->checkDuplicatedAppNameTest('不存在的应用', 10)) && p() && e('0');
|
||||
r($aiTest->checkDuplicatedAppNameTest('测试应用2', 3)) && p() && e('0');
|
||||
r($aiTest->checkDuplicatedAppNameTest('', 1)) && p() && e('0');
|
||||
r($aiTest->checkDuplicatedAppNameTest('已删除应用', 1)) && p() && e('0');
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
title: AI小程序重复名称检查测试数据
|
||||
desc: 用于测试checkDuplicatedAppName方法的测试数据
|
||||
author: Claude
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 小程序ID
|
||||
range: 1-6
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: name
|
||||
note: 小程序名称
|
||||
range: 测试应用1{2}, 测试应用2, 测试应用3, 唯一应用, 已删除应用
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: category
|
||||
note: 分类
|
||||
range: 工具{3}, 效率{2}, 测试{1}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: desc
|
||||
note: 描述
|
||||
range: 这是一个测试应用{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: model
|
||||
note: 模型ID
|
||||
range: 1{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: icon
|
||||
note: 图标
|
||||
range: writinghand-7{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: createdBy
|
||||
note: 创建者
|
||||
range: admin{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: createdDate
|
||||
note: 创建时间
|
||||
range: '2023-01-01 00:00:00'{6}
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: editedBy
|
||||
note: 编辑者
|
||||
range: admin{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: editedDate
|
||||
note: 编辑时间
|
||||
range: '2023-01-01 00:00:00'{6}
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: published
|
||||
note: 是否发布
|
||||
range: '0'{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: publishedDate
|
||||
note: 发布时间
|
||||
range: []{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'{5}, '1'{1}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: prompt
|
||||
note: 提示词模板
|
||||
range: 请帮我{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
- field: builtIn
|
||||
note: 是否内置
|
||||
range: '0'{6}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
Reference in New Issue
Block a user