From 53ee30206b27e9b2a9dbf247c0688a63018edb83 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 7 Nov 2025 11:45:29 +0800 Subject: [PATCH] + [misc] Add unit tests for searchTao::processExecutionRecord() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../test/tao/processexecutionrecord.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 module/search/test/tao/processexecutionrecord.php diff --git a/module/search/test/tao/processexecutionrecord.php b/module/search/test/tao/processexecutionrecord.php new file mode 100644 index 0000000000..b008f19a23 --- /dev/null +++ b/module/search/test/tao/processexecutionrecord.php @@ -0,0 +1,56 @@ +#!/usr/bin/env php +> 验证URL包含execution-view且extraType为空 +- 测试看板执行类型(kanban),应生成kanban链接 >> 验证URL包含execution-kanban且extraType为kanban +- 测试迭代执行类型(stage),应生成view链接 >> 验证URL包含execution-view且extraType为stage +- 测试空类型执行,应生成view链接 >> 验证URL包含execution-view且extraType为空 +- 测试另一个普通执行,验证ID和URL正确生成 >> 验证URL包含execution-view且record ID正确 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/tao.class.php'; + +$project = zenData('project'); +$project->id->range('1-10'); +$project->name->range('项目1,项目2,项目3,项目4,项目5,项目6,项目7,项目8,项目9,项目10'); +$project->type->range('sprint,kanban,stage,sprint,sprint,kanban,sprint,stage,sprint,sprint'); +$project->status->range('doing'); +$project->deleted->range('0'); +$project->gen(10); + +su('admin'); + +$searchTest = new searchTaoTest(); + +$record1 = (object)array('id' => 1, 'objectID' => 1, 'objectType' => 'execution', 'title' => 'Execution 1', 'url' => '', 'extraType' => ''); +$objectList1 = array('execution' => array(1 => (object)array('id' => 1, 'type' => 'sprint', 'project' => 1))); +$result1 = $searchTest->processExecutionRecordTest($record1, $objectList1); +r(strpos($result1->url, 'execution-view') !== false && $result1->extraType == '') && p() && e('1'); + +$record2 = (object)array('id' => 2, 'objectID' => 2, 'objectType' => 'execution', 'title' => 'Execution 2', 'url' => '', 'extraType' => ''); +$objectList2 = array('execution' => array(2 => (object)array('id' => 2, 'type' => 'kanban', 'project' => 2))); +$result2 = $searchTest->processExecutionRecordTest($record2, $objectList2); +r(strpos($result2->url, 'execution-kanban') !== false && $result2->extraType == 'kanban') && p() && e('1'); + +$record3 = (object)array('id' => 3, 'objectID' => 3, 'objectType' => 'execution', 'title' => 'Execution 3', 'url' => '', 'extraType' => ''); +$objectList3 = array('execution' => array(3 => (object)array('id' => 3, 'type' => 'stage', 'project' => 3))); +$result3 = $searchTest->processExecutionRecordTest($record3, $objectList3); +r(strpos($result3->url, 'execution-view') !== false && $result3->extraType == 'stage') && p() && e('1'); + +$record4 = (object)array('id' => 4, 'objectID' => 4, 'objectType' => 'execution', 'title' => 'Execution 4', 'url' => '', 'extraType' => ''); +$objectList4 = array('execution' => array(4 => (object)array('id' => 4, 'type' => '', 'project' => 4))); +$result4 = $searchTest->processExecutionRecordTest($record4, $objectList4); +r(strpos($result4->url, 'execution-view') !== false && $result4->extraType == '') && p() && e('1'); + +$record5 = (object)array('id' => 5, 'objectID' => 5, 'objectType' => 'execution', 'title' => 'Execution 5', 'url' => '', 'extraType' => ''); +$objectList5 = array('execution' => array(5 => (object)array('id' => 5, 'type' => 'sprint', 'project' => 5))); +$result5 = $searchTest->processExecutionRecordTest($record5, $objectList5); +r(strpos($result5->url, 'execution-view') !== false && $result5->id == 5) && p() && e('1');