forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepoTest.php
More file actions
107 lines (91 loc) · 2.96 KB
/
Copy pathRepoTest.php
File metadata and controls
107 lines (91 loc) · 2.96 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
<?php
namespace Github\Tests\Integration;
/**
* @group integration
*/
class RepoTest extends TestCase
{
/**
* @test
*/
public function shouldShowPRDiffIfHeaderIsPresent()
{
$this->client->addHeaders(
['Accept' => sprintf(
'application/vnd.github.%s.diff',
$this->client->getApiVersion()
)]
);
$diff = $this->client->api('pull_request')->show('KnpLabs', 'php-github-api', '92');
$this->assertInternalType('string', $diff);
}
/**
* @test
*/
public function shouldRetrieveRawBlob()
{
$api = $this->client->api('git_data')->blobs();
$api->configure('raw');
$contents = $api->show(
'KnpLabs',
'php-github-api',
'e50d5e946385cff052636e2f09f36b03d1c368f4'
);
$this->assertInternalType('string', $contents);
$this->assertStringStartsWith('<?php', $contents);
}
/**
* @test
*/
public function shouldNotDecodeRawBlob()
{
$api = $this->client->api('git_data')->blobs();
$api->configure('raw');
$contents = $api->show(
'KnpLabs',
'php-github-api',
'dc16d3e77fd4e40638cb722927ffe15fa85b1434'
);
$this->assertInternalType('string', $contents);
$this->assertStringStartsWith('{', $contents);
}
/**
* @test
*/
public function shouldRetrieveContributorsList()
{
$username = 'KnpLabs';
$repo = 'php-github-api';
$contributors = $this->client->api('repo')->contributors($username, $repo);
$contributor = array_pop($contributors);
$this->assertArrayHasKey('url', $contributor);
$this->assertArrayHasKey('gravatar_id', $contributor);
$this->assertArrayHasKey('contributions', $contributor);
$this->assertArrayHasKey('avatar_url', $contributor);
$this->assertArrayHasKey('login', $contributor);
$this->assertArrayHasKey('id', $contributor);
}
/**
* @test
*/
public function shouldShowRepo()
{
$username = 'KnpLabs';
$repo = 'php-github-api';
$repo = $this->client->api('repo')->show($username, $repo);
$this->assertArrayHasKey('id', $repo);
$this->assertArrayHasKey('name', $repo);
$this->assertArrayHasKey('description', $repo);
$this->assertArrayHasKey('url', $repo);
$this->assertArrayHasKey('has_wiki', $repo);
$this->assertArrayHasKey('has_issues', $repo);
$this->assertArrayHasKey('forks', $repo);
$this->assertArrayHasKey('updated_at', $repo);
$this->assertArrayHasKey('created_at', $repo);
$this->assertArrayHasKey('pushed_at', $repo);
$this->assertArrayHasKey('open_issues', $repo);
$this->assertArrayHasKey('ssh_url', $repo);
$this->assertArrayHasKey('git_url', $repo);
$this->assertArrayHasKey('svn_url', $repo);
}
}