Skip to content

Commit

Permalink
Added namespace search endpoint. Fixes #101
Browse files Browse the repository at this point in the history
  • Loading branch information
m4tthumphrey committed Jul 28, 2015
1 parent c5cfb3e commit 65dc679
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/Gitlab/Api/ProjectNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,19 @@ public function all($page = 1, $per_page = self::PER_PAGE)
'per_page' => $per_page
));
}

/**
* @param string $terms
* @param int $page
* @param int $per_page
* @return mixed
*/
public function search($terms, $page = 1, $per_page = self::PER_PAGE)
{
return $this->get('namespaces', array(
'search' => $terms,
'page' => $page,
'per_page' => $per_page
));
}
}
19 changes: 19 additions & 0 deletions test/Gitlab/Tests/Api/ProjectNamespacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ public function shouldNotNeedPaginationWhenGettingNamespaces()

$this->assertEquals($expectedArray, $api->all());
}
/**
* @test
*/
public function shouldSearchNamespaces()
{
$expectedArray = array(
array('id' => 1, 'name' => 'bespokes'),
array('id' => 2, 'name' => 'internal')
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('namespaces', array('search' => 'term', 'page' => 1, 'per_page' => 10))
->will($this->returnValue($expectedArray))
;

$this->assertEquals($expectedArray, $api->search('term', 1, 10));
}

protected function getApiClass()
{
Expand Down

0 comments on commit 65dc679

Please sign in to comment.