Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
principis authored and m1guelpf committed Oct 10, 2019
1 parent 39aeae1 commit dcce2e7
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions test/Gitlab/Tests/Api/GroupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,104 @@ protected function getApiClass()
{
return 'Gitlab\Api\Groups';
}

/**
* @test
*/
public function shouldGetAllGroupProjectsWithIssuesEnabled()
{
$expectedArray = array(
array('id' => 1, 'name' => 'A group', 'issues_enabled' => true),
array('id' => 2, 'name' => 'Another group', 'issues_enabled' => true),
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1/projects', ['with_issues_enabled' => 'true'])
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->projects(1, ['with_issues_enabled' => true]));
}

/**
* @test
*/
public function shouldGetAllGroupProjectsWithMergeRequestsEnabled()
{
$expectedArray = array(
array('id' => 1, 'name' => 'A group', 'merge_requests_enabled' => true),
array('id' => 2, 'name' => 'Another group', 'merge_requests_enabled' => true),
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1/projects', ['with_merge_requests_enabled' => 'true'])
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->projects(1, ['with_merge_requests_enabled' => true]));
}

/**
* @test
*/
public function shouldGetAllGroupProjectsSharedToGroup()
{
$expectedArray = array(
array('id' => 1, 'name' => 'A project', 'shared_with_groups' => [1]),
array('id' => 2, 'name' => 'Another project', 'shared_with_groups' => [1]),
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1/projects', ['with_shared' => 'true'])
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->projects(1, ['with_shared' => true]));
}

/**
* @test
*/
public function shouldGetAllGroupProjectsIncludingSubsgroups()
{
$expectedArray = array(
array('id' => 1, 'name' => 'A project'),
array('id' => 2, 'name' => 'Another project', 'shared_with_groups' => [1]),
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1/projects', ['include_subgroups' => 'true'])
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->projects(1, ['include_subgroups' => true]));
}

/**
* @test
*/
public function shouldGetAllGroupProjectsIncludingCustomAttributes()
{
$expectedArray = array(
array('id' => 1, 'name' => 'A project', 'custom_Attr' => true),
array('id' => 2, 'name' => 'Another project', 'custom_Attr' => true),
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('groups/1/projects', ['with_custom_attributes' => 'true'])
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->projects(1, ['with_custom_attributes' => true]));
}
}

0 comments on commit dcce2e7

Please sign in to comment.