znt/module/ai/test/model/isexecutable.php

39 lines
2.5 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 aiModel::isExecutable();
timeout=0
cid=15056
- 步骤1完整有效的prompt对象 @1
- 步骤2缺少必填字段name的prompt对象 @0
- 步骤3module字段为空字符串的prompt对象 @0
- 步骤4source字段为空字符串的prompt对象 @0
- 步骤5purpose字段为空字符串的prompt对象 @0
- 步骤6targetForm字段为空字符串的prompt对象 @0
- 步骤7传入空值null @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备简化处理不依赖数据库数据
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$aiTest = new aiModelTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r($aiTest->isExecutableTest((object)array('id' => 1, 'name' => 'prompt1', 'module' => 'story', 'source' => ',story.title,story.spec,', 'purpose' => 'test purpose1', 'targetForm' => 'story.create'))) && p() && e('1'); // 步骤1完整有效的prompt对象
r($aiTest->isExecutableTest((object)array('id' => 2, 'name' => '', 'module' => 'story', 'source' => ',story.title,story.spec,', 'purpose' => 'test purpose2', 'targetForm' => 'story.create'))) && p() && e('0'); // 步骤2缺少必填字段name的prompt对象
r($aiTest->isExecutableTest((object)array('id' => 3, 'name' => 'prompt3', 'module' => '', 'source' => ',story.title,story.spec,', 'purpose' => 'test purpose3', 'targetForm' => 'story.create'))) && p() && e('0'); // 步骤3module字段为空字符串的prompt对象
r($aiTest->isExecutableTest((object)array('id' => 4, 'name' => 'prompt4', 'module' => 'story', 'source' => '', 'purpose' => 'test purpose4', 'targetForm' => 'story.create'))) && p() && e('0'); // 步骤4source字段为空字符串的prompt对象
r($aiTest->isExecutableTest((object)array('id' => 5, 'name' => 'prompt5', 'module' => 'story', 'source' => ',story.title,story.spec,', 'purpose' => '', 'targetForm' => 'story.create'))) && p() && e('0'); // 步骤5purpose字段为空字符串的prompt对象
r($aiTest->isExecutableTest((object)array('id' => 6, 'name' => 'prompt6', 'module' => 'story', 'source' => ',story.title,story.spec,', 'purpose' => 'test purpose6', 'targetForm' => ''))) && p() && e('0'); // 步骤6targetForm字段为空字符串的prompt对象
r($aiTest->isExecutableTest(null)) && p() && e('0'); // 步骤7传入空值null