Skip to content

Commit 8ea80ac

Browse files
author
Matt Humphrey
committed
Added test for group search
1 parent eb0b9ce commit 8ea80ac

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,46 @@ public function shouldNotNeedPaginationWhenGettingGroups()
4444
$this->assertEquals($expectedArray, $api->all());
4545
}
4646

47+
/**
48+
* @test
49+
*/
50+
public function shouldSearchGroups()
51+
{
52+
$expectedArray = array(
53+
array('id' => 1, 'name' => 'A group'),
54+
array('id' => 2, 'name' => 'Another group'),
55+
);
56+
57+
$api = $this->getApiMock();
58+
$api->expects($this->once())
59+
->method('get')
60+
->with('groups?search=group', array('page' => 1, 'per_page' => AbstractApi::PER_PAGE))
61+
->will($this->returnValue($expectedArray))
62+
;
63+
64+
$this->assertEquals($expectedArray, $api->search('group'));
65+
}
66+
67+
/**
68+
* @test
69+
*/
70+
public function shouldSearchGroupsWithPagination()
71+
{
72+
$expectedArray = array(
73+
array('id' => 1, 'name' => 'A group'),
74+
array('id' => 2, 'name' => 'Another group'),
75+
);
76+
77+
$api = $this->getApiMock();
78+
$api->expects($this->once())
79+
->method('get')
80+
->with('groups?search=group', array('page' => 2, 'per_page' => 5))
81+
->will($this->returnValue($expectedArray))
82+
;
83+
84+
$this->assertEquals($expectedArray, $api->search('group', 2, 5));
85+
}
86+
4787
/**
4888
* @test
4989
*/

0 commit comments

Comments
 (0)