Skip to content

Commit 5a3ef56

Browse files
authored
Merge pull request #325 from labzone/master
add parameters to project
2 parents 4fc60dc + c1eecda commit 5a3ef56

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,28 @@ public function all(array $parameters = [])
8585

8686
/**
8787
* @param int $project_id
88+
* @param array $parameters {
89+
*
90+
* @var bool $statistics Include project statistics.
91+
* @var bool $with_custom_attributes Include project custom attributes.
92+
* }
8893
* @return mixed
8994
*/
90-
public function show($project_id)
95+
public function show($project_id, array $parameters = [])
9196
{
92-
return $this->get('projects/'.$this->encodePath($project_id));
97+
$resolver = $this->createOptionsResolver();
98+
$booleanNormalizer = function (Options $resolver, $value) {
99+
return $value ? true : false;
100+
};
101+
$resolver->setDefined('statistics')
102+
->setAllowedTypes('statistics', 'bool')
103+
->setNormalizer('statistics', $booleanNormalizer)
104+
;
105+
$resolver->setDefined('with_custom_attributes')
106+
->setAllowedTypes('with_custom_attributes', 'bool')
107+
->setNormalizer('with_custom_attributes', $booleanNormalizer)
108+
;
109+
return $this->get('projects/'.$this->encodePath($project_id), $resolver->resolve($parameters));
93110
}
94111

95112
/**

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,33 @@ public function shouldShowProject()
110110
$this->assertEquals($expectedArray, $api->show(1));
111111
}
112112

113+
/**
114+
* @test
115+
*/
116+
public function shouldShowProjectWithStatistics()
117+
{
118+
$expectedArray = array(
119+
'id' => 1,
120+
'name' => 'Project Name',
121+
'statistics' => array(
122+
'commit_count' => 37,
123+
'storage_size' => 1038090,
124+
'repository_size' => 1038090,
125+
'lfs_objects_size' => 0,
126+
'job_artifacts_size' => 0
127+
)
128+
);
129+
130+
$api = $this->getApiMock();
131+
$api->expects($this->once())
132+
->method('get')
133+
->with('projects/1', ['statistics' => true])
134+
->will($this->returnValue($expectedArray))
135+
;
136+
137+
$this->assertEquals($expectedArray, $api->show(1, ['statistics' => true]));
138+
}
139+
113140
/**
114141
* @test
115142
*/

0 commit comments

Comments
 (0)