* [misc] Enhance unit tests for repoTao::parseBugComment() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1455,13 +1455,25 @@ class repoTest
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test parseBugComment method.
|
||||
*
|
||||
* @param string $comment
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function parseBugCommentTest(string $comment)
|
||||
{
|
||||
$rules = $this->objectModel->processRules();
|
||||
$actions = array();
|
||||
ob_start();
|
||||
$result = $this->objectModel->parseBugComment($comment, $rules, $actions);
|
||||
ob_end_clean();
|
||||
|
||||
// 使用反射调用protected方法
|
||||
$reflection = new ReflectionClass($this->objectTao);
|
||||
$method = $reflection->getMethod('parseBugComment');
|
||||
$method->setAccessible(true);
|
||||
$result = $method->invokeArgs($this->objectTao, array($comment, $rules, &$actions));
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,50 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/repo.unittest.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 repoModel->parseBugComment();
|
||||
title=测试 repoTao::parseBugComment();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 解析修复bug属性3 @3
|
||||
- 解析修复多个bug
|
||||
- 步骤1:正常单个bug修复属性3 @3
|
||||
- 步骤2:正常多个bug修复
|
||||
- 属性3 @3
|
||||
- 属性5 @5
|
||||
- 属性12 @12
|
||||
- 步骤3:空字符串输入 @0
|
||||
- 步骤4:无效格式注释 @0
|
||||
- 步骤5:非数字ID注释 @0
|
||||
- 步骤6:复杂格式注释
|
||||
- 属性1 @1
|
||||
- 属性2 @2
|
||||
- 属性5 @5
|
||||
- 属性8 @8
|
||||
- 属性10 @10
|
||||
- 步骤7:大小写不敏感属性7 @7
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/repo.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$repo = new repoTest();
|
||||
|
||||
$fixBugComment = 'Fix bug#3';
|
||||
$fixBugComment2 = 'Fix bug#3,5,12';
|
||||
// 测试数据准备
|
||||
$normalSingleComment = 'Fix bug#3';
|
||||
$normalMultipleComment = 'Fix bug#3,5,12';
|
||||
$emptyComment = '';
|
||||
$invalidFormatComment = 'Fixed some issues';
|
||||
$nonNumericComment = 'Fix bug#abc';
|
||||
$complexFormatComment = 'Fix bug#1,2 Fix bug#5,8,10';
|
||||
$caseInsensitiveComment = 'fix BUG#7';
|
||||
|
||||
r($repo->parseBugCommentTest($fixBugComment)) && p('3') && e('3'); //解析修复bug
|
||||
r($repo->parseBugCommentTest($fixBugComment2)) && p('3,5,12') && e('3,5,12'); //解析修复多个bug
|
||||
r($repo->parseBugCommentTest($normalSingleComment)) && p('3') && e('3'); // 步骤1:正常单个bug修复
|
||||
r($repo->parseBugCommentTest($normalMultipleComment)) && p('3,5,12') && e('3,5,12'); // 步骤2:正常多个bug修复
|
||||
r($repo->parseBugCommentTest($emptyComment)) && p() && e('0'); // 步骤3:空字符串输入
|
||||
r($repo->parseBugCommentTest($invalidFormatComment)) && p() && e('0'); // 步骤4:无效格式注释
|
||||
r($repo->parseBugCommentTest($nonNumericComment)) && p() && e('0'); // 步骤5:非数字ID注释
|
||||
r($repo->parseBugCommentTest($complexFormatComment)) && p('1,2,5,8,10') && e('1,2,5,8,10'); // 步骤6:复杂格式注释
|
||||
r($repo->parseBugCommentTest($caseInsensitiveComment)) && p('7') && e('7'); // 步骤7:大小写不敏感
|
||||
Reference in New Issue
Block a user