-
-
Notifications
You must be signed in to change notification settings - Fork 600
/
Copy pathMembershipsTest.php
96 lines (84 loc) · 2.26 KB
/
MembershipsTest.php
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
<?php
namespace Github\Tests\Api\CurrentUser;
use Github\Tests\Api\TestCase;
class MembershipsTest extends TestCase
{
/**
* @test
*/
public function shouldGetMemberships()
{
$expectedValue = [
[
'organization' => [
'login' => 'octocat',
'id' => 1,
],
'user' => [
'login' => 'defunkt',
'id' => 3,
],
],
[
'organization' => [
'login' => 'invitocat',
'id' => 2,
],
'user' => [
'login' => 'defunkt',
'id' => 3,
],
],
];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/user/memberships/orgs')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->all());
}
/**
* @test
*/
public function shouldGetMembershipsForOrganization()
{
$expectedValue = [
'organization' => [
'login' => 'invitocat',
'id' => 2,
],
'user' => [
'login' => 'defunkt',
'id' => 3,
],
];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/user/memberships/orgs/invitocat')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->organization('invitocat'));
}
/**
* @test
*/
public function shouldEditMembershipsForOrganization()
{
$expectedValue = [
'state' => 'active',
];
$api = $this->getApiMock();
$api->expects($this->once())
->method('patch')
->with('/user/memberships/orgs/invitocat')
->will($this->returnValue($expectedValue));
$this->assertEquals($expectedValue, $api->edit('invitocat'));
}
/**
* @return string
*/
protected function getApiClass()
{
return \Github\Api\CurrentUser\Memberships::class;
}
}