znt/module/gitlab/test/model/apigetsingleuser.php

42 lines
1.3 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 gitlabModel::apiGetSingleUser();
timeout=0
cid=16622
- 步骤1正常查询无真实API连接 @0
- 步骤2无效gitlabID查询 @0
- 步骤3不存在userID @0
- 步骤4边界值userID为0 @0
- 步骤5负数userID @0
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备
$table = zenData('pipeline');
$table->type->range('gitlab');
$table->name->range('GitLab测试实例');
$table->url->range('https://gitlab.example.com/api/v4%s?private_token=glpat-test');
$table->account->range('testuser');
$table->password->range('testtoken123');
$table->gen(5);
// 3. 用户登录
su('admin');
// 4. 创建测试实例
$gitlab = new gitlabModelTest();
// 5. 测试步骤至少5个
r($gitlab->apiGetSingleUserTest(1, 1)) && p() && e('0'); // 步骤1正常查询无真实API连接
r($gitlab->apiGetSingleUserTest(0, 2)) && p() && e('0'); // 步骤2无效gitlabID查询
r($gitlab->apiGetSingleUserTest(1, 100001)) && p() && e('0'); // 步骤3不存在userID
r($gitlab->apiGetSingleUserTest(1, 0)) && p() && e('0'); // 步骤4边界值userID为0
r($gitlab->apiGetSingleUserTest(1, -1)) && p() && e('0'); // 步骤5负数userID