From 21a3445c9c7cd52a530aacee09619a383a069cf6 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Thu, 1 May 2014 18:05:16 +0200 Subject: [PATCH 1/4] Added way to sort user repositories --- lib/Github/Api/User.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index e832bd84710..499fa71e797 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -104,11 +104,12 @@ public function subscriptions($username) * @link http://developer.github.com/v3/repos/ * * @param string $username the username + * @param string $sort the repository order * @return array list of the user repositories */ - public function repositories($username) + public function repositories($username, $sort = 'full_name') { - return $this->get('users/'.rawurlencode($username).'/repos'); + return $this->get('users/'.rawurlencode($username).'/repos?sort=' . rawurlencode($sort)); } /** From 91176a03632603facd3287cd2c66aec307a9f340 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Thu, 1 May 2014 18:19:07 +0200 Subject: [PATCH 2/4] Updated unit test User class --- test/Github/Tests/Api/UserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index 95dcb542e5f..cff91d2332c 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -97,7 +97,7 @@ public function shouldGetUserRepositories() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('users/l3l0/repos') + ->with('users/l3l0/repos?sort=full_name') ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositories('l3l0')); From c102d4c9413916238b0337f31e9be638f3027e42 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Fri, 2 May 2014 18:03:40 +0200 Subject: [PATCH 3/4] Updated repositories method Made use of the parameters array --- lib/Github/Api/User.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index 499fa71e797..0419c306626 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -109,7 +109,9 @@ public function subscriptions($username) */ public function repositories($username, $sort = 'full_name') { - return $this->get('users/'.rawurlencode($username).'/repos?sort=' . rawurlencode($sort)); + return $this->get('users/'.rawurlencode($username).'/repos', array( + 'sort' => $sort + )); } /** From ca3f8de2430882aa1e826ea55f89b8c003f981f2 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Fri, 2 May 2014 18:33:36 +0200 Subject: [PATCH 4/4] Updated User test case --- test/Github/Tests/Api/UserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index cff91d2332c..95dcb542e5f 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -97,7 +97,7 @@ public function shouldGetUserRepositories() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('users/l3l0/repos?sort=full_name') + ->with('users/l3l0/repos') ->will($this->returnValue($expectedArray)); $this->assertEquals($expectedArray, $api->repositories('l3l0'));