summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php
diff options
context:
space:
mode:
authorEoleDev <root@serverpc.home>2016-03-09 15:37:42 +0100
committerEoleDev <root@serverpc.home>2016-03-09 15:37:42 +0100
commit1d3ed3af6d57316640c143002ddf80d61e6c098a (patch)
tree97ac49bc7ff0f16150aefee821da3557dc0d0644 /server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php
parentd69adc4f9d1f6019927de235ef84885c68e6e508 (diff)
parent08ea5ef31abcc4e23a39a780cacb64fa27f19194 (diff)
Merge branch 'Evan' into develop
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php')
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php
new file mode 100644
index 0000000..ea0f7c8
--- /dev/null
+++ b/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperationTest.php
@@ -0,0 +1,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());
+ }
+}