Skip to content

Commit 14e2901

Browse files
authored
Merge pull request #484 from pkolmann/pkolmann
add forks API call to return all forked projects
2 parents 800522a + b54ccc0 commit 14e2901

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

lib/Gitlab/Api/Projects.php

+12
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,18 @@ public function languages($project_id)
650650
return $this->get($this->getProjectPath($project_id, 'languages'));
651651
}
652652

653+
/**
654+
* @param int $project_id
655+
* @param array $parameters
656+
* @return mixed
657+
*/
658+
public function forks($project_id, array $parameters = [])
659+
{
660+
$resolver = $this->createOptionsResolver();
661+
662+
return $this->get($this->getProjectPath($project_id, 'forks'), $resolver->resolve($parameters));
663+
}
664+
653665
/**
654666
* @param int $project_id
655667
* @param array $params (

test/Gitlab/Tests/Api/ProjectsTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,35 @@ public function shouldRemoveForkRelation()
12981298
$this->assertEquals($expectedBool, $api->removeForkRelation(2));
12991299
}
13001300

1301+
1302+
/**
1303+
* @test
1304+
*/
1305+
public function shouldGetForks()
1306+
{
1307+
$expectedArray = [
1308+
[
1309+
'id' => 2,
1310+
'forked_from_project' => [
1311+
'id' => 1
1312+
]
1313+
],
1314+
[
1315+
'id' => 3,
1316+
'forked_from_project' => [
1317+
'id' => 1
1318+
]
1319+
],
1320+
];
1321+
$api = $this->getApiMock();
1322+
$api->expects($this->once())
1323+
->method('get')
1324+
->with('projects/1/forks')
1325+
->will($this->returnValue($expectedArray));
1326+
1327+
$this->assertEquals($expectedArray, $api->forks(1));
1328+
}
1329+
13011330
/**
13021331
* @test
13031332
*/

0 commit comments

Comments
 (0)