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

41 lines
1.5 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::apiGetMergeRequests();
timeout=0
cid=16609
- 步骤1使用有效的GitLab ID和项目ID获取合并请求 @~~
- 步骤2验证返回结果是数组类型 @1
- 步骤3使用无效的GitLab ID测试错误处理 @~~
- 步骤4使用无效的项目ID测试边界处理 @~~
- 步骤5使用边界值项目ID为0测试参数验证 @~~
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 准备测试数据
$pipeline = zenData('pipeline');
$pipeline->id->range('1-5');
$pipeline->name->range('gitlab1,gitlab2,gitlab3,gitlab4,gitlab5');
$pipeline->type->range('gitlab{5}');
$pipeline->url->range('https://gitlab{1-5}.example.com');
$pipeline->token->range('glpat-test{1-5}');
$pipeline->gen(5);
// 用户登录
su('admin');
// 创建测试实例
$gitlabTest = new gitlabModelTest();
r($gitlabTest->apiGetMergeRequestsTest(1, 18)) && p() && e('~~'); // 步骤1使用有效的GitLab ID和项目ID获取合并请求
$result = $gitlabTest->apiGetMergeRequestsTest(1, 18);
r(is_array($result)) && p() && e('1'); // 步骤2验证返回结果是数组类型
r($gitlabTest->apiGetMergeRequestsTest(999, 18)) && p() && e('~~'); // 步骤3使用无效的GitLab ID测试错误处理
r($gitlabTest->apiGetMergeRequestsTest(1, 999999)) && p() && e('~~'); // 步骤4使用无效的项目ID测试边界处理
r($gitlabTest->apiGetMergeRequestsTest(1, 0)) && p() && e('~~'); // 步骤5使用边界值项目ID为0测试参数验证