diff --git a/module/bug/model.php b/module/bug/model.php
index a5e98e5f81..23b0ddf5a3 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -1909,12 +1909,16 @@ class bugModel extends model
*/
public function summary(array $bugs): string
{
+ /* 获取为解决的bug数量。 */
+ /* Get unresolved bug count. */
$unresolved = 0;
foreach($bugs as $bug)
{
if($bug->status != 'resolved' && $bug->status != 'closed') $unresolved ++;
}
+ /* 返回bug的统计信息。 */
+ /* Return the statistics of the bugs. */
return sprintf($this->lang->bug->notice->summary, count($bugs), $unresolved);
}
diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php
index bb5d247553..6b887fb48a 100644
--- a/module/bug/test/bug.class.php
+++ b/module/bug/test/bug.class.php
@@ -1359,4 +1359,20 @@ class bugTest
return $idList;
}
}
+
+ /**
+ * 测试获取 bugs 统计信息。
+ * Test get the statistics of the bugs.
+ *
+ * @param string $bugIdList
+ * @access public
+ * @return string
+ */
+ public function summaryTest(string $bugIdList): string
+ {
+ $bugs = $this->objectModel->getByIdList($bugIdList);
+ if(empty($bugs)) $bugs = array();
+ $summary = $this->objectModel->summary($bugs);
+ return $summary;
+ }
}
diff --git a/module/bug/test/model/summary.php b/module/bug/test/model/summary.php
new file mode 100644
index 0000000000..c7a33cce8b
--- /dev/null
+++ b/module/bug/test/model/summary.php
@@ -0,0 +1,33 @@
+#!/usr/bin/env php
+gen(20);
+
+/**
+
+title=bugModel->summary();
+timeout=0
+cid=1
+
+- 测试获取bugID 1,2,3,4,5 的统计信息 @本页共 5 个Bug,未解决 5。
+
+- 测试获取bugID 6,7,8,9,10 的统计信息 @本页共 5 个Bug,未解决 5。
+
+- 测试获取bugID 11,12,13,14,15 的统计信息 @本页共 5 个Bug,未解决 5。
+
+- 测试获取bugID 空 的统计信息 @本页共 20 个Bug,未解决 20。
+
+- 测试获取bugID 不存在 的统计信息 @本页共 0 个Bug,未解决 0。
+
+*/
+
+$bugIdList = array('1,2,3,4,5', '6,7,8,9,10', '11,12,13,14,15', '', '1000001');
+
+$bug=new bugTest();
+r($bug->summaryTest($bugIdList[0])) && p() && e('本页共 5 个Bug,未解决 5。'); // 测试获取bugID 1,2,3,4,5 的统计信息
+r($bug->summaryTest($bugIdList[1])) && p() && e('本页共 5 个Bug,未解决 5。'); // 测试获取bugID 6,7,8,9,10 的统计信息
+r($bug->summaryTest($bugIdList[2])) && p() && e('本页共 5 个Bug,未解决 5。'); // 测试获取bugID 11,12,13,14,15 的统计信息
+r($bug->summaryTest($bugIdList[3])) && p() && e('本页共 20 个Bug,未解决 20。'); // 测试获取bugID 空 的统计信息
+r($bug->summaryTest($bugIdList[4])) && p() && e('本页共 0 个Bug,未解决 0。'); // 测试获取bugID 不存在 的统计信息