1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Detain\Cloudlinux\Tests; |
4
|
|
|
|
5
|
|
|
use Detain\Cloudlinux\Cloudlinux; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Cloudlinux Test Suite |
10
|
|
|
*/ |
11
|
|
|
class CloudlinuxTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var Cloudlinux |
15
|
|
|
*/ |
16
|
|
|
protected $object; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Sets up the fixture, for example, opens a network connection. |
20
|
|
|
* This method is called before a test is executed. |
21
|
|
|
*/ |
22
|
|
|
protected function setUp() |
23
|
|
|
{ |
24
|
|
|
if (file_exists(__DIR__.'/.env')) { |
25
|
|
|
$dotenv = new Dotenv\Dotenv(__DIR__); |
26
|
|
|
$dotenv->load(); |
27
|
|
|
} |
28
|
|
|
$this->object = new Cloudlinux(getenv('CLOUDLINUX_LOGIN'), getenv('CLOUDLINUX_KEY')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Tears down the fixture, for example, closes a network connection. |
33
|
|
|
* This method is called after a test is executed. |
34
|
|
|
*/ |
35
|
|
|
protected function tearDown() |
36
|
|
|
{ |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testTestEnvironment() { |
40
|
|
|
$CLOUDLINUX_LOGIN = getenv('CLOUDLINUX_LOGIN'); |
41
|
|
|
$this->assertNotEmpty($CLOUDLINUX_LOGIN, 'No environment variables! Copy .env.example -> .env and fill out your account details.'); |
42
|
|
|
$this->assertInstanceOf('\Detain\Cloudlinux\Cloudlinux', $this->object); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::getcurlpage |
47
|
|
|
*/ |
48
|
|
|
public function testGetcurlpage() |
49
|
|
|
{ |
50
|
|
|
$this->assertRegExp('/<html/i', $this->object->getcurlpage('https://cln.cloudlinux.com')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::status |
55
|
|
|
*/ |
56
|
|
|
public function testStatus() |
57
|
|
|
{ |
58
|
|
|
//Array( [success] => 1 [data] => Array([db_rhn_online] => 1 [db_clweb_connected] => 1 [db_clweb_online] => 1 [ip_server_reg] => 1 [xmlrpc] => 1 [rhn_overloaded] => [db_rhn_connected] => 1 ) ) |
|
|
|
|
59
|
|
|
// Remove the following lines when you implement this test. |
60
|
|
|
$status = $this->object->status(); |
61
|
|
|
$this->assertTrue(is_array($status)); |
62
|
|
|
$this->assertArrayHasKey('success', $status, 'Missing success status in response'); |
63
|
|
|
$this->assertArrayHasKey('data', $status, 'Missing data in response'); |
64
|
|
|
$this->assertEquals($status['data']['ip_server_reg'], 1, 'IP Server is not up'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::availability |
69
|
|
|
* @todo Implement testAvailability(). |
70
|
|
|
*/ |
71
|
|
|
public function testAvailability() |
72
|
|
|
{ |
73
|
|
|
// Remove the following lines when you implement this test. |
74
|
|
|
$this->markTestIncomplete( |
75
|
|
|
'This test has not been implemented yet.' |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::check |
81
|
|
|
* @todo Implement testCheck(). |
82
|
|
|
*/ |
83
|
|
|
public function testCheck() |
84
|
|
|
{ |
85
|
|
|
// Remove the following lines when you implement this test. |
86
|
|
|
$this->markTestIncomplete( |
87
|
|
|
'This test has not been implemented yet.' |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::register |
93
|
|
|
* @todo Implement testRegister(). |
94
|
|
|
*/ |
95
|
|
|
public function testRegister() |
96
|
|
|
{ |
97
|
|
|
// Remove the following lines when you implement this test. |
98
|
|
|
$this->markTestIncomplete( |
99
|
|
|
'This test has not been implemented yet.' |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::rest_remove |
105
|
|
|
* @todo Implement testRest_remove(). |
106
|
|
|
*/ |
107
|
|
|
public function testRest_remove() |
108
|
|
|
{ |
109
|
|
|
// Remove the following lines when you implement this test. |
110
|
|
|
$this->markTestIncomplete( |
111
|
|
|
'This test has not been implemented yet.' |
112
|
|
|
); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::remove |
117
|
|
|
* @todo Implement testRemove(). |
118
|
|
|
*/ |
119
|
|
|
public function testRemove() |
120
|
|
|
{ |
121
|
|
|
// Remove the following lines when you implement this test. |
122
|
|
|
$this->markTestIncomplete( |
123
|
|
|
'This test has not been implemented yet.' |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::rest_list |
129
|
|
|
* @todo Implement testRest_list(). |
130
|
|
|
*/ |
131
|
|
|
public function testRest_list() |
132
|
|
|
{ |
133
|
|
|
// Remove the following lines when you implement this test. |
134
|
|
|
$this->markTestIncomplete( |
135
|
|
|
'This test has not been implemented yet.' |
136
|
|
|
); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::authToken |
141
|
|
|
* @todo Implement testAuthToken(). |
142
|
|
|
*/ |
143
|
|
|
public function testAuthToken() |
144
|
|
|
{ |
145
|
|
|
// Remove the following lines when you implement this test. |
146
|
|
|
$this->markTestIncomplete( |
147
|
|
|
'This test has not been implemented yet.' |
148
|
|
|
); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::license |
153
|
|
|
* @todo Implement testLicense(). |
154
|
|
|
*/ |
155
|
|
|
public function testLicense() |
156
|
|
|
{ |
157
|
|
|
// Remove the following lines when you implement this test. |
158
|
|
|
$this->markTestIncomplete( |
159
|
|
|
'This test has not been implemented yet.' |
160
|
|
|
); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::remove_license |
165
|
|
|
* @todo Implement testRemove_license(). |
166
|
|
|
*/ |
167
|
|
|
public function testRemove_license() |
168
|
|
|
{ |
169
|
|
|
// Remove the following lines when you implement this test. |
170
|
|
|
$this->markTestIncomplete( |
171
|
|
|
'This test has not been implemented yet.' |
172
|
|
|
); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::isLicensed |
177
|
|
|
* @todo Implement testIs_licensed(). |
178
|
|
|
*/ |
179
|
|
|
public function testIs_licensed() |
180
|
|
|
{ |
181
|
|
|
// Remove the following lines when you implement this test. |
182
|
|
|
$this->markTestIncomplete( |
183
|
|
|
'This test has not been implemented yet.' |
184
|
|
|
); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::xmlIsLicensed |
189
|
|
|
* @todo Implement testXml_isLicensed(). |
190
|
|
|
*/ |
191
|
|
|
public function testXml_isLicensed() |
192
|
|
|
{ |
193
|
|
|
// Remove the following lines when you implement this test. |
194
|
|
|
$this->markTestIncomplete( |
195
|
|
|
'This test has not been implemented yet.' |
196
|
|
|
); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::licenseList |
201
|
|
|
* @todo Implement testLicense_list(). |
202
|
|
|
*/ |
203
|
|
|
public function testLicense_list() |
204
|
|
|
{ |
205
|
|
|
// Remove the following lines when you implement this test. |
206
|
|
|
$this->markTestIncomplete( |
207
|
|
|
'This test has not been implemented yet.' |
208
|
|
|
); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* @covers Detain\Cloudlinux\Cloudlinux::reconcile |
213
|
|
|
* @todo Implement testReconcile(). |
214
|
|
|
*/ |
215
|
|
|
public function testReconcile() |
216
|
|
|
{ |
217
|
|
|
// Remove the following lines when you implement this test. |
218
|
|
|
$this->markTestIncomplete( |
219
|
|
|
'This test has not been implemented yet.' |
220
|
|
|
); |
221
|
|
|
} |
222
|
|
|
} |
223
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.