* userTest: refactor script to test the getListForGitLabAPI method.

This commit is contained in:
liugang
2023-12-16 09:50:26 +08:00
parent 432c973225
commit d6624b0192
2 changed files with 27 additions and 21 deletions
+23 -17
View File
@@ -1,24 +1,30 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/user.class.php';
zdTable('user')->gen(500);
su('admin');
/**
title=测试 userModel::getUserDetailsForAPI();
title=测试 userModel->getListForGitLabAPI();
cid=1
pid=1
获取admin用户的url >> getuserdetailsforapi
获取test2用户的真实姓名 >> 测试2
获取user10的头像信息 >> http:///home/z/tmp/10.png
*/
$user = new userTest();
$userList = array('admin', 'test2', 'user10', '');
$users = $user->getUserDetailsForAPITest($userList);
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/user.class.php';
r($users) && p('test2:realname') && e('测试2'); //获取test2用户的真实姓名
r($users) && p('user10:avatar') && e('https://www.gravatar.com/avatar/990d67a9f94696b1abe2dccf06900322?d=identicon&s=80'); //获取user10的头像信息
$user = zdTable('user');
$user->account->range('1-2')->prefix('user');
$user->avatar->range('`avatar`,``');
$user->gen(2);
$userTest = new userTest();
$accounts = array('user1', 'user2');
$users = $userTest->getListForGitLabAPITest(array());
r(count($users)) && p() && e(0); // 传入参数为空数组,返回空数组。
$users = $userTest->getListForGitLabAPITest(array('admin'));
r(count($users)) && p() && e(0); // 传入参数为非空数组,其中包含的账号在数据库中不存在,返回空数组。
$users = $userTest->getListForGitLabAPITest($accounts);
r(count($users)) && p() && e(2); // 传入参数为非空数组,包含 2 个账号,返回数组包含 2 个用户。
$user1 = $userTest->getByIdTest('user1');
r($users[0]->avatar == $tester->getSysURL() . $user1->avatar) && p() && e(1); // 传入参数为非空数组,包含 2 个账号,返回数组包含 2 个用户,其中第 1 个用户有头像。
r($users[1]->avatar == "https://www.gravatar.com/avatar/" . md5('user2') . "?d=identicon&s=80") && p() && e(1); // 传入参数为非空数组,包含 2 个账号,返回数组包含 2 个用户,其中第 2 个用户无头像。