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

101 lines
3.7 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::canPublishMiniProgram();
timeout=0
cid=14999
- 步骤1完整有效对象 @1
- 步骤2缺少name字段 @0
- 步骤3缺少desc字段 @0
- 步骤4缺少model字段 @0
- 步骤5缺少prompt字段 @0
- 步骤6空字符串字段 @0
- 步骤7所有字段为空 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$aiTest = new aiModelTest();
// 4. 创建测试数据对象
// 测试步骤1完整有效的小程序对象
$validProgram = new stdClass();
$validProgram->id = 1;
$validProgram->name = 'Test Program';
$validProgram->desc = 'This is a test description';
$validProgram->category = 'work';
$validProgram->model = 1;
$validProgram->prompt = 'This is a test prompt';
// 测试步骤2name字段为null的小程序对象
$programWithoutName = new stdClass();
$programWithoutName->id = 2;
$programWithoutName->name = null;
$programWithoutName->desc = 'This is a test description';
$programWithoutName->category = 'work';
$programWithoutName->model = 1;
$programWithoutName->prompt = 'This is a test prompt';
// 测试步骤3desc字段为null的小程序对象
$programWithoutDesc = new stdClass();
$programWithoutDesc->id = 3;
$programWithoutDesc->name = 'Test Program';
$programWithoutDesc->desc = null;
$programWithoutDesc->category = 'work';
$programWithoutDesc->model = 1;
$programWithoutDesc->prompt = 'This is a test prompt';
// 测试步骤4model字段为null的小程序对象
$programWithoutModel = new stdClass();
$programWithoutModel->id = 4;
$programWithoutModel->name = 'Test Program';
$programWithoutModel->desc = 'This is a test description';
$programWithoutModel->category = 'work';
$programWithoutModel->model = null;
$programWithoutModel->prompt = 'This is a test prompt';
// 测试步骤5prompt字段为null的小程序对象
$programWithoutPrompt = new stdClass();
$programWithoutPrompt->id = 5;
$programWithoutPrompt->name = 'Test Program';
$programWithoutPrompt->desc = 'This is a test description';
$programWithoutPrompt->category = 'work';
$programWithoutPrompt->model = 1;
$programWithoutPrompt->prompt = null;
// 测试步骤6name字段为空字符串的小程序对象
$programWithEmptyName = new stdClass();
$programWithEmptyName->id = 6;
$programWithEmptyName->name = '';
$programWithEmptyName->desc = 'This is a test description';
$programWithEmptyName->category = 'work';
$programWithEmptyName->model = 1;
$programWithEmptyName->prompt = 'This is a test prompt';
// 测试步骤7所有字段都为空的小程序对象
$emptyProgram = new stdClass();
$emptyProgram->id = '';
$emptyProgram->name = '';
$emptyProgram->desc = '';
$emptyProgram->category = '';
$emptyProgram->model = '';
$emptyProgram->prompt = '';
// 5. 强制要求必须包含至少5个测试步骤
r($aiTest->canPublishMiniProgramTest($validProgram)) && p() && e('1'); // 步骤1完整有效对象
r($aiTest->canPublishMiniProgramTest($programWithoutName)) && p() && e('0'); // 步骤2缺少name字段
r($aiTest->canPublishMiniProgramTest($programWithoutDesc)) && p() && e('0'); // 步骤3缺少desc字段
r($aiTest->canPublishMiniProgramTest($programWithoutModel)) && p() && e('0'); // 步骤4缺少model字段
r($aiTest->canPublishMiniProgramTest($programWithoutPrompt)) && p() && e('0'); // 步骤5缺少prompt字段
r($aiTest->canPublishMiniProgramTest($programWithEmptyName)) && p() && e('0'); // 步骤6空字符串字段
r($aiTest->canPublishMiniProgramTest($emptyProgram)) && p() && e('0'); // 步骤7所有字段为空