diff --git a/test/class/user.class.php b/test/class/user.class.php index 87fdce99ce..eb3de2d874 100644 --- a/test/class/user.class.php +++ b/test/class/user.class.php @@ -179,4 +179,26 @@ class userTest return $objects; } } + + /** + * Test get user by id. + * + * @param int|string $userID + * @param string $field + * @access public + * @return void + */ + public function getByIdTest($userID, $field = 'account') + { + $objects = $this->objectModel->getById($userID, $field); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } } diff --git a/test/model/user/getbyid.php b/test/model/user/getbyid.php index 864f536a35..ffd1c89fe6 100755 --- a/test/model/user/getbyid.php +++ b/test/model/user/getbyid.php @@ -22,4 +22,4 @@ r($user->getByID('admin', 'account')) && p('account') && e('admin'); // 使 r($user->getByID('admin')) && p('account') && e('admin'); // 通过默认字段获取存在的用户 r($user->getByID(1)) && p('account') && e(''); // 通过默认字段获取不存在的用户 r($user->getByID(100000, 'id')) && p('account') && e(''); // 通过id字段获取不存在的用户 -r($user->getByID('error', 'account')) && p('account') && e(''); // 通过默认字段获取不存在的用户 \ No newline at end of file +r($user->getByID('error', 'account')) && p('account') && e(''); // 通过默认字段获取不存在的用户 diff --git a/test/model/user/getuserdisplayinfos.php b/test/model/user/getuserdisplayinfos.php index 45d14e8325..69b9816426 100644 --- a/test/model/user/getuserdisplayinfos.php +++ b/test/model/user/getuserdisplayinfos.php @@ -22,10 +22,10 @@ pid=1 */ -$accounts = array('!asd12d', '中文用户名', 'user10', 'dev33', 'cccfff'); +$accounts = array('!asd12d', '中文用户名', 'user10', 'dev33', 'cccfff', 'outside1'); $user = new userTest(); -r($user->getUserRolesTest($accounts, true)) && p('dev33') && e('dev'); //获取用户名和职位Key的键值对 -r($user->getUserRolesTest($accounts, false)) && p('dev33') && e('研发'); //获取用户名和职位Value的键值对 -r(count($user->getUserRolesTest($accounts, true))) && p() && e(2); //从指定accounts中获取到的键值对数量 -r(count($user->getUserRolesTest($accounts, false))) && p() && e(2); //从指定accounts中获取到的键值对数量 +r($user->getUserDisplayInfosTest($accounts)) && p('dev33:realname') && e('项目经理33'); //查找获取到的用户名为dev33的真实姓名 +r($user->getUserDisplayInfosTest($accounts)) && p('user10:avatar') && e('/home/z/tmp/10.png'); //查找获取到的用户名为user10的头像 +r($user->getUserDisplayInfosTest($accounts, 0, 'outside')) && p('outside1:avatar') && e('/home/z/tmp/18.png'); //查找获取到的用户名为outside1的外部用户的头像信息 +r($user->getUserDisplayInfosTest($accounts)) && p('cccfff:realname') && e('Error: Cannot get index cccfff.'); //查找获取到的用户名为cccfff的真实姓名