Skip to content

Commit 47c13d7

Browse files
lifeofguenterm1guelpf
authored andcommitted
Extend create groups
1 parent dc39427 commit 47c13d7

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

lib/Gitlab/Api/Groups.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ public function show($id)
6767
* @param string $path
6868
* @param string $description
6969
* @param string $visibility
70+
* @param bool $lfs_enabled
71+
* @param bool $request_access_enabled
72+
* @param int $parent_id
73+
* @param int $shared_runners_minutes_limit
7074
* @return mixed
7175
*/
72-
public function create($name, $path, $description = null, $visibility = 'private')
76+
public function create($name, $path, $description = null, $visibility = 'private', $lfs_enabled = null, $request_access_enabled = null, $parent_id = null, $shared_runners_minutes_limit = null)
7377
{
74-
return $this->post('groups', array(
78+
$params = array(
7579
'name' => $name,
7680
'path' => $path,
7781
'description' => $description,
7882
'visibility' => $visibility,
79-
));
83+
'lfs_enabled' => $lfs_enabled,
84+
'request_access_enabled' => $request_access_enabled,
85+
'parent_id' => $parent_id,
86+
'shared_runners_minutes_limit' => $shared_runners_minutes_limit,
87+
);
88+
89+
return $this->post('groups', array_filter($params, 'strlen'));
8090
}
8191

8292
/**

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function shouldCreateGroup()
111111
$api = $this->getApiMock();
112112
$api->expects($this->once())
113113
->method('post')
114-
->with('groups', array('name' => 'A new group', 'path' => 'a-new-group', 'description' => null, 'visibility' => 'private'))
114+
->with('groups', array('name' => 'A new group', 'path' => 'a-new-group', 'visibility' => 'private'))
115115
->will($this->returnValue($expectedArray))
116116
;
117117

@@ -121,17 +121,34 @@ public function shouldCreateGroup()
121121
/**
122122
* @test
123123
*/
124-
public function shouldCreateGroupWithDescriptionAndVisibility()
124+
public function shouldCreateGroupWithDescriptionVisibilityAndParentId()
125125
{
126-
$expectedArray = array('id' => 1, 'name' => 'A new group', 'visibility_level' => 2);
126+
$expectedArray = array('id' => 1, 'name' => 'A new group', 'visibility_level' => 2, 'parent_id' => 666);
127127

128128
$api = $this->getApiMock();
129129
$api->expects($this->once())
130130
->method('post')
131-
->with('groups', array('name' => 'A new group', 'path' => 'a-new-group', 'description' => 'Description', 'visibility' => 'public'))
131+
->with('groups', array('name' => 'A new group', 'path' => 'a-new-group', 'description' => 'Description', 'visibility' => 'public', 'parent_id' => 666))
132132
->will($this->returnValue($expectedArray))
133133
;
134134

135+
$this->assertEquals($expectedArray, $api->create('A new group', 'a-new-group', 'Description', 'public', null, null, 666));
136+
}
137+
138+
/**
139+
* @test
140+
*/
141+
public function shouldCreateGroupWithDescriptionAndVisibility()
142+
{
143+
$expectedArray = array('id' => 1, 'name' => 'A new group', 'visibility_level' => 2);
144+
145+
$api = $this->getApiMock();
146+
$api->expects($this->once())
147+
->method('post')
148+
->with('groups', array('name' => 'A new group', 'path' => 'a-new-group', 'description' => 'Description', 'visibility' => 'public'))
149+
->will($this->returnValue($expectedArray))
150+
;
151+
135152
$this->assertEquals($expectedArray, $api->create('A new group', 'a-new-group', 'Description', 'public'));
136153
}
137154

0 commit comments

Comments
 (0)