Files
EasySoft-ZenTaoPMS/module/zai/test/model/createknowledgelib.php
2025-12-02 16:32:04 +08:00

58 lines
2.0 KiB
PHP
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
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zai.unittest.class.php';
/**
title=测试 zaiModel->createKnowledgeLib();
timeout=0
cid=0
- 测试没有ZAI设置时创建知识库 @0
- 测试使用完整参数创建知识库模拟API调用 @0
- 测试只使用名称创建知识库 @0
- 测试使用名称和描述创建知识库 @0
- 测试使用空名称创建知识库 @0
*/
zenData('config')->gen(0);
zenData('user')->gen(1);
su('admin');
global $tester;
$zai = new zaiTest();
/* 测试没有ZAI设置时创建知识库 */
$result1 = $zai->createKnowledgeLibTest('test-lib-1', 'Test Library 1');
r($result1) && p() && e('0'); // 测试没有ZAI设置时创建知识库
/* 设置ZAI配置 */
$setting = new stdClass();
$setting->host = 'testhost.com';
$setting->port = 8080;
$setting->appID = 'testappid123';
$setting->token = 'testtoken123';
$setting->adminToken = 'testadmintoken123';
$tester->loadModel('setting')->setItem('system.zai.global.setting', json_encode($setting));
/* 测试使用完整参数创建知识库模拟API调用 */
// 由于没有真实的ZAI API服务器这些测试会因为网络调用失败
// 但我们可以验证方法的逻辑执行到API调用阶段
$result2 = $zai->createKnowledgeLibTest('test-lib-2', 'Test Library 2', array('type' => 'custom'));
r($result2) && p() && e('0'); // 测试使用完整参数创建知识库模拟API调用
/* 测试只使用名称创建知识库 */
$result3 = $zai->createKnowledgeLibTest('test-lib-3');
r($result3) && p() && e('0'); // 测试只使用名称创建知识库
/* 测试使用名称和描述创建知识库 */
$result4 = $zai->createKnowledgeLibTest('test-lib-4', 'Description for test library 4');
r($result4) && p() && e('0'); // 测试使用名称和描述创建知识库
/* 测试使用空名称创建知识库 */
$result5 = $zai->createKnowledgeLibTest('');
r($result5) && p() && e('0'); // 测试使用空名称创建知识库