Repository navigation
Expand file tree
/
Copy pathClientTest.php
More file actions
134 lines (108 loc) · 3.42 KB
/
Copy pathClientTest.php
File metadata and controls
134 lines (108 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
namespace Github\Tests;
use Github\Client;
use Github\Exception\InvalidArgumentException;
/**
* Client unit test
*
* @author Leszek Prabucki <leszek.prabucki@gmail.com>
*/
class ClientTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldNotHaveToPassHttpClientToConstructor()
{
$client = new Client();
$this->assertInstanceOf('Github\HttpClient\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function shouldAuthenticateUsingLoginAndPassword()
{
$client = new Client();
$client->authenticate('login', 'password', Client::AUTH_HTTP_PASSWORD);
$this->assertInstanceOf('Github\HttpClient\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function shouldAuthenticateUsingHttpToken()
{
$client = new Client();
$client->authenticate('login', 'password', Client::AUTH_HTTP_TOKEN);
$this->assertInstanceOf('Github\HttpClient\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function shouldAuthenticateUsingUrlToken()
{
$client = new Client();
$client->authenticate('login', 'password', Client::AUTH_URL_TOKEN);
$this->assertInstanceOf('Github\HttpClient\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function shouldClearHeadersLazy()
{
$client = new Client();
$client->clearHeaders();
$this->assertInstanceOf('Github\HttpClient\HttpClientInterface', $client->getHttpClient());
}
/**
* @test
*/
public function shouldSetHeadersLaizly()
{
$client = new Client();
$client->setHeaders(array('header1', 'header2'));
$this->assertInstanceOf('Github\HttpClient\HttpClientInterface', $client->getHttpClient());
}
/**
* @test
* @dataProvider getApiClassesProvider
*/
public function shouldGetApiInstance($apiName, $class)
{
$client = new Client();
$this->assertInstanceOf($class, $client->api($apiName));
}
/**
* @test
* @expectedException InvalidArgumentException
*/
public function shouldNotGetApiInstance()
{
$client = new Client();
$client->api('do_not_exist');
}
public function getApiClassesProvider()
{
return array(
array('user', 'Github\Api\User'),
array('users', 'Github\Api\User'),
array('me', 'Github\Api\CurrentUser'),
array('current_user', 'Github\Api\CurrentUser'),
array('git', 'Github\Api\GitData'),
array('git_data', 'Github\Api\GitData'),
array('gist', 'Github\Api\Gists'),
array('gists', 'Github\Api\Gists'),
array('issue', 'Github\Api\Issue'),
array('issues', 'Github\Api\Issue'),
array('markdown', 'Github\Api\Markdown'),
array('organization', 'Github\Api\Organization'),
array('organizations', 'Github\Api\Organization'),
array('repo', 'Github\Api\Repo'),
array('repos', 'Github\Api\Repo'),
array('repository', 'Github\Api\Repo'),
array('repositories', 'Github\Api\Repo'),
array('pr', 'Github\Api\PullRequest'),
array('pull_request', 'Github\Api\PullRequest'),
array('pull_requests', 'Github\Api\PullRequest'),
);
}
}