* Refactor reportModel::getUserBugs, and modify its unit test.

This commit is contained in:
liumengyi
2023-11-30 11:05:49 +08:00
parent d5d121dce0
commit 6524ab068c
4 changed files with 20 additions and 8 deletions
+3 -2
View File
@@ -133,12 +133,13 @@ class reportModel extends model
}
/**
* 获取用户的 bugs。
* Get user bugs.
*
* @access public
* @return void
* @return array
*/
public function getUserBugs()
public function getUserBugs(): array
{
return $this->dao->select('t1.id, t1.title, t2.account as user, t1.deadline')
->from(TABLE_BUG)->alias('t1')
+6 -3
View File
@@ -1,7 +1,12 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/report.class.php';
zdTable('bug')->config('bug')->gen('100');
zdTable('user')->gen(10);
su('admin');
/**
@@ -10,10 +15,8 @@ title=测试 reportModel->getUserBugs();
cid=1
pid=1
获取人员bug数 >> admin:79;dev1:52;test1:77
*/
$report = new reportTest();
r($report->getUserBugsTest()) && p() && e('admin:79;dev1:52;test1:77'); // 获取人员bug数
r($report->getUserBugsTest()) && p() && e('admin:29;user1:27;user2:28;'); // 获取人员 bug 数
+4 -3
View File
@@ -224,19 +224,20 @@ class reportTest
}
/**
* 测试获取用户的 bugs。
* Test get user bugs.
*
* @access public
* @return string
* @return string|array
*/
public function getUserBugsTest()
public function getUserBugsTest(): string|array
{
$objects = $this->objectModel->getUserBugs();
if(dao::isError()) return dao::getError();
$counts = '';
foreach($objects as $user => $bugs) $counts .= "$user:" . count($bugs) . ';';
foreach($objects as $user => $bugs) $counts .= "{$user}:" . count($bugs) . ';';
return $counts;
}
+7
View File
@@ -0,0 +1,7 @@
title: bug.
desc: bug data.
author: Mengyi Liu
version: "1.0"
fields:
- field: assignedTo
range: admin,user1,user2