From dcce2e732b598c6df6bddb71fadcebb90fed1e83 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Thu, 10 Oct 2019 13:34:52 +0200 Subject: [PATCH] added tests --- test/Gitlab/Tests/Api/GroupsTest.php | 100 +++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/test/Gitlab/Tests/Api/GroupsTest.php b/test/Gitlab/Tests/Api/GroupsTest.php index b08922e5d..b4da1de4d 100644 --- a/test/Gitlab/Tests/Api/GroupsTest.php +++ b/test/Gitlab/Tests/Api/GroupsTest.php @@ -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])); + } }