Skip to content

Commit ab52b15

Browse files
committed
removed pagination parameters default values and validation
1 parent f6c76e5 commit ab52b15

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ public function cancelPipeline($project_id, $pipeline_id)
245245
* @param array $parameters (
246246
*
247247
* @var string $query The query you want to search members for.
248-
* @var string $page The page you want to take members from. (default: 1)
249-
* @var string $per_page The count of members per page. (default: 20)
250248
* )
251249
*
252250
* @throws MissingOptionsException If a required option is not provided
@@ -266,20 +264,9 @@ public function members($project_id, $parameters = [])
266264

267265
$resolver = $this->createOptionsResolver();
268266

269-
$resolver->setDefaults(array(
270-
'page' => 1,
271-
'per_page' => 20,
272-
));
273-
274267
$resolver->setDefined('query')
275268
->setAllowedTypes('query', 'string')
276269
;
277-
$resolver->setDefined('page')
278-
->setAllowedTypes('page', 'int')
279-
;
280-
$resolver->setDefined('per_page')
281-
->setAllowedTypes('per_page', 'int')
282-
;
283270

284271
return $this->get($this->getProjectPath($project_id, 'members'), $resolver->resolve($parameters));
285272
}

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function shouldGetMembersWithQuery()
371371
$api = $this->getApiMock();
372372
$api->expects($this->once())
373373
->method('get')
374-
->with('projects/1/members', array('query' => 'at', 'page' => 1, 'per_page' => 20))
374+
->with('projects/1/members', array('query' => 'at'))
375375
->will($this->returnValue($expectedArray))
376376
;
377377

@@ -391,13 +391,36 @@ public function shouldGetMembersWithNullQuery()
391391
$api = $this->getApiMock();
392392
$api->expects($this->once())
393393
->method('get')
394-
->with('projects/1/members', array('page' => 1, 'per_page' => 20))
394+
->with('projects/1/members')
395395
->will($this->returnValue($expectedArray))
396396
;
397397

398398
$this->assertEquals($expectedArray, $api->members(1, null));
399399
}
400400

401+
/**
402+
* @test
403+
*/
404+
public function shouldGetMembersWithPagination()
405+
{
406+
$expectedArray = array(
407+
array('id' => 1, 'name' => 'Matt'),
408+
array('id' => 2, 'name' => 'Bob')
409+
);
410+
411+
$api = $this->getApiMock();
412+
$api->expects($this->once())
413+
->method('get')
414+
->with('projects/1/members', array(
415+
'page' => 2,
416+
'per_page' => 15
417+
))
418+
->will($this->returnValue($expectedArray))
419+
;
420+
421+
$this->assertEquals($expectedArray, $api->members(1, array('page' => 2, 'per_page' => 15)));
422+
}
423+
401424
/**
402425
* @test
403426
*/

0 commit comments

Comments
 (0)