Skip to content

Commit 65dc679

Browse files
committed
Added namespace search endpoint. Fixes #101
1 parent c5cfb3e commit 65dc679

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/Gitlab/Api/ProjectNamespaces.php

+15
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,19 @@ public function all($page = 1, $per_page = self::PER_PAGE)
1414
'per_page' => $per_page
1515
));
1616
}
17+
18+
/**
19+
* @param string $terms
20+
* @param int $page
21+
* @param int $per_page
22+
* @return mixed
23+
*/
24+
public function search($terms, $page = 1, $per_page = self::PER_PAGE)
25+
{
26+
return $this->get('namespaces', array(
27+
'search' => $terms,
28+
'page' => $page,
29+
'per_page' => $per_page
30+
));
31+
}
1732
}

test/Gitlab/Tests/Api/ProjectNamespacesTest.php

+19
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ public function shouldNotNeedPaginationWhenGettingNamespaces()
4343

4444
$this->assertEquals($expectedArray, $api->all());
4545
}
46+
/**
47+
* @test
48+
*/
49+
public function shouldSearchNamespaces()
50+
{
51+
$expectedArray = array(
52+
array('id' => 1, 'name' => 'bespokes'),
53+
array('id' => 2, 'name' => 'internal')
54+
);
55+
56+
$api = $this->getApiMock();
57+
$api->expects($this->once())
58+
->method('get')
59+
->with('namespaces', array('search' => 'term', 'page' => 1, 'per_page' => 10))
60+
->will($this->returnValue($expectedArray))
61+
;
62+
63+
$this->assertEquals($expectedArray, $api->search('term', 1, 10));
64+
}
4665

4766
protected function getApiClass()
4867
{

0 commit comments

Comments
 (0)