1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Tests\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Tests\CloudApiTestCase; |
6
|
|
|
use AcquiaCloudApi\Endpoints\Organizations; |
7
|
|
|
|
8
|
|
|
class MembersTest extends CloudApiTestCase |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
public $properties = [ |
12
|
|
|
'uuid', |
13
|
|
|
'teams', |
14
|
|
|
'first_name', |
15
|
|
|
'last_name', |
16
|
|
|
'mail', |
17
|
|
|
'picture_url', |
18
|
|
|
'username', |
19
|
|
|
'links' |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
public function testGetOrganizationMembers() |
23
|
|
|
{ |
24
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getMembers.json'); |
25
|
|
|
$client = $this->getMockClient($response); |
26
|
|
|
|
27
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
28
|
|
|
$organization = new Organizations($client); |
29
|
|
|
$result = $organization->getMembers('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); |
30
|
|
|
|
31
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
32
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result); |
33
|
|
|
|
34
|
|
|
foreach ($result as $record) { |
35
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $record); |
36
|
|
|
|
37
|
|
|
foreach ($this->properties as $property) { |
38
|
|
|
$this->assertObjectHasAttribute($property, $record); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testGetOrganizationMember() |
44
|
|
|
{ |
45
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getMember.json'); |
46
|
|
|
$client = $this->getMockClient($response); |
47
|
|
|
|
48
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
49
|
|
|
$organization = new Organizations($client); |
50
|
|
|
$result = $organization->getMember( |
51
|
|
|
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', |
52
|
|
|
'f2daa9cc-e5a0-4036-a5c8-f96e336c62b5' |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$this->assertNotInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result); |
56
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $result); |
57
|
|
|
|
58
|
|
|
foreach ($this->properties as $property) { |
59
|
|
|
$this->assertObjectHasAttribute($property, $result); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testGetOrganizationAdmins() |
64
|
|
|
{ |
65
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getAdmins.json'); |
66
|
|
|
$client = $this->getMockClient($response); |
67
|
|
|
|
68
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
69
|
|
|
$organization = new Organizations($client); |
70
|
|
|
$result = $organization->getAdmins('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851'); |
71
|
|
|
|
72
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
73
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result); |
74
|
|
|
|
75
|
|
|
foreach ($result as $record) { |
76
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $record); |
77
|
|
|
|
78
|
|
|
foreach ($this->properties as $property) { |
79
|
|
|
$this->assertObjectHasAttribute($property, $record); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function testGetOrganizationAdmin() |
85
|
|
|
{ |
86
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/getAdmin.json'); |
87
|
|
|
$client = $this->getMockClient($response); |
88
|
|
|
|
89
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
90
|
|
|
$organization = new Organizations($client); |
91
|
|
|
$result = $organization->getAdmin( |
92
|
|
|
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', |
93
|
|
|
'f2daa9cc-e5a0-4036-a5c8-f96e336c62b5' |
94
|
|
|
); |
95
|
|
|
|
96
|
|
|
$this->assertNotInstanceOf('\AcquiaCloudApi\Response\MembersResponse', $result); |
97
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MemberResponse', $result); |
98
|
|
|
|
99
|
|
|
foreach ($this->properties as $property) { |
100
|
|
|
$this->assertObjectHasAttribute($property, $result); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function testMemberDelete() |
105
|
|
|
{ |
106
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Organizations/deleteMember.json'); |
107
|
|
|
$client = $this->getMockClient($response); |
108
|
|
|
|
109
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
110
|
|
|
$organization = new Organizations($client); |
111
|
|
|
$result = $organization->deleteMember( |
112
|
|
|
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', |
113
|
|
|
'14-0c7e79ab-1c4a-424e-8446-76ae8be7e851' |
114
|
|
|
); |
115
|
|
|
|
116
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
117
|
|
|
|
118
|
|
|
$this->assertEquals("Organization member removed.", $result->message); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|