forked from KnpLabs/php-github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganizationTest.php
More file actions
98 lines (80 loc) · 2.37 KB
/
Copy pathOrganizationTest.php
File metadata and controls
98 lines (80 loc) · 2.37 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
<?php
namespace Github\Tests\Api;
class OrganizationTest extends TestCase
{
/**
* @test
*/
public function shouldGetAllOrganizations()
{
$expectedValue = [['login' => 'KnpLabs']];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/organizations?since=1')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->all(1));
}
/**
* @test
*/
public function shouldShowOrganization()
{
$expectedArray = ['id' => 1, 'name' => 'KnpLabs'];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/orgs/KnpLabs')
->will($this->returnValue($expectedArray));
$this->assertEquals($expectedArray, $api->show('KnpLabs'));
}
/**
* @test
*/
public function shouldUpdateOrganization()
{
$expectedArray = ['id' => 1, 'name' => 'KnpLabs'];
$api = $this->getApiMock();
$api->expects($this->once())
->method('patch')
->with('/orgs/KnpLabs', ['value' => 'toUpdate'])
->will($this->returnValue($expectedArray));
$this->assertEquals($expectedArray, $api->update('KnpLabs', ['value' => 'toUpdate']));
}
/**
* @test
*/
public function shouldGetOrganizationRepositories()
{
$expectedArray = [['id' => 1, 'username' => 'KnpLabs', 'name' => 'php-github-api']];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1])
->will($this->returnValue($expectedArray));
$this->assertEquals($expectedArray, $api->repositories('KnpLabs'));
}
/**
* @test
*/
public function shouldGetMembersApiObject()
{
$api = $this->getApiMock();
$this->assertInstanceOf(\Github\Api\Organization\Members::class, $api->members());
}
/**
* @test
*/
public function shouldGetTeamsApiObject()
{
$api = $this->getApiMock();
$this->assertInstanceOf(\Github\Api\Organization\Teams::class, $api->teams());
}
/**
* @return string
*/
protected function getApiClass()
{
return \Github\Api\Organization::class;
}
}