diff --git a/module/gitlab/test/gitlab.class.php b/module/gitlab/test/gitlab.class.php index d8846abdde..4110b4e37e 100644 --- a/module/gitlab/test/gitlab.class.php +++ b/module/gitlab/test/gitlab.class.php @@ -349,4 +349,22 @@ class gitlabTest return $result; } + + public function createGroupTest(int $gitlabID, object $project) + { + $result = $this->gitlab->createGroup($gitlabID, $project); + + if(dao::isError()) return dao::getError(); + + return $result; + } + + public function editGroupTest(int $gitlabID, object $project) + { + $result = $this->gitlab->editGroup($gitlabID, $project); + + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/gitlab/test/model/creategroup.php b/module/gitlab/test/model/creategroup.php new file mode 100644 index 0000000000..c69bf73b0d --- /dev/null +++ b/module/gitlab/test/model/creategroup.php @@ -0,0 +1,43 @@ +#!/usr/bin/env php +gen(5); + +$gitlab = new gitlabTest(); + +$gitlabID = 1; +$group = new stdclass(); +$group->name = ''; +$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'; + +r($gitlab->createGroupTest($gitlabID, $group)) && p('name:0') && e('群组名称不能为空'); //使用空的名字创建gitlab群组 + +$group->name = 'unitTestGroup17'; +$group->path = ''; +r($gitlab->createGroupTest($gitlabID, $group)) && p('path:0') && e('群组URL不能为空'); //使用空的群组URL创建gitlab群组 + +$group->path = 'unit_test_group17'; +$result = $gitlab->createGroupTest($gitlabID, $group); +if(!empty($result[0]) and $result[0] == '保存失败,群组URL路径已经被使用。') $result = true; +r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支 \ No newline at end of file diff --git a/module/gitlab/test/model/editgroup.php b/module/gitlab/test/model/editgroup.php new file mode 100644 index 0000000000..9ab39d5305 --- /dev/null +++ b/module/gitlab/test/model/editgroup.php @@ -0,0 +1,55 @@ +#!/usr/bin/env php +gen(5); + +$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); + +/* Get groupID. */ +$gitlabGroups = $gitlab->apiGetGroups($gitlabID); +foreach($gitlabGroups as $gitlabGroup) +{ + if($gitlabGroup->name == 'unitTestGroup17') + { + $groupID = $gitlabGroup->id; + break; + } +} + +$group = new stdclass(); +$group->description = 'apiUpdatedGroup'; + +$gitlabTest = new gitlabTest(); +r($gitlabTest->editGroupTest($gitlabID, $group)) && p('name:0') && e('群组名称不能为空'); //使用空的groupID创建gitlab群组 + +$group->id = $groupID; +$group->name = 'unitTestGroup17'; +r($gitlabTest->editGroupTest($gitlabID, $group)) && p() && e('1'); //通过gitlabID,用户对象正确更新用户名字 \ No newline at end of file