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

43 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::apiGetNamespaces();
timeout=0
cid=16610
- 步骤1有效GitLab ID获取namespace列表 @~~
- 步骤2有效GitLab ID检查返回数据类型 @1
- 步骤3无效GitLab ID0获取namespace @~~
- 步骤4不存在的GitLab ID获取namespace @~~
- 步骤5负数GitLab ID获取namespace @~~
*/
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://gitlabdev.qc.oop.cc{5}');
$pipeline->token->range('glpat-b8Sa1pM9k9ygxMZYPN6w{5}');
$pipeline->gen(5);
zenData('oauth')->gen(4);
// 用户登录
su('admin');
// 创建测试实例
$gitlabTest = new gitlabModelTest();
r($gitlabTest->apiGetNamespacesTest(1)) && p() && e('~~'); // 步骤1有效GitLab ID获取namespace列表
$result = $gitlabTest->apiGetNamespacesTest(1);
r(is_array($result)) && p() && e('1'); // 步骤2有效GitLab ID检查返回数据类型
r($gitlabTest->apiGetNamespacesTest(0)) && p() && e('~~'); // 步骤3无效GitLab ID0获取namespace
r($gitlabTest->apiGetNamespacesTest(999)) && p() && e('~~'); // 步骤4不存在的GitLab ID获取namespace
r($gitlabTest->apiGetNamespacesTest(-1)) && p() && e('~~'); // 步骤5负数GitLab ID获取namespace