forked from rackspace/php-opencloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstanceTest.php
More file actions
107 lines (104 loc) · 2.59 KB
/
InstanceTest.php
File metadata and controls
107 lines (104 loc) · 2.59 KB
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
<?php
/**
* Unit Tests
*
* @copyright 2012-2013 Rackspace Hosting, Inc.
* See COPYING for licensing information
*
* @version 1.0.0
* @author Glen Campbell <glen.campbell@rackspace.com>
*/
require_once('stub_conn.inc');
require_once('stub_service.inc');
require_once('dbservice.inc');
class MyInstanceClass extends OpenCloud\DbService\Instance {
public function CreateJson($parm=array()) {
return parent::CreateJson($parm);
}
}
class InstanceTest extends PHPUnit_Framework_TestCase
{
private
$service,
$instance;
public function __construct() {
$conn = new StubConnection('http://example.com', 'SECRET');
$this->service = new OpenCloud\DbService(
$conn, 'cloudDatabases', 'DFW', 'publicURL');
$this->instance = new MyInstanceClass(
$this->service,'INSTANCE-ID');
}
/**
* Tests
*/
public function test___construct() {
$this->assertEquals(
'MyInstanceClass',
get_class($this->instance));
}
/**
* @expectedException OpenCloud\DbService\InstanceUpdateError
*/
public function testUpdate() {
$this->instance->Update();
}
public function testRestart() {
$this->assertEquals(
200,
$this->instance->Restart()->HttpStatus());
}
public function testResize() {
$flavor = $this->service->Flavor(2);
$this->assertEquals(
200,
$this->instance->Resize($flavor)->HttpStatus());
}
public function testResizeVolume() {
$this->assertEquals(
200,
$this->instance->ResizeVolume(4)->HttpStatus());
}
public function testEnableRootUser() {
$this->assertEquals(
'OpenCloud\DbService\User',
get_class($this->instance->EnableRootUser()));
}
public function testIsRootEnabled() {
$this->assertEquals(
FALSE,
$this->instance->IsRootEnabled());
}
public function testDatabase() {
$this->assertEquals(
'OpenCloud\DbService\Database',
get_class($this->instance->Database('FOO')));
}
public function testUser() {
// user with 2 databases
$u = $this->instance->User('BAR',array('FOO','BAR'));
$this->assertEquals(
'OpenCloud\DbService\User',
get_class($u));
// make sure it has 2 databases
$this->assertEquals(
2,
count($u->databases));
}
public function testDatabaseList() {
$this->assertEquals(
'OpenCloud\Collection',
get_class($this->instance->DatabaseList()));
}
public function testUserList() {
$this->assertEquals(
'OpenCloud\Collection',
get_class($this->instance->UserList()));
}
public function testCreateJson() {
$this->instance->name = 'FOOBAR';
$obj = $this->instance->CreateJson();
$this->assertEquals(
'FOOBAR',
$obj->instance->name);
}
}