1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Tests\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Tests\CloudApiTestCase; |
6
|
|
|
use AcquiaCloudApi\Endpoints\Environments; |
7
|
|
|
|
8
|
|
|
class EnvironmentsTest extends CloudApiTestCase |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
public $properties = [ |
12
|
|
|
'uuid', |
13
|
|
|
'label', |
14
|
|
|
'name', |
15
|
|
|
'domains', |
16
|
|
|
'sshUrl', |
17
|
|
|
'ips', |
18
|
|
|
'region', |
19
|
|
|
'status', |
20
|
|
|
'type', |
21
|
|
|
'vcs', |
22
|
|
|
'flags', |
23
|
|
|
'configuration', |
24
|
|
|
'links' |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
public function testGetEnvironments() |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/getAllEnvironments.json'); |
31
|
|
|
$client = $this->getMockClient($response); |
32
|
|
|
|
33
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
34
|
|
|
$environments = new Environments($client); |
35
|
|
|
$result = $environments->getAll('8ff6c046-ec64-4ce4-bea6-27845ec18600'); |
36
|
|
|
|
37
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
38
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentsResponse', $result); |
39
|
|
|
|
40
|
|
|
foreach ($result as $record) { |
41
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentResponse', $record); |
42
|
|
|
|
43
|
|
|
foreach ($this->properties as $property) { |
44
|
|
|
$this->assertObjectHasAttribute($property, $record); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testGetEnvironment() |
50
|
|
|
{ |
51
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/getEnvironment.json'); |
52
|
|
|
|
53
|
|
|
$client = $this->getMockClient($response); |
54
|
|
|
|
55
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
56
|
|
|
$environment = new Environments($client); |
57
|
|
|
$result = $environment->get('24-a47ac10b-58cc-4372-a567-0e02b2c3d470'); |
58
|
|
|
|
59
|
|
|
$this->assertNotInstanceOf('\AcquiaCloudApi\Response\EnvironmentsResponse', $result); |
60
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentResponse', $result); |
61
|
|
|
|
62
|
|
|
foreach ($this->properties as $property) { |
63
|
|
|
$this->assertObjectHasAttribute($property, $result); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testModifyEnvironment() |
68
|
|
|
{ |
69
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/updateEnvironment.json'); |
70
|
|
|
|
71
|
|
|
$client = $this->getMockClient($response); |
72
|
|
|
|
73
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
74
|
|
|
$environment = new Environments($client); |
75
|
|
|
$result = $environment->update('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ['version' => '7.2']); |
76
|
|
|
|
77
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
78
|
|
|
|
79
|
|
|
$this->assertEquals('The environment configuration is being updated.', $result->message); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testRenameEnvironment() |
83
|
|
|
{ |
84
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/renameEnvironment.json'); |
85
|
|
|
|
86
|
|
|
$client = $this->getMockClient($response); |
87
|
|
|
|
88
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
89
|
|
|
$environment = new Environments($client); |
90
|
|
|
$result = $environment->rename('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', 'Alpha'); |
91
|
|
|
|
92
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
93
|
|
|
|
94
|
|
|
$this->assertEquals('Changing environment label.', $result->message); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function testCreateCDEnvironment() |
98
|
|
|
{ |
99
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/createCDEnvironment.json'); |
100
|
|
|
|
101
|
|
|
$client = $this->getMockClient($response); |
102
|
|
|
|
103
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
104
|
|
|
$environment = new Environments($client); |
105
|
|
|
$result = $environment->create( |
106
|
|
|
'24-a47ac10b-58cc-4372-a567-0e02b2c3d470', |
107
|
|
|
'CD label', |
108
|
|
|
'my-feature-branch', |
109
|
|
|
[ |
110
|
|
|
"database1", |
111
|
|
|
"database2" |
112
|
|
|
] |
113
|
|
|
); |
114
|
|
|
|
115
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
116
|
|
|
|
117
|
|
|
$this->assertEquals('Adding an environment.', $result->message); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function testDeleteCDEnvironment() |
121
|
|
|
{ |
122
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/deleteCDEnvironment.json'); |
123
|
|
|
|
124
|
|
|
$client = $this->getMockClient($response); |
125
|
|
|
|
126
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
127
|
|
|
$environment = new Environments($client); |
128
|
|
|
$result = $environment->delete('24-a47ac10b-58cc-4372-a567-0e02b2c3d470'); |
129
|
|
|
|
130
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
131
|
|
|
|
132
|
|
|
$this->assertEquals('The environment is being deleted.', $result->message); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|