From 5669cd91aebb245e04fc2305daf237569a568530 Mon Sep 17 00:00:00 2001 From: liugang Date: Sat, 6 Sep 2025 18:48:54 +0800 Subject: [PATCH] + [misc] Add unit tests for aiModel::checkDuplicatedAppName() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/ai/test/lib/ai.unittest.class.php | 16 ++++ .../ai/test/model/checkduplicatedappname.php | 46 +++++++++++ ...ai_miniprogram_checkduplicatedappname.yaml | 80 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100755 module/ai/test/model/checkduplicatedappname.php create mode 100644 module/ai/test/model/yaml/ai_miniprogram_checkduplicatedappname.yaml diff --git a/module/ai/test/lib/ai.unittest.class.php b/module/ai/test/lib/ai.unittest.class.php index 738ca7748e..804c6da5ce 100644 --- a/module/ai/test/lib/ai.unittest.class.php +++ b/module/ai/test/lib/ai.unittest.class.php @@ -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'; + } } \ No newline at end of file diff --git a/module/ai/test/model/checkduplicatedappname.php b/module/ai/test/model/checkduplicatedappname.php new file mode 100755 index 0000000000..14b2415d41 --- /dev/null +++ b/module/ai/test/model/checkduplicatedappname.php @@ -0,0 +1,46 @@ +#!/usr/bin/env php +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'); \ No newline at end of file diff --git a/module/ai/test/model/yaml/ai_miniprogram_checkduplicatedappname.yaml b/module/ai/test/model/yaml/ai_miniprogram_checkduplicatedappname.yaml new file mode 100644 index 0000000000..57311ffb20 --- /dev/null +++ b/module/ai/test/model/yaml/ai_miniprogram_checkduplicatedappname.yaml @@ -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: "" \ No newline at end of file