Skip to content

Commit 73c12f2

Browse files
o.trelinm1guelpf
authored andcommitted
Get namespace by ID
1 parent e29ab46 commit 73c12f2

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/Gitlab/Api/ProjectNamespaces.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ public function all(array $parameters = [])
1717

1818
return $this->get('namespaces', $resolver->resolve($parameters));
1919
}
20+
21+
/**
22+
* @param integer|string $namespace_id
23+
* @return mixed
24+
*/
25+
public function show($namespace_id)
26+
{
27+
return $this->get('namespaces/'.$this->encodePath($namespace_id));
28+
}
2029
}

test/Gitlab/Tests/Api/ProjectNamespacesTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ public function shouldGetAllNamespaces()
2424
$this->assertEquals($expectedArray, $api->all());
2525
}
2626

27+
/**
28+
* @test
29+
*/
30+
public function shouldShowNamespace()
31+
{
32+
$expectedArray = array('id' => 1, 'name' => 'internal');
33+
34+
$api = $this->getApiMock();
35+
$api->expects($this->once())
36+
->method('get')
37+
->with('namespaces/1')
38+
->will($this->returnValue($expectedArray))
39+
;
40+
41+
$this->assertEquals($expectedArray, $api->show(1));
42+
}
43+
2744
protected function getApiClass()
2845
{
2946
return 'Gitlab\Api\ProjectNamespaces';

0 commit comments

Comments
 (0)