Skip to content

Commit 0f56632

Browse files
committed
use OptionsResolver in DeployKeys api
1 parent 6e409e8 commit 0f56632

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

UPGRADE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ See [documentation](doc/customize.md) to know how to customize the client timeou
1313
* The `setHttpClient` method have been removed. Use a `Gitlab\HttpClient\Builder` instead.
1414
* The `getHttpClient` method return type is changed to `Http\Client\Common\HttpMethodsClient`.
1515

16+
## `Gitlab\Api\DeployKeys` changes
17+
18+
* The `all` method now take a single argument which is an associative array of query string parameters.
19+
* The `ORDER_BY` and `SORT` class constants have been removed.
1620

1721
## `Gitlab\Api\Groups` changes
1822

lib/Gitlab/Api/DeployKeys.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,15 @@
22

33
class DeployKeys extends AbstractApi
44
{
5-
const ORDER_BY = 'id';
6-
const SORT = 'asc';
7-
85
/**
9-
* @param int $page
10-
* @param int $per_page
11-
* @param string $order_by
12-
* @param string $sort
6+
* @param array $parameters
7+
*
138
* @return mixed
149
*/
15-
public function all($page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT)
10+
public function all(array $parameters = [])
1611
{
17-
return $this->get('deploy_keys', array(
18-
'page' => $page,
19-
'per_page' => $per_page,
20-
'order_by' => $order_by,
21-
'sort' => $sort
22-
));
12+
$resolver = $this->createOptionsResolver();
13+
14+
return $this->get('deploy_keys', $resolver->resolve($parameters));
2315
}
2416
}

test/Gitlab/Tests/Api/DeployKeysTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,14 @@ public function shouldGetAllDeployKeys()
99
{
1010
$expectedArray = $this->getMultipleDeployKeysData();
1111

12-
$api = $this->getMultipleDeployKeysRequestMock('deploy_keys', $expectedArray);
13-
14-
$this->assertEquals($expectedArray, $api->all());
15-
}
16-
17-
protected function getMultipleDeployKeysRequestMock($path, $expectedArray = array(), $page = 1, $per_page = 20, $order_by = 'id', $sort = 'asc')
18-
{
1912
$api = $this->getApiMock();
2013
$api->expects($this->once())
2114
->method('get')
22-
->with($path, array('page' => $page, 'per_page' => $per_page, 'order_by' => $order_by, 'sort' => $sort))
15+
->with('deploy_keys', array('page' => 2, 'per_page' => 5))
2316
->will($this->returnValue($expectedArray))
2417
;
2518

26-
return $api;
19+
$this->assertEquals($expectedArray, $api->all(['page' => 2, 'per_page' => 5]));
2720
}
2821

2922
protected function getMultipleDeployKeysData()

0 commit comments

Comments
 (0)