* [misc] Enhance unit tests for gitlabModel::editGroup() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,40 +1,47 @@
|
||||
#!/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::editGroup();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 使用空的groupID创建gitlab群组第name条的0属性 @群组名称不能为空
|
||||
- 通过gitlabID,用户对象正确更新用户名字 @1
|
||||
- 执行gitlabTest模块的editGroupTest方法,参数是$gitlabID, $emptyNameGroup 第name条的0属性 @群组名称不能为空
|
||||
- 执行gitlabTest模块的editGroupTest方法,参数是$gitlabID, $validGroup @1
|
||||
- 执行gitlabTest模块的editGroupTest方法,参数是999, $invalidGitlabGroup @0
|
||||
- 执行gitlabTest模块的editGroupTest方法,参数是$gitlabID, $invalidGroup @0
|
||||
- 执行gitlabTest模块的editGroupTest方法,参数是$gitlabID, $emptyStringGroup 第name条的0属性 @群组名称不能为空
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/gitlab.unittest.class.php';
|
||||
|
||||
zenData('pipeline')->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
$gitlabTest = new gitlabTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
|
||||
/* Create group for testing. */
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
|
||||
/* Create group. */
|
||||
$group = new stdclass();
|
||||
$group->name = 'unitTestGroup17';
|
||||
$group->path = 'unit_test_group17';
|
||||
$group->description = 'unit_test_group desc';
|
||||
$group->visibility = 'public';
|
||||
$group->request_access_enabled = '1';
|
||||
$group->lfs_enabled = '1';
|
||||
$group->project_creation_level = 'developer';
|
||||
$group->subgroup_creation_level = 'maintainer';
|
||||
$gitlab->apiCreateGroup($gitlabID, $group);
|
||||
$testGroup = new stdclass();
|
||||
$testGroup->name = 'unitTestGroup17';
|
||||
$testGroup->path = 'unit_test_group17';
|
||||
$testGroup->description = 'unit_test_group desc';
|
||||
$testGroup->visibility = 'public';
|
||||
$testGroup->request_access_enabled = '1';
|
||||
$testGroup->lfs_enabled = '1';
|
||||
$testGroup->project_creation_level = 'developer';
|
||||
$testGroup->subgroup_creation_level = 'maintainer';
|
||||
$gitlab->apiCreateGroup($gitlabID, $testGroup);
|
||||
|
||||
/* Get groupID. */
|
||||
$gitlabGroups = $gitlab->apiGetGroups($gitlabID);
|
||||
$groupID = 0;
|
||||
foreach($gitlabGroups as $gitlabGroup)
|
||||
{
|
||||
if($gitlabGroup->name == 'unitTestGroup17')
|
||||
@@ -44,12 +51,34 @@ foreach($gitlabGroups as $gitlabGroup)
|
||||
}
|
||||
}
|
||||
|
||||
$group = new stdclass();
|
||||
$group->description = 'apiUpdatedGroup';
|
||||
// 测试步骤1:使用空name字段编辑群组
|
||||
$emptyNameGroup = new stdclass();
|
||||
$emptyNameGroup->id = $groupID;
|
||||
$emptyNameGroup->description = 'test description';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $emptyNameGroup)) && p('name:0') && e('群组名称不能为空');
|
||||
|
||||
$gitlabTest = new gitlabTest();
|
||||
r($gitlabTest->editGroupTest($gitlabID, $group)) && p('name:0') && e('群组名称不能为空'); //使用空的groupID创建gitlab群组
|
||||
// 测试步骤2:使用有效参数正常编辑群组
|
||||
$validGroup = new stdclass();
|
||||
$validGroup->id = $groupID;
|
||||
$validGroup->name = 'updatedTestGroup17';
|
||||
$validGroup->description = 'updated description';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $validGroup)) && p() && e('1');
|
||||
|
||||
$group->id = $groupID;
|
||||
$group->name = 'unitTestGroup17';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $group)) && p() && e('1'); //通过gitlabID,用户对象正确更新用户名字
|
||||
// 测试步骤3:使用无效的gitlabID编辑群组
|
||||
$invalidGitlabGroup = new stdclass();
|
||||
$invalidGitlabGroup->id = $groupID;
|
||||
$invalidGitlabGroup->name = 'testGroup';
|
||||
r($gitlabTest->editGroupTest(999, $invalidGitlabGroup)) && p() && e('0');
|
||||
|
||||
// 测试步骤4:使用无效的groupID编辑群组
|
||||
$invalidGroup = new stdclass();
|
||||
$invalidGroup->id = 99999;
|
||||
$invalidGroup->name = 'testGroup';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $invalidGroup)) && p() && e('0');
|
||||
|
||||
// 测试步骤5:测试name字段边界值(空字符串)
|
||||
$emptyStringGroup = new stdclass();
|
||||
$emptyStringGroup->id = $groupID;
|
||||
$emptyStringGroup->name = '';
|
||||
$emptyStringGroup->description = 'test description';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $emptyStringGroup)) && p('name:0') && e('群组名称不能为空');
|
||||
Reference in New Issue
Block a user