diff --git a/module/search/test/lib/search.unittest.class.php b/module/search/test/lib/search.unittest.class.php index 2bdf0943e8..d529d43e4b 100755 --- a/module/search/test/lib/search.unittest.class.php +++ b/module/search/test/lib/search.unittest.class.php @@ -1120,4 +1120,46 @@ class searchTest return dao::isError() ? -1 : count($result); } + + /** + * Test markKeywords method directly. + * + * @param string $content + * @param string $keywords + * @access public + * @return string + */ + public function markKeywordsDirectTest(string $content, string $keywords): string + { + // 使用反射访问私有方法 + $reflection = new ReflectionClass($this->objectTao); + $method = $reflection->getMethod('markKeywords'); + $method->setAccessible(true); + + $result = $method->invokeArgs($this->objectTao, array($content, $keywords)); + if(dao::isError()) return dao::getError(); + + return $result; + } + + /** + * Test processRecord method. + * + * @param object $record + * @param array $objectList + * @access public + * @return object + */ + public function processRecordTest(object $record, array $objectList): object + { + // 使用反射访问私有方法 + $reflection = new ReflectionClass($this->objectTao); + $method = $reflection->getMethod('processRecord'); + $method->setAccessible(true); + + $result = $method->invokeArgs($this->objectTao, array($record, $objectList)); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/search/test/tao/markkeywords.php b/module/search/test/tao/markkeywords.php new file mode 100755 index 0000000000..f2f2124acc --- /dev/null +++ b/module/search/test/tao/markkeywords.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +test content +- 执行searchTest模块的markKeywordsDirectTest方法,参数是'This contains key1 and key2 words', 'key1 key2' @This contains key1 and key2 words +- 执行searchTest模块的markKeywordsDirectTest方法,参数是'这是一个测试内容', '测试' @这是一个测试 内容 +- 执行searchTest模块的markKeywordsDirectTest方法,参数是'Product version 12345 released', '12345' @Product version 12345 released +- 执行searchTest模块的markKeywordsDirectTest方法,参数是'No keywords here', '' @No keywords here + +*/ + +$searchTest = new searchTest(); + +r($searchTest->markKeywordsDirectTest('This is a test content', 'test')) && p() && e("This is a test content "); +r($searchTest->markKeywordsDirectTest('This contains key1 and key2 words', 'key1 key2')) && p() && e("This contains key1 and key2 words "); +r($searchTest->markKeywordsDirectTest('这是一个测试内容', '测试')) && p() && e("这是一个测试 内容 "); +r($searchTest->markKeywordsDirectTest('Product version 12345 released', '12345')) && p() && e("Product version 12345 released "); +r($searchTest->markKeywordsDirectTest('No keywords here', '')) && p() && e('No keywords here'); \ No newline at end of file diff --git a/module/search/test/tao/processrecord.php b/module/search/test/tao/processrecord.php new file mode 100755 index 0000000000..b7c107ef10 --- /dev/null +++ b/module/search/test/tao/processrecord.php @@ -0,0 +1,57 @@ +#!/usr/bin/env php +id->range('1-10'); +$taskTable->project->range('1-3'); +$taskTable->name->range('任务{1-10}'); +$taskTable->status->range('wait{3},doing{4},done{3}'); +$taskTable->gen(10); + +$projectTable = zenData('project'); +$projectTable->id->range('1-10'); +$projectTable->name->range('项目{1-10}'); +$projectTable->model->range('waterfall{3},scrum{3},kanban{2}'); +$projectTable->multiple->range('1{8},0{2}'); +$projectTable->gen(10); + +// 3. 用户登录(选择合适角色) +su('admin'); + +// 4. 创建测试实例(变量名与模块名一致) +$searchTest = new searchTest(); + +// 5. 强制要求:必须包含至少5个测试步骤 +$taskResult = $searchTest->processRecordTest((object)array('objectType' => 'task', 'objectID' => 1), array()); +r(strpos($taskResult->url, 'm=task') !== false) && p() && e('1'); // 步骤1:测试任务记录URL包含task模块 + +$projectResult = $searchTest->processRecordTest((object)array('objectType' => 'project', 'objectID' => 3), array('project' => array(3 => (object)array('model' => 'kanban')))); +r(strpos($projectResult->url, 'f=index') !== false) && p() && e('1'); // 步骤2:测试kanban项目URL包含index方法 + +$executionResult = $searchTest->processRecordTest((object)array('objectType' => 'execution', 'objectID' => 2), array('execution' => array(2 => (object)array('type' => 'sprint', 'project' => 1)))); +r($executionResult->extraType) && p() && e('sprint'); // 步骤3:测试执行记录的额外类型 + +$storyResult = $searchTest->processRecordTest((object)array('objectType' => 'story', 'objectID' => 1), array('story' => array(1 => (object)array('type' => 'story', 'lib' => 0)))); +r(strpos($storyResult->url, 'f=storyView') !== false) && p() && e('1'); // 步骤4:测试需求记录URL包含storyView方法 + +$docResult = $searchTest->processRecordTest((object)array('objectType' => 'doc', 'objectID' => 7), array('doc' => array(7 => (object)array('assetLib' => 0)))); +r(strpos($docResult->url, 'm=doc') !== false) && p() && e('1'); // 步骤5:测试文档记录URL包含doc模块 \ No newline at end of file