* [misc] Enhance unit tests for gitlabModel::apiGetSingleGroup() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,29 +1,43 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/gitlab.unittest.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->apiGetSingleGroup();
|
||||
title=测试 gitlabModel::apiGetSingleGroup();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 查询正确的group信息属性name @testGroup
|
||||
- 使用不存在的gitlabID查询group信息 @0
|
||||
- 使用不存在的group名称查询group信息属性message @404 Group Not Found
|
||||
- 步骤1:正常情况属性name @testGroup
|
||||
- 步骤2:无效gitlabID @0
|
||||
- 步骤3:无效groupID属性message @404 Group Not Found
|
||||
- 步骤4:边界值gitlabID为0 @0
|
||||
- 步骤5:边界值groupID为负数 @0
|
||||
|
||||
*/
|
||||
|
||||
zenData('pipeline')->gen(5);
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/gitlab.unittest.class.php';
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
// 2. zendata数据准备
|
||||
$table = zenData('pipeline');
|
||||
$table->id->range('1-5');
|
||||
$table->type->range('gitlab');
|
||||
$table->name->range('GitLab服务器');
|
||||
$table->url->range('https://gitlabdev.qc.oop.cc');
|
||||
$table->account->range('root');
|
||||
$table->token->range('glpat-b8Sa1pM9k9ygxMZYPN6w');
|
||||
$table->gen(5);
|
||||
|
||||
$group1 = $gitlab->apiGetSingleGroupTest(1, 14);
|
||||
$group2 = $gitlab->apiGetSingleGroupTest(0, 2);
|
||||
$group3 = $gitlab->apiGetSingleGroupTest(1, 100001);
|
||||
// 3. 用户登录
|
||||
su('admin');
|
||||
|
||||
r($group1) && p('name') && e('testGroup'); // 查询正确的group信息
|
||||
r($group2) && p() && e('0'); // 使用不存在的gitlabID查询group信息
|
||||
r($group3) && p('message') && e('404 Group Not Found'); // 使用不存在的group名称查询group信息
|
||||
// 4. 创建测试实例
|
||||
$gitlabTest = new gitlabTest();
|
||||
|
||||
// 5. 强制要求:必须包含至少5个测试步骤
|
||||
r($gitlabTest->apiGetSingleGroupTest(1, 14)) && p('name') && e('testGroup'); // 步骤1:正常情况
|
||||
r($gitlabTest->apiGetSingleGroupTest(999, 14)) && p() && e('0'); // 步骤2:无效gitlabID
|
||||
r($gitlabTest->apiGetSingleGroupTest(1, 100001)) && p('message') && e('404 Group Not Found'); // 步骤3:无效groupID
|
||||
r($gitlabTest->apiGetSingleGroupTest(0, 14)) && p() && e('0'); // 步骤4:边界值gitlabID为0
|
||||
r($gitlabTest->apiGetSingleGroupTest(1, -1)) && p() && e('0'); // 步骤5:边界值groupID为负数
|
||||
Reference in New Issue
Block a user