diff --git a/module/ai/test/lib/ai.unittest.class.php b/module/ai/test/lib/ai.unittest.class.php index ed7625a418..eac79f051e 100644 --- a/module/ai/test/lib/ai.unittest.class.php +++ b/module/ai/test/lib/ai.unittest.class.php @@ -1378,4 +1378,20 @@ class aiTest return $result; } + + /** + * Test getAssistants method. + * + * @param pager $pager + * @param string $orderBy + * @access public + * @return mixed + */ + public function getAssistantsTest($pager = null, $orderBy = 'id_desc') + { + $result = $this->objectModel->getAssistants($pager, $orderBy); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/ai/test/model/getassistants.php b/module/ai/test/model/getassistants.php new file mode 100755 index 0000000000..b36eb43bee --- /dev/null +++ b/module/ai/test/model/getassistants.php @@ -0,0 +1,43 @@ +#!/usr/bin/env php +id->range('1-10'); +$table->name->range('助手1,助手2,助手3,助手4,助手5,助手6,助手7,助手8,助手9,助手10'); +$table->modelId->range('1-5'); +$table->desc->range('这是一个AI助手的描述{10}'); +$table->systemMessage->range('你是一个专业的AI助手{10}'); +$table->greetings->range('你好!我是你的AI助手{10}'); +$table->icon->range('coding-1'); +$table->enabled->range('1'); +$table->createdDate->range('`2024-01-01 10:00:00`,`2024-01-02 10:00:00`,`2024-01-03 10:00:00`,`2024-01-04 10:00:00`,`2024-01-05 10:00:00`,`2024-01-06 10:00:00`,`2024-01-07 10:00:00`,`2024-01-08 10:00:00`,`2024-01-09 10:00:00`,`2024-01-10 10:00:00`'); +$table->publishedDate->range('`2024-01-05 10:00:00`'); +$table->deleted->range('0'); +$table->gen(10); + +su('admin'); + +$aiTest = new aiTest(); + +r(count($aiTest->getAssistantsTest())) && p() && e('10'); +r($aiTest->getAssistantsTest(null, 'id_desc')) && p('10:name') && e('助手10'); +r($aiTest->getAssistantsTest(null, 'id_desc')) && p('9:name') && e('助手9'); +r($aiTest->getAssistantsTest(null, 'name_asc')) && p('1:name') && e('助手1'); +r($aiTest->getAssistantsTest()) && p('10:id') && e('10'); \ No newline at end of file