diff --git a/test/class/user.class.php b/test/class/user.class.php index 42d7d8a553..87fdce99ce 100644 --- a/test/class/user.class.php +++ b/test/class/user.class.php @@ -50,6 +50,16 @@ class userTest } } + /** + * Test user get pairs. + * + * @param string $params + * @param string $usersToAppended + * @param int $maxCount + * @param array $accounts + * @access public + * @return void + */ public function getPairsTest($params = '', $usersToAppended = '', $maxCount = 0, $accounts = array()) { $objects = $this->objectModel->getPairs($params, $usersToAppended, $maxCount, $accounts); @@ -63,4 +73,110 @@ class userTest return $objects; } } + + /** + * Test get avatar pairs. + * + * @access public + * @return void + */ + public function getAvatarPairsTest() + { + $objects = $this->objectModel->getAvatarPairs(); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } + + /** + * Test get user commiters. + * + * @access public + * @return void + */ + public function getCommitersTest() + { + $objects = $this->objectModel->getCommiters(); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } + + /** + * Test get user realname and emails. + * + * @param array $accounts + * @access public + * @return void + */ + public function getRealNameAndEmailsTest($accounts) + { + $objects = $this->objectModel->getRealNameAndEmails($accounts); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } + + /** + * Test get user roles. + * + * @param array $accounts + * @param bool $needRole + * @access public + * @return void + */ + public function getUserRolesTest($accounts, $needRole = false) + { + $objects = $this->objectModel->getUserRoles($accounts, $needRole); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } + + /** + * Test get user display infos. + * + * @param int $accounts + * @param int $deptID + * @param string $type + * @access public + * @return void + */ + public function getUserDisplayInfosTest($accounts, $deptID = 0, $type = 'inside') + { + $objects = $this->objectModel->getUserDisplayInfos($accounts, $deptID, $type); + if(dao::isError()) + { + $error = dao::getError(); + return $error[0]; + } + else + { + return $objects; + } + } } diff --git a/test/data/user.yaml b/test/data/user.yaml index ea3b28fe51..0c5d4ae06a 100644 --- a/test/data/user.yaml +++ b/test/data/user.yaml @@ -50,12 +50,20 @@ fields: note: "昵称" - field: commiter note: "源代码帐号" + fields: + - field: commiter1 + range: admin,user{99},test{100},dev{100},pm{100},po{100},td{100},pd{100},qd{100},top{100},outside{100},others{100},a,bb,ccc,qwuiadsd?!2as@#%$aasd~aj1!@#1 + - field: commiter2 + range: [],1-99,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,[]{4} - field: avatar note: "" - range: 0 + fields: + - field: avatar1 + range: /home/z/tmp/,/home/z/user/ + - field: avatar2 + range: 1-10,10-20 prefix: "" - postfix: "" - loop: 0 + postfix: ".png" format: "" - field: birthday note: "生日" diff --git a/test/model/user/getavatarpairs.php b/test/model/user/getavatarpairs.php new file mode 100644 index 0000000000..2ba8389fa0 --- /dev/null +++ b/test/model/user/getavatarpairs.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +查找带有Closed用户的外部用户键值对 >> Closed +查找带有首字母的外部用户键值对 >> O:用户1 +查找不带首字母的外部用户键值对 >> 用户1 +按照给定的用户名查找用户键值对,返回值中不带有Closed用户 >> 1 +按照给定的用户名查找用户键值对,返回值中带有Closed用户 >> 2 +使用limit参数来限制最多获取2个用户键值对 >> 2 +使用limit参数来限制最多获取50个用户键值对 >> 50 +使用pofirst参数来将系统中的产品经理用户放到返回值前列 >> P:测试主管58 +使用pmfirst参数来将系统中的项目经理用户放到返回值前列 >> O:其他100 + +*/ +$user = new userTest(); + +r(count($user->getAvatarPairsTest())) && p() && e('999'); //所有用户头像的数量 +r($user->getAvatarPairsTest()) && p('user99') && e('/home/z/user/15.png'); //查找account为"user99"的用户的头像路径 diff --git a/test/model/user/getcommiters.php b/test/model/user/getcommiters.php new file mode 100644 index 0000000000..a12a9e426c --- /dev/null +++ b/test/model/user/getcommiters.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +查找带有Closed用户的外部用户键值对 >> Closed +查找带有首字母的外部用户键值对 >> O:用户1 +查找不带首字母的外部用户键值对 >> 用户1 +按照给定的用户名查找用户键值对,返回值中不带有Closed用户 >> 1 +按照给定的用户名查找用户键值对,返回值中带有Closed用户 >> 2 +使用limit参数来限制最多获取2个用户键值对 >> 2 +使用limit参数来限制最多获取50个用户键值对 >> 50 +使用pofirst参数来将系统中的产品经理用户放到返回值前列 >> P:测试主管58 +使用pmfirst参数来将系统中的项目经理用户放到返回值前列 >> O:其他100 + +*/ + +$user = new userTest(); +$commiters = $user->getCommitersTest(); + +r($commiters) && p('qd100') && e('高层管理100'); //获取源代码账号为qd100的用户真实姓名 +r(count($commiters)) && p() && e('1000'); //获取系统中源代码账号不为空的用户数量 diff --git a/test/model/user/getpairs.php b/test/model/user/getpairs.php index 2d6e4fd5f4..b111b224c6 100644 --- a/test/model/user/getpairs.php +++ b/test/model/user/getpairs.php @@ -44,4 +44,4 @@ r(count($usersInAccountsWithclosed)) && p() && e('2'); // r(count($limit2Users)) && p() && e('2'); //使用limit参数来限制最多获取2个用户键值对 r(count($limit50Users)) && p() && e('50'); //使用limit参数来限制最多获取50个用户键值对 r($firstPO) && p('pd58') && e('P:测试主管58'); //使用pofirst参数来将系统中的产品经理用户放到返回值前列 -r($firstPM) && p('outside100') && e('O:其他100'); //使用pmfirst参数来将系统中的项目经理用户放到返回值前列 \ No newline at end of file +r($firstPM) && p('outside100') && e('O:其他100'); //使用pmfirst参数来将系统中的项目经理用户放到返回值前列 diff --git a/test/model/user/getrealnameandemails.php b/test/model/user/getrealnameandemails.php new file mode 100644 index 0000000000..966d8bc0ef --- /dev/null +++ b/test/model/user/getrealnameandemails.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +查找带有Closed用户的外部用户键值对 >> Closed +查找带有首字母的外部用户键值对 >> O:用户1 +查找不带首字母的外部用户键值对 >> 用户1 +按照给定的用户名查找用户键值对,返回值中不带有Closed用户 >> 1 +按照给定的用户名查找用户键值对,返回值中带有Closed用户 >> 2 +使用limit参数来限制最多获取2个用户键值对 >> 2 +使用limit参数来限制最多获取50个用户键值对 >> 50 +使用pofirst参数来将系统中的产品经理用户放到返回值前列 >> P:测试主管58 +使用pmfirst参数来将系统中的项目经理用户放到返回值前列 >> O:其他100 + +*/ + +$accounts = array('tesrasd1asd#@!#$', 'ASD123中文', 'user10', 'ccsdqq@!', 'admin'); +$user = new userTest(); +$emails = $user->getRealNameAndEmailsTest($accounts); + +r($emails['admin']) && p('email') && e('631479@qq.com'); //获取admin的邮箱 +r(count($emails)) && p() && e('2'); //从accounts中获取到的用户邮箱数量 diff --git a/test/model/user/getuserdisplayinfos.php b/test/model/user/getuserdisplayinfos.php new file mode 100644 index 0000000000..45d14e8325 --- /dev/null +++ b/test/model/user/getuserdisplayinfos.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +查找带有Closed用户的外部用户键值对 >> Closed +查找带有首字母的外部用户键值对 >> O:用户1 +查找不带首字母的外部用户键值对 >> 用户1 +按照给定的用户名查找用户键值对,返回值中不带有Closed用户 >> 1 +按照给定的用户名查找用户键值对,返回值中带有Closed用户 >> 2 +使用limit参数来限制最多获取2个用户键值对 >> 2 +使用limit参数来限制最多获取50个用户键值对 >> 50 +使用pofirst参数来将系统中的产品经理用户放到返回值前列 >> P:测试主管58 +使用pmfirst参数来将系统中的项目经理用户放到返回值前列 >> O:其他100 + +*/ + +$accounts = array('!asd12d', '中文用户名', 'user10', 'dev33', 'cccfff'); +$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中获取到的键值对数量 diff --git a/test/model/user/getuserroles.php b/test/model/user/getuserroles.php new file mode 100644 index 0000000000..45d14e8325 --- /dev/null +++ b/test/model/user/getuserroles.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +查找带有Closed用户的外部用户键值对 >> Closed +查找带有首字母的外部用户键值对 >> O:用户1 +查找不带首字母的外部用户键值对 >> 用户1 +按照给定的用户名查找用户键值对,返回值中不带有Closed用户 >> 1 +按照给定的用户名查找用户键值对,返回值中带有Closed用户 >> 2 +使用limit参数来限制最多获取2个用户键值对 >> 2 +使用limit参数来限制最多获取50个用户键值对 >> 50 +使用pofirst参数来将系统中的产品经理用户放到返回值前列 >> P:测试主管58 +使用pmfirst参数来将系统中的项目经理用户放到返回值前列 >> O:其他100 + +*/ + +$accounts = array('!asd12d', '中文用户名', 'user10', 'dev33', 'cccfff'); +$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中获取到的键值对数量