forked from typhonius/acquia-php-sdk-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnvironmentsTest.php
188 lines (148 loc) · 6.53 KB
/
EnvironmentsTest.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
namespace AcquiaCloudApi\Tests\Endpoints;
use AcquiaCloudApi\Tests\CloudApiTestCase;
use AcquiaCloudApi\Endpoints\Environments;
class EnvironmentsTest extends CloudApiTestCase
{
/**
* @var mixed[] $properties
*/
public $properties = [
'uuid',
'label',
'name',
'domains',
'sshUrl',
'ips',
'region',
'status',
'type',
'vcs',
'flags',
'configuration',
'links',
'platform',
'balancer',
];
public function testGetEnvironments(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/getAllEnvironments.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environments = new Environments($client);
$result = $environments->getAll('8ff6c046-ec64-4ce4-bea6-27845ec18600');
$this->assertInstanceOf('\ArrayObject', $result);
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentsResponse', $result);
$this->assertNotEmpty($result);
foreach ($result as $record) {
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentResponse', $record);
foreach ($this->properties as $property) {
$this->assertObjectHasAttribute($property, $record);
}
}
}
public function testGetEnvironment(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/getEnvironment.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->get('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');
$this->assertNotInstanceOf('\AcquiaCloudApi\Response\EnvironmentsResponse', $result);
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentResponse', $result);
foreach ($this->properties as $property) {
$this->assertObjectHasAttribute($property, $result);
}
}
public function testModifyEnvironment(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/updateEnvironment.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->update('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ['version' => '7.2']);
$requestOptions = [
'json' => [
'version' => '7.2',
],
];
$this->assertEquals($requestOptions, $this->getRequestOptions($client));
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('The environment configuration is being updated.', $result->message);
}
public function testRenameEnvironment(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/renameEnvironment.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->rename('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', 'Alpha');
$requestOptions = [
'json' => [
'label' => 'Alpha',
],
];
$this->assertEquals($requestOptions, $this->getRequestOptions($client));
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Changing environment label.', $result->message);
}
public function testCreateCDEnvironment(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/createCDEnvironment.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->create(
'24-a47ac10b-58cc-4372-a567-0e02b2c3d470',
'CD label',
'my-feature-branch',
[
"database1",
"database2"
]
);
$requestOptions = [
'json' => [
'label' => 'CD label',
'branch' => 'my-feature-branch',
'databases' => [
"database1",
"database2"
],
],
];
$this->assertEquals($requestOptions, $this->getRequestOptions($client));
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Adding an environment.', $result->message);
}
public function testDeleteCDEnvironment(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/deleteCDEnvironment.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->delete('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('The environment is being deleted.', $result->message);
}
public testEnableEmail(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/enableEmail.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->enableEmail('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Platform Email is being enabled', $result->message);
}
public testDisableEmail(): void
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/enableEmail.json');
$client = $this->getMockClient($response);
/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->disableEmail('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Platform Email is being disabled', $result->message);
}
}