forked from rackspace/php-opencloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageTest.php
More file actions
74 lines (71 loc) · 1.8 KB
/
ImageTest.php
File metadata and controls
74 lines (71 loc) · 1.8 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
<?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('image.inc');
require_once('compute.inc');
require_once('stub_conn.inc');
class ImageStub extends OpenCloud\Compute\Image {
}
class ImageTest extends PHPUnit_Framework_TestCase
{
private
$compute;
public function __construct() {
$conn = new StubConnection('http://example.com','SECRET');
$this->compute = new OpenCloud\Compute($conn,
'cloudServersOpenStack','DFW','publicURL');
}
/**
* Tests
*/
/**
* @expectedException OpenCloud\InstanceNotFound
*/
public function test___construct() {
$image = new OpenCloud\Compute\Image($this->compute, 'XXXXXX');
}
public function test_good_image() {
$image = new OpenCloud\Compute\Image($this->compute);
$this->assertEquals(NULL, $image->status);
$this->assertEquals('OpenCloud\Metadata', get_class($image->metadata));
}
/**
* @expectedException OpenCloud\JsonError
*/
public function test_bad_json() {
$image = new OpenCloud\Compute\Image($this->compute, 'BADJSON');
}
/**
* @expectedException OpenCloud\EmptyResponseError
*/
public function test_empty_json() {
$image = new OpenCloud\Compute\Image($this->compute, 'EMPTY');
}
/**
* @expectedException OpenCloud\CreateError
*/
public function testCreate() {
$image = $this->compute->Image();
$image->Create();
}
/**
* @expectedException OpenCloud\UpdateError
*/
public function testUpdate() {
$image = $this->compute->Image();
$image->Update();
}
public function testJsonName() {
$x = new ImageStub($this->compute);
$this->assertEquals(
'image',
$x->JsonName());
}
}