summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes.home>2016-04-16 19:10:27 +0200
committerLoic GUEGAN <loic@Manzerbredes.home>2016-04-16 19:10:27 +0200
commita3ff4d243e2ac37d4516ae56ff86985eadc00eb8 (patch)
tree32e71c42855cc46d95d9c6b74ad2c145eb9ec7eb /server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php
parent396c90f921c30de2d15d2ce52d5d1beabf8eb52d (diff)
parent31d2d0c158ad4daa3dde7a905f3c2e312c194f2e (diff)
Test
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php')
-rwxr-xr-xserver/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php102
1 files changed, 0 insertions, 102 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php
deleted file mode 100755
index 4aae8e5..0000000
--- a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-
-namespace OpenCloud\Test\Common\JsonSchema;
-
-use JsonSchema\Validator;
-use OpenCloud\Common\JsonSchema\Schema;
-use OpenCloud\Test\TestCase;
-
-class SchemaTest extends TestCase
-{
- /** @var Schema */
- private $schema;
-
- /** @var Validator */
- private $validator;
- private $body;
-
- public function setUp()
- {
- $this->body = [
- 'properties' => [
- 'foo' => (object)[],
- 'bar' => (object)[],
- 'baz' => (object)['readOnly' => true],
- ],
- ];
-
- $this->validator = $this->prophesize(Validator::class);
- $this->schema = new Schema($this->body, $this->validator->reveal());
- }
-
- public function test_it_gets_errors()
- {
- $this->validator->getErrors()
- ->shouldBeCalled()
- ->willReturn([]);
-
- $this->assertEquals([], $this->schema->getErrors());
- }
-
- public function test_it_gets_error_string()
- {
- $this->validator->getErrors()
- ->shouldBeCalled()
- ->willReturn([['property' => 'foo', 'message' => 'bar']]);
-
- $errorMsg = sprintf("Provided values do not validate. Errors:\n[foo] bar\n");
-
- $this->assertEquals($errorMsg, $this->schema->getErrorString());
- }
-
- public function test_it_gets_property_paths()
- {
- $this->assertEquals(['/foo', '/bar', '/baz'], $this->schema->getPropertyPaths());
- }
-
- public function test_it_ignores_readOnly_attrs()
- {
- $expected = (object)[
- 'foo' => true,
- 'bar' => false,
- ];
-
- $subject = (object)[
- 'foo' => true,
- 'bar' => false,
- 'baz' => true,
- ];
-
- $this->assertEquals((object)$expected, $this->schema->normalizeObject((object)$subject, []));
- }
-
- public function test_it_stocks_aliases()
- {
- $subject = (object)[
- 'fooAlias' => true,
- 'bar' => false,
- 'other' => true,
- ];
-
- $expected = (object)[
- 'foo' => true,
- 'bar' => false,
- ];
-
- $this->assertEquals($expected, $this->schema->normalizeObject($subject, ['foo' => 'fooAlias', 'bar' => 'lol']));
- }
-
- public function test_it_validates()
- {
- $this->validator->check([], (object) $this->body)->shouldBeCalled();
-
- $this->schema->validate([]);
- }
-
- public function test_it_checks_validity()
- {
- $this->validator->isValid()->shouldBeCalled()->willReturn(true);
-
- $this->schema->isValid();
- }
-} \ No newline at end of file