Skip to content

Addition of Projects API calls in Group Model #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/Gitlab/Api/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,18 @@ public function removeMember($group_id, $user_id)
{
return $this->delete('groups/'.$this->encodePath($group_id).'/members/'.$this->encodePath($user_id));
}

/**
* @param $id
* @param int $page
* @param int $per_page
* @return mixed
*/
public function projects($id, $page = 1, $per_page = self::PER_PAGE)
{
return $this->get('groups/'.$this->encodePath($id).'/projects', array(
'page' => $page,
'per_page' => $per_page
));
}
}
11 changes: 11 additions & 0 deletions lib/Gitlab/Model/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,15 @@ public function removeMember($user_id)

return true;
}

/**
* @return Group
*/
public function projects()
{

$data = $this->api('groups')->projects($this->id);

return Group::fromArray($this->getClient(),$data);
}
}
2 changes: 2 additions & 0 deletions lib/Gitlab/Model/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class Node extends AbstractModel
'type',
'mode',
'id',
'path',
'project'
);


/**
* @param Client $client
* @param Project $project
Expand Down
3 changes: 2 additions & 1 deletion test/Gitlab/Tests/Api/ProjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ public function shouldGetOwnedProjects()
{
$expectedArray = $this->getMultipleProjectsData();

$api = $this->getMultipleProjectsRequestMock('projects/owned', $expectedArray, 3, 50);
$api = $this->getMultipleProjectsRequestMock('projects?owned=1', $expectedArray, 3, 50);

$this->assertEquals($expectedArray, $api->owned(3, 50));
}


/**
* @test
*/
Expand Down