diff --git a/module/user/test/tao/fetchexecutiontaskcount.php b/module/user/test/tao/fetchexecutiontaskcount.php new file mode 100644 index 0000000000..a6460c0033 --- /dev/null +++ b/module/user/test/tao/fetchexecutiontaskcount.php @@ -0,0 +1,48 @@ +#!/usr/bin/env php +fetchExecutionTaskCount(); +cid=1 +pid=1 +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/user.class.php'; + +$table = zdTable('task'); +$table->execution->range('1-5{10}'); +$table->parent->range('1,0{6}'); +$table->assignedTo->range('user1{2},user2{4},user3'); +$table->deleted->range('0{7},1'); +$table->gen(50); + +global $config; + +$userTest = new userTest(); + +$executionIdList = array(1, 2, 3, 4, 5); + +r($userTest->fetchExecutionTaskCountTest('user1', array())) && p() && e(0); // 传入空数组,返回空数组。 +r($userTest->fetchExecutionTaskCountTest('admin', $executionIdList)) && p() && e(0); // 用户 admin 没有参与执行,返回空数组。 + +$tasks = $userTest->fetchExecutionTaskCountTest('user1', $executionIdList); +r(count($tasks)) && p() && e(4); // 用户 user1 参与了 4 个执行。 +r($tasks) && p(1) && e(2); // 执行 1 中指派给 user1 的任务数为 2。 +r($tasks) && p(3) && e(2); // 执行 3 中指派给 user1 的任务数为 2。 +r($tasks) && p(4) && e(1); // 执行 4 中指派给 user1 的任务数为 1。 +r($tasks) && p(5) && e(1); // 执行 5 中指派给 user1 的任务数为 1。 + +$tasks = $userTest->fetchExecutionTaskCountTest('user2', $executionIdList); +r(count($tasks)) && p() && e(5); // 用户 user2 参与了 5 个执行。 +r($tasks) && p(1) && e(5); // 执行 1 中指派给 user2 的任务数为 5。 +r($tasks) && p(2) && e(7); // 执行 2 中指派给 user2 的任务数为 7。 +r($tasks) && p(3) && e(3); // 执行 3 中指派给 user2 的任务数为 3。 +r($tasks) && p(4) && e(5); // 执行 4 中指派给 user2 的任务数为 5。 +r($tasks) && p(5) && e(4); // 执行 5 中指派给 user2 的任务数为 4。 + +$tasks = $userTest->fetchExecutionTaskCountTest('user3', $executionIdList); +r(count($tasks)) && p() && e(5); // 用户 user3 参与了 5 个执行。 +r($tasks) && p(1) && e(1); // 执行 1 中指派给 user3 的任务数为 1。 +r($tasks) && p(2) && e(1); // 执行 2 中指派给 user3 的任务数为 1。 +r($tasks) && p(3) && e(2); // 执行 3 中指派给 user3 的任务数为 2。 +r($tasks) && p(4) && e(1); // 执行 4 中指派给 user3 的任务数为 1。 +r($tasks) && p(5) && e(2); // 执行 5 中指派给 user3 的任务数为 2。 diff --git a/module/user/test/user.class.php b/module/user/test/user.class.php index cb98c7829b..ae3099b68f 100755 --- a/module/user/test/user.class.php +++ b/module/user/test/user.class.php @@ -129,6 +129,20 @@ class userTest return $this->objectTao->fetchExecutions($account, $status, $orderBy, $pager); } + /** + * 测试获取某个用户参与的执行和执行中指派给他的任务数的键值对。 + * Get the executions that the user joined and the task count of the execution. + * + * @param string $account + * @param array $executionIdList + * @access public + * @return + */ + public function fetchExecutionTaskCountTest(string $account, array $executionIdList): array + { + return $this->objectTao->fetchExecutionTaskCount($account, $executionIdList); + } + /** * 根据用户名获取用户信息。 * Get user information by account.