From 4e6658d7f91ef9661e2494244442c13d414642a5 Mon Sep 17 00:00:00 2001 From: Claude Dioudonnat Date: Sat, 10 May 2014 00:02:39 +0200 Subject: [PATCH 1/2] Add the /meta api part --- doc/index.md | 1 + doc/meta.md | 29 +++++++++++++++++++++++++ lib/Github/Api/Meta.php | 22 +++++++++++++++++++ lib/Github/Client.php | 4 ++++ test/Github/Tests/Api/MetaTest.php | 35 ++++++++++++++++++++++++++++++ test/Github/Tests/ClientTest.php | 2 ++ 6 files changed, 93 insertions(+) create mode 100644 doc/meta.md create mode 100644 lib/Github/Api/Meta.php create mode 100644 test/Github/Tests/Api/MetaTest.php diff --git a/doc/index.md b/doc/index.md index 1f447d6e457..7e4356427ad 100644 --- a/doc/index.md +++ b/doc/index.md @@ -17,6 +17,7 @@ APIs: * [Releases](repo/releases.md) * [Assets](repo/assets.md) * [Users](users.md) +* [Meta](meta.md) Additional features: diff --git a/doc/meta.md b/doc/meta.md new file mode 100644 index 00000000000..24ea3bfa270 --- /dev/null +++ b/doc/meta.md @@ -0,0 +1,29 @@ +## Users API +[Back to the navigation](index.md) + + +Wrap [GitHub User API](http://developer.github.com/v3/meta/). + +### Get information about GitHub services + +```php +$service = $client->api('meta')->service(); +``` + +return + +``` +array(3) { + 'verifiable_password_authentication' => bool + 'hooks' => + array(1) { + [0] => + string(15) "127.0.0.1/22" + } + 'git' => + array(1) { + [0] => + string(15) "127.0.0.1/22" + } +} +``` \ No newline at end of file diff --git a/lib/Github/Api/Meta.php b/lib/Github/Api/Meta.php new file mode 100644 index 00000000000..de504da9e72 --- /dev/null +++ b/lib/Github/Api/Meta.php @@ -0,0 +1,22 @@ + + */ +class Meta extends AbstractApi +{ + /** + * Get the ip address of the hook and git servers for the GitHub.com service + * + * @return array Informations about the service of GitHub.com + */ + public function service() + { + return $this->get('meta'); + } +} \ No newline at end of file diff --git a/lib/Github/Client.php b/lib/Github/Client.php index 0ec20c21aa4..d99fa44e515 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -139,6 +139,10 @@ public function api($name) $api = new Api\Authorizations($this); break; + case 'meta': + $api = new Api\Meta($this); + break; + default: throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name)); } diff --git a/test/Github/Tests/Api/MetaTest.php b/test/Github/Tests/Api/MetaTest.php new file mode 100644 index 00000000000..f284613a381 --- /dev/null +++ b/test/Github/Tests/Api/MetaTest.php @@ -0,0 +1,35 @@ + array( + '127.0.0.1/32' + ), + 'git' => array( + '127.0.0.1/32' + ), + 'verifiable_password_authentication' => true + ); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->will($this->returnValue($expectedArray)); + + $this->assertEquals($expectedArray, $api->service()); + } + + protected function getApiClass() + { + return 'Github\Api\Meta'; + } +} diff --git a/test/Github/Tests/ClientTest.php b/test/Github/Tests/ClientTest.php index 29e926b246a..8ebe27f785f 100644 --- a/test/Github/Tests/ClientTest.php +++ b/test/Github/Tests/ClientTest.php @@ -168,6 +168,8 @@ public function getApiClassesProvider() array('authorization', 'Github\Api\Authorizations'), array('authorizations', 'Github\Api\Authorizations'), + + array('meta', 'Github\Api\Meta') ); } From 8953af322689a8d7bca30c143e221352ee8ffcdb Mon Sep 17 00:00:00 2001 From: Claude Dioudonnat Date: Mon, 12 May 2014 23:54:54 +0200 Subject: [PATCH 2/2] Fix lines --- lib/Github/Api/Meta.php | 2 +- test/Github/Tests/Api/MetaTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Github/Api/Meta.php b/lib/Github/Api/Meta.php index de504da9e72..a10c1361b12 100644 --- a/lib/Github/Api/Meta.php +++ b/lib/Github/Api/Meta.php @@ -19,4 +19,4 @@ public function service() { return $this->get('meta'); } -} \ No newline at end of file +} diff --git a/test/Github/Tests/Api/MetaTest.php b/test/Github/Tests/Api/MetaTest.php index f284613a381..f2f8374f314 100644 --- a/test/Github/Tests/Api/MetaTest.php +++ b/test/Github/Tests/Api/MetaTest.php @@ -9,11 +9,10 @@ class MetaTest extends TestCase */ public function shouldGetInformationService() { - $expectedArray = array( 'hooks' => array( '127.0.0.1/32' - ), + ), 'git' => array( '127.0.0.1/32' ),