1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Tests\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Tests\CloudApiTestCase; |
6
|
|
|
use AcquiaCloudApi\Endpoints\Organizations; |
7
|
|
|
use AcquiaCloudApi\Endpoints\Roles; |
8
|
|
|
|
9
|
|
|
class RolesTest extends CloudApiTestCase |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
public $properties = [ |
13
|
|
|
'uuid', |
14
|
|
|
'name', |
15
|
|
|
'description', |
16
|
|
|
'last_edited', |
17
|
|
|
'permissions', |
18
|
|
|
]; |
19
|
|
|
|
20
|
|
|
public function testGetRole() |
21
|
|
|
{ |
22
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Roles/getRole.json'); |
23
|
|
|
$client = $this->getMockClient($response); |
24
|
|
|
|
25
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
26
|
|
|
$roles = new Roles($client); |
27
|
|
|
$result = $roles->get('8ff6c046-ec64-4ce4-bea6-27845ec18600'); |
28
|
|
|
|
29
|
|
|
$this->assertNotInstanceOf('\AcquiaCloudApi\Response\RolesResponse', $result); |
30
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\RoleResponse', $result); |
31
|
|
|
|
32
|
|
|
foreach ($this->properties as $property) { |
33
|
|
|
$this->assertObjectHasAttribute($property, $result); |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testGetRoles() |
38
|
|
|
{ |
39
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Roles/getAllRoles.json'); |
40
|
|
|
$client = $this->getMockClient($response); |
41
|
|
|
|
42
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
43
|
|
|
$roles = new Roles($client); |
44
|
|
|
$result = $roles->getAll('8ff6c046-ec64-4ce4-bea6-27845ec18600'); |
45
|
|
|
|
46
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
47
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\RolesResponse', $result); |
48
|
|
|
|
49
|
|
|
foreach ($result as $record) { |
50
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\RoleResponse', $record); |
51
|
|
|
|
52
|
|
|
foreach ($this->properties as $property) { |
53
|
|
|
$this->assertObjectHasAttribute($property, $record); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testCreateRole() |
59
|
|
|
{ |
60
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Roles/createRole.json'); |
61
|
|
|
$client = $this->getMockClient($response); |
62
|
|
|
|
63
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
64
|
|
|
$roles = new Roles($client); |
65
|
|
|
$result = $roles->create( |
66
|
|
|
'8ff6c046-ec64-4ce4-bea6-27845ec18600', |
67
|
|
|
'My new role', |
68
|
|
|
['access cloud api', 'pull from prod'], |
69
|
|
|
'My new role description' |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
73
|
|
|
$this->assertEquals('Role created.', $result->message); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testDeleteRole() |
77
|
|
|
{ |
78
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Roles/deleteRole.json'); |
79
|
|
|
$client = $this->getMockClient($response); |
80
|
|
|
|
81
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
82
|
|
|
$role = new Roles($client); |
83
|
|
|
$result = $role->delete('r47ac10b-58cc-4372-a567-0e02b2c3d470'); |
84
|
|
|
|
85
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
86
|
|
|
$this->assertEquals('Deleted role.', $result->message); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function testUpdateRole() |
90
|
|
|
{ |
91
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Roles/updateRole.json'); |
92
|
|
|
$client = $this->getMockClient($response); |
93
|
|
|
|
94
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
95
|
|
|
$role = new Roles($client); |
96
|
|
|
$result = $role->update('r47ac10b-58cc-4372-a567-0e02b2c3d470', ['pull from prod']); |
97
|
|
|
|
98
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
99
|
|
|
$this->assertEquals('Updating role.', $result->message); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|