Skip to content

Commit 0a14df1

Browse files
committed
Add more shortcuts for API factory method to prevent some typos.
Fix functional tests.
1 parent 4363f6f commit 0a14df1

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

lib/Github/Client.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,23 @@ public function __construct(ClientInterface $httpClient = null)
8888
public function api($name)
8989
{
9090
switch ($name) {
91+
case 'me':
9192
case 'current_user':
9293
$api = new Api\CurrentUser($this);
9394
break;
9495

96+
case 'git':
9597
case 'git_data':
9698
$api = new Api\GitData($this);
9799
break;
98100

101+
case 'gist':
99102
case 'gists':
100103
$api = new Api\Gists($this);
101104
break;
102105

103106
case 'issue':
107+
case 'issues':
104108
$api = new Api\Issue($this);
105109
break;
106110

@@ -109,18 +113,25 @@ public function api($name)
109113
break;
110114

111115
case 'organization':
116+
case 'organizations':
112117
$api = new Api\Organization($this);
113118
break;
114119

120+
case 'pr':
115121
case 'pull_request':
122+
case 'pull_requests':
116123
$api = new Api\PullRequest($this);
117124
break;
118125

119126
case 'repo':
127+
case 'repos':
128+
case 'repository':
129+
case 'repositories':
120130
$api = new Api\Repo($this);
121131
break;
122132

123133
case 'user':
134+
case 'users':
124135
$api = new Api\User($this);
125136
break;
126137

test/Github/Tests/ClientTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function shouldAuthenticateUsingUrlToken()
5858
/**
5959
* @test
6060
*/
61-
public function shouldClearHeadersLaizly()
61+
public function shouldClearHeadersLazy()
6262
{
6363
$client = new Client();
6464
$client->clearHeaders();
@@ -102,14 +102,33 @@ public function getApiClassesProvider()
102102
{
103103
return array(
104104
array('user', 'Github\Api\User'),
105+
array('users', 'Github\Api\User'),
106+
107+
array('me', 'Github\Api\CurrentUser'),
105108
array('current_user', 'Github\Api\CurrentUser'),
109+
110+
array('git', 'Github\Api\GitData'),
106111
array('git_data', 'Github\Api\GitData'),
112+
113+
array('gist', 'Github\Api\Gists'),
107114
array('gists', 'Github\Api\Gists'),
115+
108116
array('issue', 'Github\Api\Issue'),
117+
array('issues', 'Github\Api\Issue'),
118+
109119
array('markdown', 'Github\Api\Markdown'),
120+
110121
array('organization', 'Github\Api\Organization'),
122+
array('organizations', 'Github\Api\Organization'),
123+
111124
array('repo', 'Github\Api\Repo'),
125+
array('repos', 'Github\Api\Repo'),
126+
array('repository', 'Github\Api\Repo'),
127+
array('repositories', 'Github\Api\Repo'),
128+
129+
array('pr', 'Github\Api\PullRequest'),
112130
array('pull_request', 'Github\Api\PullRequest'),
131+
array('pull_requests', 'Github\Api\PullRequest'),
113132
);
114133
}
115134
}

test/Github/Tests/Functional/TestCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
use Github\Client;
66
use Github\Exception\ApiLimitExceedException;
7+
use Github\Exception\RuntimeException;
78

8-
class TestCase
9+
class TestCase extends \PHPUnit_Framework_TestCase
910
{
1011
protected $client;
1112

@@ -17,6 +18,10 @@ public function setUp()
1718
$client->api('current_user')->show();
1819
} catch (ApiLimitExceedException $e) {
1920
$this->markTestSkipped('API limit reached. Skipping to prevent unnecessary failure.');
21+
} catch (RuntimeException $e) {
22+
if ('Requires authentication' == $e->getMessage()) {
23+
$this->markTestSkipped('Test requires authentication. Skipping to prevent unnecessary failure.');
24+
}
2025
}
2126

2227
$this->client = $client;

0 commit comments

Comments
 (0)