forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGistTest.php
More file actions
71 lines (61 loc) · 1.94 KB
/
Copy pathGistTest.php
File metadata and controls
71 lines (61 loc) · 1.94 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
<?php
namespace Github\Tests\Integration;
use Github\Exception\RuntimeException;
/**
* @group integration
*/
class GistTest extends TestCase
{
/**
* @test
*/
public function shouldRetrievePublicGistsListWhenCalledAnonymously()
{
$gists = $this->client->api('gists')->all();
$gist = array_pop($gists);
$this->assertArrayHasKey('url', $gist);
$this->assertArrayHasKey('files', $gist);
$this->assertArrayHasKey('comments', $gist);
$this->assertArrayHasKey('created_at', $gist);
$this->assertArrayHasKey('updated_at', $gist);
$this->assertArrayHasKey('user', $gist);
}
/**
* @test
*/
public function shouldNotGetStarredListWithoutAuthorization()
{
$this->expectException(RuntimeException::class);
$this->client->api('gists')->all('starred');
}
/**
* @test
*/
public function shouldRetrievePublicGistsList()
{
$gists = $this->client->api('gists')->all('public');
$gist = array_pop($gists);
$this->assertArrayHasKey('url', $gist);
$this->assertArrayHasKey('files', $gist);
$this->assertArrayHasKey('comments', $gist);
$this->assertArrayHasKey('created_at', $gist);
$this->assertArrayHasKey('updated_at', $gist);
$this->assertArrayHasKey('user', $gist);
}
/**
* @test
*/
public function shouldRetrieveGistById()
{
$id = 1;
$gist = $this->client->api('gists')->show($id);
$this->assertArrayHasKey('url', $gist);
$this->assertArrayHasKey('files', $gist);
$this->assertArrayHasKey('comments', $gist);
$this->assertArrayHasKey('created_at', $gist);
$this->assertArrayHasKey('updated_at', $gist);
$this->assertArrayHasKey('user', $gist);
$this->assertArrayHasKey('gistfile1.txt', $gist['files']);
$this->assertEquals('schacon', $gist['user']['login']);
}
}