Files
Darek Slusarczyk cc5bfacf66 WL#13014 DevAPI: Add schema validation to create collection
- add support for JSON parse errors
- add schema_validation/parse_error.phpt
- clean ups
2020-03-23 13:27:17 +01:00

45 lines
791 B
PHP

--TEST--
mysqlx schema validation simple
--SKIPIF--
--FILE--
<?php
require(__DIR__."/../connect.inc");
$session = create_test_session(true);
$schema = $session->getSchema($db);
$coll = $schema->createCollection("mycollection", '{
"validation": {
"level": "strict",
"schema": {
"id": "http://json-schema.org/geo",
"description": "A geographical coordinate",
"type": "object",
"properties": {
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
}
},
"required": ["latitude", "longitude"]
}
}
}');
$coll->add('{"latitude": 10, "longitude": 20}')->execute();
expect_eq($coll->count(), 1);
verify_expectations();
print "done!\n";
?>
--CLEAN--
<?php
require(__DIR__."/../connect.inc");
clean_test_db();
?>
--EXPECTF--
done!%A