Skip to content

Commit

Permalink
Get namespace by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
o.trelin authored and m1guelpf committed Feb 2, 2019
1 parent e29ab46 commit 73c12f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Gitlab/Api/ProjectNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ public function all(array $parameters = [])

return $this->get('namespaces', $resolver->resolve($parameters));
}

/**
* @param integer|string $namespace_id
* @return mixed
*/
public function show($namespace_id)
{
return $this->get('namespaces/'.$this->encodePath($namespace_id));
}
}
17 changes: 17 additions & 0 deletions test/Gitlab/Tests/Api/ProjectNamespacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ public function shouldGetAllNamespaces()
$this->assertEquals($expectedArray, $api->all());
}

/**
* @test
*/
public function shouldShowNamespace()
{
$expectedArray = array('id' => 1, 'name' => 'internal');

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('namespaces/1')
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->show(1));
}

protected function getApiClass()
{
return 'Gitlab\Api\ProjectNamespaces';
Expand Down

0 comments on commit 73c12f2

Please sign in to comment.