1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Tests\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Tests\CloudApiTestCase; |
6
|
|
|
use AcquiaCloudApi\Endpoints\Domains; |
7
|
|
|
|
8
|
|
|
class DomainsTest extends CloudApiTestCase |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
public $properties = [ |
12
|
|
|
'hostname', |
13
|
|
|
'flags', |
14
|
|
|
'environment', |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
public $metricsProperties = [ |
18
|
|
|
'metric', |
19
|
|
|
'datapoints', |
20
|
|
|
'last_data_at', |
21
|
|
|
'metadata', |
22
|
|
|
'links' |
23
|
|
|
]; |
24
|
|
|
|
25
|
|
|
public function testGetDomains() |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/getAllDomains.json'); |
29
|
|
|
$client = $this->getMockClient($response); |
30
|
|
|
|
31
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
32
|
|
|
$domain = new Domains($client); |
33
|
|
|
$result = $domain->getAll('185f07c7-9c4f-407b-8968-67892ebcb38a'); |
34
|
|
|
|
35
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
36
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\DomainsResponse', $result); |
37
|
|
|
|
38
|
|
|
foreach ($result as $record) { |
39
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\DomainResponse', $record); |
40
|
|
|
|
41
|
|
|
foreach ($this->properties as $property) { |
42
|
|
|
$this->assertObjectHasAttribute($property, $record); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetDomain() |
48
|
|
|
{ |
49
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/getDomain.json'); |
50
|
|
|
$client = $this->getMockClient($response); |
51
|
|
|
|
52
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
53
|
|
|
$domain = new Domains($client); |
54
|
|
|
$result = $domain->get('185f07c7-9c4f-407b-8968-67892ebcb38a', 'example.com'); |
55
|
|
|
|
56
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\DomainResponse', $result); |
57
|
|
|
$this->assertEquals('example.com', $result->hostname); |
58
|
|
|
|
59
|
|
|
foreach ($this->properties as $property) { |
60
|
|
|
$this->assertObjectHasAttribute($property, $result); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testDomainAdd() |
65
|
|
|
{ |
66
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/createDomain.json'); |
67
|
|
|
$client = $this->getMockClient($response); |
68
|
|
|
|
69
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
70
|
|
|
$domain = new Domains($client); |
71
|
|
|
$result = $domain->create('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'new-domain.com'); |
72
|
|
|
|
73
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
74
|
|
|
$this->assertEquals("Adding domain example.com", $result->message); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function testDomainDelete() |
78
|
|
|
{ |
79
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/deleteDomain.json'); |
80
|
|
|
$client = $this->getMockClient($response); |
81
|
|
|
|
82
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
83
|
|
|
$domain = new Domains($client); |
84
|
|
|
$result = $domain->delete('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'deleted-domain.com'); |
85
|
|
|
|
86
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); |
87
|
|
|
$this->assertEquals("Removing the domain example.com", $result->message); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testDomainStatus() |
91
|
|
|
{ |
92
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/getDomainStatus.json'); |
93
|
|
|
$client = $this->getMockClient($response); |
94
|
|
|
|
95
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
96
|
|
|
$domain = new Domains($client); |
97
|
|
|
$result = $domain->status('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'domain.com'); |
98
|
|
|
|
99
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\DomainResponse', $result); |
100
|
|
|
$this->assertEquals('example.com', $result->hostname); |
101
|
|
|
|
102
|
|
|
foreach ($this->properties as $property) { |
103
|
|
|
$this->assertObjectHasAttribute($property, $result); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function testDomainMetrics() |
108
|
|
|
{ |
109
|
|
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Domains/getDomainMetrics.json'); |
110
|
|
|
$client = $this->getMockClient($response); |
111
|
|
|
|
112
|
|
|
/** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ |
113
|
|
|
$domain = new Domains($client); |
114
|
|
|
$result = $domain->metrics('14-0c7e79ab-1c4a-424e-8446-76ae8be7e851', 'example.com'); |
115
|
|
|
|
116
|
|
|
$this->assertInstanceOf('\ArrayObject', $result); |
117
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MetricsResponse', $result); |
118
|
|
|
|
119
|
|
|
foreach ($result as $record) { |
120
|
|
|
$this->assertInstanceOf('\AcquiaCloudApi\Response\MetricResponse', $record); |
121
|
|
|
|
122
|
|
|
foreach ($this->metricsProperties as $property) { |
123
|
|
|
$this->assertObjectHasAttribute($property, $record); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|