+ [misc] Add unit tests for searchZen::getTypeList() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-11-12 08:31:13 +08:00
co-authored by Claude
parent ee8a293dcc
commit bc92e94f06
3 changed files with 123 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
declare(strict_types = 1);
require_once dirname(__FILE__, 5) . '/test/lib/test.class.php';
class searchZenTest extends baseTest
{
protected $moduleName = 'search';
protected $className = 'zen';
/**
* Test getTypeList method.
*
* @access public
* @return mixed
*/
public function getTypeListTest()
{
$result = $this->invokeArgs('getTypeList');
if(dao::isError()) return dao::getError();
return $result;
}
}
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php
/**
title=测试 searchZen::getTypeList();
timeout=0
cid=0
- 执行$result1['all'] @1
- 执行$result2 @1
- 执行$result3属性all @全部
- 执行$result4) > 0 @1
- 执行$result5)[0] @all
- 执行$result6属性all @全部
- 执行$result7) && isset($result7['all'] @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
zenData('searchindex')->loadYaml('searchindex', false, 2)->gen(50);
su('admin');
$searchTest = new searchZenTest();
$result1 = $searchTest->getTypeListTest();
$result2 = $searchTest->getTypeListTest();
$result3 = $searchTest->getTypeListTest();
$result4 = $searchTest->getTypeListTest();
$result5 = $searchTest->getTypeListTest();
$result6 = $searchTest->getTypeListTest();
$result7 = $searchTest->getTypeListTest();
r(isset($result1['all'])) && p() && e('1');
r(is_array($result2)) && p() && e('1');
r($result3) && p('all') && e('全部');
r(count($result4) > 0) && p() && e('1');
r(array_keys($result5)[0]) && p() && e('all');
r($result6) && p('all') && e('全部');
r(is_array($result7) && isset($result7['all'])) && p() && e('1');
@@ -0,0 +1,57 @@
title: table zt_searchindex
desc: "搜索索引测试数据"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-50
prefix: ""
postfix: ""
loop: 0
format: ""
- field: objectType
note: "对象类型"
range: task,bug,case,doc,todo,build,product,story
prefix: ""
postfix: ""
loop: 0
format: ""
- field: objectID
note: "对象ID"
range: 1-50
prefix: ""
postfix: ""
loop: 0
format: ""
- field: title
note: "对象标题"
range: 1-50
prefix: "测试标题"
postfix: ""
loop: 0
format: ""
- field: content
note: "对象内容"
range: 1-50
prefix: "测试内容"
postfix: ""
loop: 0
format: ""
- field: addedDate
note: "添加日期"
range: "(-1M)-(+1w):-1D"
type: timestamp
format: "YYYY-MM-DD hh:mm:ss"
- field: editedDate
note: "编辑日期"
range: "(-1M)-(+1w):-1D"
type: timestamp
format: "YYYY-MM-DD hh:mm:ss"
- field: vision
note: "界面类型"
range: rnd
prefix: ""
postfix: ""
loop: 0
format: ""