summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema
diff options
context:
space:
mode:
authorEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
committerEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
commit24bb5fefbdf93ce0969b7f56cc46c459ebb82a95 (patch)
tree531fc8b774c035040774234efba780a3d4fe9242 /server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema
parent646af6fd4d14c5b5edb1372e5f68ed9bdc35b3d2 (diff)
Mise a jour et nettoyage depot
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema')
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/Fixtures/jsonPatchTests.json231
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/JsonPatchTest.php28
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php102
3 files changed, 0 insertions, 361 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/Fixtures/jsonPatchTests.json b/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/Fixtures/jsonPatchTests.json
deleted file mode 100644
index e7f3579..0000000
--- a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/Fixtures/jsonPatchTests.json
+++ /dev/null
@@ -1,231 +0,0 @@
-[
- { "comment": "empty list, empty docs",
- "doc": {},
- "patch": [],
- "expected": {} },
-
- { "comment": "empty patch list",
- "doc": {"foo": 1},
- "patch": [],
- "expected": {"foo": 1} },
-
- { "comment": "rearrangements OK?",
- "doc": {"foo": 1, "bar": 2},
- "patch": [],
- "expected": {"bar":2, "foo": 1} },
-
- { "comment": "rearrangements OK? How about one level down ... array",
- "doc": [{"foo": 1, "bar": 2}],
- "patch": [],
- "expected": [{"bar":2, "foo": 1}] },
-
- { "comment": "rearrangements OK? How about one level down...",
- "doc": {"foo":{"foo": 1, "bar": 2}},
- "patch": [],
- "expected": {"foo":{"bar":2, "foo": 1}} },
-
- { "comment": "toplevel array",
- "doc": [],
- "patch": [{"op": "add", "path": "/0", "value": "foo"}],
- "expected": ["foo"] },
-
- { "comment": "toplevel array, no change",
- "doc": ["foo"],
- "patch": [],
- "expected": ["foo"] },
-
- { "comment": "toplevel object, numeric string",
- "doc": {},
- "patch": [{"op": "add", "path": "/foo", "value": "1"}],
- "expected": {"foo":"1"} },
-
- { "comment": "toplevel object, integer",
- "doc": {},
- "patch": [{"op": "add", "path": "/foo", "value": 1}],
- "expected": {"foo":1} },
-
- { "comment": "Toplevel scalar values OK?",
- "doc": "foo",
- "patch": [{"op": "replace", "path": "", "value": "bar"}],
- "expected": "bar",
- "disabled": true },
-
- { "comment": "Add, / target",
- "doc": {},
- "patch": [ {"op": "add", "path": "/", "value":1 } ],
- "expected": {"":1} },
-
- { "comment": "Add composite value at top level",
- "doc": {"foo": 1},
- "patch": [{"op": "add", "path": "/bar", "value": [1, 2]}],
- "expected": {"foo": 1, "bar": [1, 2]} },
-
- { "comment": "Add into composite value",
- "doc": {"foo": 1, "baz": [{"qux": "hello"}]},
- "patch": [{"op": "add", "path": "/baz/0/foo", "value": "world"}],
- "expected": {"foo": 1, "baz": [{"qux": "hello", "foo": "world"}]} },
-
- { "doc": {"bar": [1, 2]},
- "patch": [{"op": "add", "path": "/bar/8", "value": "5"}],
- "error": "Out of bounds (upper)" },
-
- { "doc": {"bar": [1, 2]},
- "patch": [{"op": "add", "path": "/bar/-1", "value": "5"}],
- "error": "Out of bounds (lower)" },
-
- { "doc": {"foo": 1},
- "patch": [{"op": "add", "path": "/bar", "value": true}],
- "expected": {"foo": 1, "bar": true} },
-
- { "doc": {"foo": 1},
- "patch": [{"op": "add", "path": "/bar", "value": false}],
- "expected": {"foo": 1, "bar": false} },
-
- { "doc": {"foo": 1},
- "patch": [{"op": "add", "path": "/bar", "value": null}],
- "expected": {"foo": 1, "bar": null} },
-
- { "comment": "0 can be an array index or object element name",
- "doc": {"foo": 1},
- "patch": [{"op": "add", "path": "/0", "value": "bar"}],
- "expected": {"foo": 1, "0": "bar" } },
-
- { "doc": ["foo"],
- "patch": [{"op": "add", "path": "/1", "value": "bar"}],
- "expected": ["foo", "bar"] },
-
- { "doc": ["foo", "sil"],
- "patch": [{"op": "add", "path": "/1", "value": "bar"}],
- "expected": ["foo", "bar", "sil"] },
-
- { "doc": ["foo", "sil"],
- "patch": [{"op": "add", "path": "/0", "value": "bar"}],
- "expected": ["bar", "foo", "sil"] },
-
- { "comment": "push item to array via last index + 1",
- "doc": ["foo", "sil"],
- "patch": [{"op":"add", "path": "/2", "value": "bar"}],
- "expected": ["foo", "sil", "bar"] },
-
- { "comment": "add item to array at index > length should fail",
- "doc": ["foo", "sil"],
- "patch": [{"op":"add", "path": "/3", "value": "bar"}],
- "error": "index is greater than number of items in array" },
-
- { "doc": ["foo", "sil"],
- "patch": [{"op": "add", "path": "/bar", "value": 42}],
- "error": "Object operation on array target" },
-
- { "doc": ["foo", "sil"],
- "patch": [{"op": "add", "path": "/1", "value": ["bar", "baz"]}],
- "expected": ["foo", ["bar", "baz"], "sil"],
- "comment": "value in array add not flattened" },
-
- { "doc": {"foo": 1, "bar": [1, 2, 3, 4]},
- "patch": [{"op": "remove", "path": "/bar"}],
- "expected": {"foo": 1} },
-
- { "doc": {"foo": 1, "baz": [{"qux": "hello"}]},
- "patch": [{"op": "remove", "path": "/baz/0/qux"}],
- "expected": {"foo": 1, "baz": [{}]} },
-
- { "doc": {"foo": 1, "baz": [{"qux": "hello"}]},
- "patch": [{"op": "replace", "path": "/foo", "value": [1, 2, 3, 4]}],
- "expected": {"foo": [1, 2, 3, 4], "baz": [{"qux": "hello"}]} },
-
- { "doc": {"foo": [1, 2, 3, 4], "baz": [{"qux": "hello"}]},
- "patch": [{"op": "replace", "path": "/baz/0/qux", "value": "world"}],
- "expected": {"foo": [1, 2, 3, 4], "baz": [{"qux": "world"}]} },
-
- { "doc": ["foo"],
- "patch": [{"op": "replace", "path": "/0", "value": "bar"}],
- "expected": ["bar"] },
-
- { "doc": [""],
- "patch": [{"op": "replace", "path": "/0", "value": 0}],
- "expected": [0] },
-
- { "doc": [""],
- "patch": [{"op": "replace", "path": "/0", "value": true}],
- "expected": [true] },
-
- { "doc": [""],
- "patch": [{"op": "replace", "path": "/0", "value": false}],
- "expected": [false] },
-
- { "doc": [""],
- "patch": [{"op": "replace", "path": "/0", "value": null}],
- "expected": [null] },
-
- { "doc": ["foo", "sil"],
- "patch": [{"op": "replace", "path": "/1", "value": ["bar", "baz"]}],
- "expected": ["foo", ["bar", "baz"]],
- "comment": "value in array replace not flattened" },
-
- { "comment": "replace whole document",
- "disabled": true,
- "doc": {"foo": "bar"},
- "patch": [{"op": "replace", "path": "", "value": {"baz": "qux"}}],
- "expected": {"baz": "qux"} },
-
- { "doc": {"foo": null},
- "patch": [{"op": "replace", "path": "/foo", "value": "truthy"}],
- "expected": {"foo": "truthy"},
- "comment": "null value should be valid obj property to be replaced with something truthy" },
-
- { "doc": {"foo": null},
- "patch": [{"op": "remove", "path": "/foo"}],
- "expected": {},
- "comment": "null value should be valid obj property to be removed" },
-
- { "doc": {"foo": "bar"},
- "patch": [{"op": "replace", "path": "/foo", "value": null}],
- "expected": {"foo": null},
- "comment": "null value should still be valid obj property replace other value" },
-
- { "comment": "test remove with bad number should fail",
- "doc": {"foo": 1, "baz": [{"qux": "hello"}]},
- "patch": [{"op": "remove", "path": "/baz/1e0/qux"}],
- "error": "remove op shouldn't remove from array with bad number" },
-
- { "comment": "test remove on array",
- "doc": [1, 2, 3, 4],
- "patch": [{"op": "remove", "path": "/0"}],
- "expected": [2, 3, 4] },
-
- { "comment": "test repeated removes",
- "doc": [1, 2, 3, 4],
- "patch": [{ "op": "remove", "path": "/1" },
- { "op": "remove", "path": "/3" }],
- "expected": [1, 3] },
-
- { "comment": "test remove with bad index should fail",
- "doc": [1, 2, 3, 4],
- "patch": [{"op": "remove", "path": "/1e0"}],
- "error": "remove op shouldn't remove from array with bad number" },
-
- { "comment": "test replace with bad number should fail",
- "doc": [""],
- "patch": [{"op": "replace", "path": "/1e0", "value": false}],
- "error": "replace op shouldn't replace in array with bad number" },
-
- { "comment": "test add with bad number should fail",
- "doc": ["foo", "sil"],
- "patch": [{"op": "add", "path": "/1e0", "value": "bar"}],
- "error": "add op shouldn't add to array with bad number" },
-
- { "comment": "missing 'value' parameter to add",
- "doc": [ 1 ],
- "patch": [ { "op": "add", "path": "/-" } ],
- "error": "missing 'value' parameter" },
-
- { "comment": "missing 'value' parameter to replace",
- "doc": [ 1 ],
- "patch": [ { "op": "replace", "path": "/0" } ],
- "error": "missing 'value' parameter" },
-
- { "comment": "unrecognized op should fail",
- "doc": {"foo": 1},
- "patch": [{"op": "spam", "path": "/foo", "value": 1}],
- "error": "Unrecognized op 'spam'" }
-] \ No newline at end of file
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/JsonPatchTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/JsonPatchTest.php
deleted file mode 100644
index ee7db9e..0000000
--- a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/JsonPatchTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-namespace OpenCloud\Test\Common\JsonSchema;
-
-use OpenCloud\Common\JsonSchema\JsonPatch;
-use OpenCloud\Test\TestCase;
-
-class JsonPatchTest extends TestCase
-{
- public function testAll()
- {
- $fixtures = json_decode(file_get_contents(__DIR__ . '/Fixtures/jsonPatchTests.json'));
-
- foreach ($fixtures as $fixture) {
- if (isset($fixture->disabled) || !isset($fixture->expected)) {
- continue;
- }
-
- $actual = JsonPatch::diff($fixture->doc, $fixture->expected);
-
- $this->assertEquals(
- json_encode($fixture->patch, JSON_UNESCAPED_SLASHES),
- json_encode($actual, JSON_UNESCAPED_SLASHES),
- isset($fixture->comment) ? sprintf("Failed asserting test: %s\n", $fixture->comment) : ''
- );
- }
- }
-}
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 100644
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