blob: ea0f7c84f6fe4fdb7c99291fa260bc48dfc343d7 (
plain)
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
namespace OpenCloud\Test\Common\Api;
use OpenCloud\Common\Api\Operation;
use OpenCloud\Common\Api\Parameter;
use OpenCloud\Test\Fixtures\ComputeV2Api;
class OperationTest extends \PHPUnit_Framework_TestCase
{
private $operation;
public function setUp()
{
$def = (new ComputeV2Api())->postServer();
$this->operation = new Operation($def);
}
public function test_it_reveals_whether_params_are_set_or_not()
{
$this->assertFalse($this->operation->hasParam('foo'));
$this->assertTrue($this->operation->hasParam('name'));
}
public function test_it_gets_params()
{
$this->assertInstanceOf(Parameter::class, $this->operation->getParam('name'));
}
public function test_it_validates_params()
{
$this->assertTrue($this->operation->validate([
'name' => 'foo',
'imageId' => 'bar',
'flavorId' => 'baz',
]));
}
/**
* @expectedException \Exception
*/
public function test_exceptions_are_propagated()
{
$this->assertFalse($this->operation->validate([
'name' => true,
'imageId' => 'bar',
'flavorId' => 'baz',
]));
}
/**
* @expectedException \Exception
*/
public function test_an_exception_is_thrown_when_user_does_not_provide_required_options()
{
$this->operation->validate([]);
}
/**
* @expectedException \Exception
*/
public function test_it_throws_exception_when_user_provides_undefined_options()
{
$userData = ['name' => 'new_server', 'undefined_opt' => 'bah'];
$this->operation->validate($userData);
}
public function test_it_gets_json_key()
{
$this->assertEquals('server', $this->operation->getJsonKey());
}
}
|