Skip to content

Commit dcce2e7

Browse files
principism1guelpf
authored andcommitted
added tests
1 parent 39aeae1 commit dcce2e7

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,104 @@ protected function getApiClass()
525525
{
526526
return 'Gitlab\Api\Groups';
527527
}
528+
529+
/**
530+
* @test
531+
*/
532+
public function shouldGetAllGroupProjectsWithIssuesEnabled()
533+
{
534+
$expectedArray = array(
535+
array('id' => 1, 'name' => 'A group', 'issues_enabled' => true),
536+
array('id' => 2, 'name' => 'Another group', 'issues_enabled' => true),
537+
);
538+
539+
$api = $this->getApiMock();
540+
$api->expects($this->once())
541+
->method('get')
542+
->with('groups/1/projects', ['with_issues_enabled' => 'true'])
543+
->will($this->returnValue($expectedArray))
544+
;
545+
546+
$this->assertEquals($expectedArray, $api->projects(1, ['with_issues_enabled' => true]));
547+
}
548+
549+
/**
550+
* @test
551+
*/
552+
public function shouldGetAllGroupProjectsWithMergeRequestsEnabled()
553+
{
554+
$expectedArray = array(
555+
array('id' => 1, 'name' => 'A group', 'merge_requests_enabled' => true),
556+
array('id' => 2, 'name' => 'Another group', 'merge_requests_enabled' => true),
557+
);
558+
559+
$api = $this->getApiMock();
560+
$api->expects($this->once())
561+
->method('get')
562+
->with('groups/1/projects', ['with_merge_requests_enabled' => 'true'])
563+
->will($this->returnValue($expectedArray))
564+
;
565+
566+
$this->assertEquals($expectedArray, $api->projects(1, ['with_merge_requests_enabled' => true]));
567+
}
568+
569+
/**
570+
* @test
571+
*/
572+
public function shouldGetAllGroupProjectsSharedToGroup()
573+
{
574+
$expectedArray = array(
575+
array('id' => 1, 'name' => 'A project', 'shared_with_groups' => [1]),
576+
array('id' => 2, 'name' => 'Another project', 'shared_with_groups' => [1]),
577+
);
578+
579+
$api = $this->getApiMock();
580+
$api->expects($this->once())
581+
->method('get')
582+
->with('groups/1/projects', ['with_shared' => 'true'])
583+
->will($this->returnValue($expectedArray))
584+
;
585+
586+
$this->assertEquals($expectedArray, $api->projects(1, ['with_shared' => true]));
587+
}
588+
589+
/**
590+
* @test
591+
*/
592+
public function shouldGetAllGroupProjectsIncludingSubsgroups()
593+
{
594+
$expectedArray = array(
595+
array('id' => 1, 'name' => 'A project'),
596+
array('id' => 2, 'name' => 'Another project', 'shared_with_groups' => [1]),
597+
);
598+
599+
$api = $this->getApiMock();
600+
$api->expects($this->once())
601+
->method('get')
602+
->with('groups/1/projects', ['include_subgroups' => 'true'])
603+
->will($this->returnValue($expectedArray))
604+
;
605+
606+
$this->assertEquals($expectedArray, $api->projects(1, ['include_subgroups' => true]));
607+
}
608+
609+
/**
610+
* @test
611+
*/
612+
public function shouldGetAllGroupProjectsIncludingCustomAttributes()
613+
{
614+
$expectedArray = array(
615+
array('id' => 1, 'name' => 'A project', 'custom_Attr' => true),
616+
array('id' => 2, 'name' => 'Another project', 'custom_Attr' => true),
617+
);
618+
619+
$api = $this->getApiMock();
620+
$api->expects($this->once())
621+
->method('get')
622+
->with('groups/1/projects', ['with_custom_attributes' => 'true'])
623+
->will($this->returnValue($expectedArray))
624+
;
625+
626+
$this->assertEquals($expectedArray, $api->projects(1, ['with_custom_attributes' => true]));
627+
}
528628
}

0 commit comments

Comments
 (0)