* Test saveIndex.
This commit is contained in:
@@ -7,15 +7,19 @@ su('admin');
|
||||
/**
|
||||
|
||||
title=测试 searchModel->saveIndex();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
创建ID为10的bug的索引 >> 1
|
||||
创建ID为10的任务的索引 >> 1
|
||||
- 创建ID为10的bug的索引
|
||||
- 属性objecttype @bug
|
||||
- 属性objectid @10
|
||||
- 创建ID为10的任务的索引
|
||||
- 属性objecttype @task
|
||||
- 属性objectid @10
|
||||
|
||||
*/
|
||||
|
||||
$search = new searchTest();
|
||||
|
||||
r($search->saveIndexTest('bug', 10)) && p() && e('1'); //创建ID为10的bug的索引
|
||||
r($search->saveIndexTest('task', 10)) && p() && e('1'); //创建ID为10的任务的索引
|
||||
r($search->saveIndexTest('bug', 10)) && p('objecttype,objectid') && e('bug,10'); //创建ID为10的bug的索引
|
||||
r($search->saveIndexTest('task', 10)) && p('objecttype,objectid') && e('task,10'); //创建ID为10的任务的索引
|
||||
@@ -272,14 +272,15 @@ class searchTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试保存搜索索引。
|
||||
* Test save index.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return bool
|
||||
* @return array|object
|
||||
*/
|
||||
public function saveIndexTest($objectType, $objectID)
|
||||
public function saveIndexTest(string $objectType, int $objectID): array|object
|
||||
{
|
||||
global $tester;
|
||||
$tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec();
|
||||
@@ -289,15 +290,10 @@ class searchTest
|
||||
$object = $tester->dao->select('*')->from($table)->where('id')->eq($objectID)->fetch();
|
||||
$object->comment = '';
|
||||
|
||||
$objects = $this->objectModel->saveIndex($objectType, $object);
|
||||
$this->objectModel->saveIndex($objectType, $object);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$insertedIndex = $tester->dao->select('*')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->fetch();
|
||||
|
||||
$tester->dao->delete()->from(TABLE_SEARCHINDEX)->exec();
|
||||
$tester->dao->delete()->from(TABLE_SEARCHDICT)->exec();
|
||||
|
||||
if($insertedIndex) return true;
|
||||
return $tester->dao->select('*')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user