From 4b17d8a8a42c0e2291c13cad1468862cf3a49b3d Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Wed, 12 Jan 2022 07:25:41 +0800 Subject: [PATCH] + Add su function. --- test/lib/init.php | 15 +++++++++++++++ test/model/user/getbyid.php | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/lib/init.php b/test/lib/init.php index 70104b252a..79a4ba205d 100644 --- a/test/lib/init.php +++ b/test/lib/init.php @@ -175,3 +175,18 @@ function zdImport($table, $yaml, $count = 10) $command = "$config->zdPath -c $yaml -t $table -T -dns $dns --clear -n $count"; system($command); } + +/** + * Switch user. + * + * @param string $account + * @access public + * @return bool + */ +function su($account) +{ + $userModel = new userModel(); + $user = $userModel->identify($account, '123qwe!@#'); + if($user) return $userModel->login($user); + return false; +} diff --git a/test/model/user/getbyid.php b/test/model/user/getbyid.php index 5cfa37d902..7d17b2e96c 100755 --- a/test/model/user/getbyid.php +++ b/test/model/user/getbyid.php @@ -2,6 +2,8 @@ getByID('account1')) && p('account') && e('account1'); // 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 + */