mirror of
https://github.com/justinrainbow/json-schema.git
synced 2025-05-02 04:18:09 +02:00
description for failing tests. Flatten directory structure Use "test.json / suite description / test case description" notation in data provider to allow a readable test output Skip Draft3Test / Draft4Test tests which are not passing Add some comment to skipped tests
189 lines
5.0 KiB
PHP
189 lines
5.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the JsonSchema package.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace JsonSchema\Tests\Constraints;
|
|
|
|
use JsonSchema\Validator;
|
|
|
|
class AdditionalPropertiesTest extends BaseTestCase
|
|
{
|
|
public function getInvalidTests()
|
|
{
|
|
return array(
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"patternProp":"3",
|
|
"additionalProp":"2"
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"patternProperties":{
|
|
"^patternProp$":{"type":"string"}
|
|
},
|
|
"additionalProperties": false
|
|
}',
|
|
null,
|
|
array(
|
|
array(
|
|
'property' => '',
|
|
'message' => 'The property additionalProp is not defined and the definition does not allow additional properties',
|
|
'constraint' => 'additionalProp',
|
|
)
|
|
)
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":"2"
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"additionalProperties": false
|
|
}',
|
|
Validator::CHECK_MODE_TYPE_CAST
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":2
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"additionalProperties": {"type":"string"}
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":2
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"additionalProperties": {"type":"string"}
|
|
}',
|
|
Validator::CHECK_MODE_TYPE_CAST
|
|
),
|
|
array(
|
|
'{
|
|
"prop1": "a",
|
|
"prop2": "b"
|
|
}',
|
|
'{
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "boolean"
|
|
}
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop1": "a",
|
|
"prop2": "b"
|
|
}',
|
|
'{
|
|
"type": "object",
|
|
"additionalProperties": false
|
|
}'
|
|
),
|
|
);
|
|
}
|
|
|
|
public function getValidTests()
|
|
{
|
|
return array(
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":"2"
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
}
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":"2"
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
}
|
|
}',
|
|
Validator::CHECK_MODE_TYPE_CAST
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":"2"
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"additionalProperties": {"type":"string"}
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop":"1",
|
|
"additionalProp":[]
|
|
}',
|
|
'{
|
|
"type":"object",
|
|
"properties":{
|
|
"prop":{"type":"string"}
|
|
},
|
|
"additionalProperties": true
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop1": "a",
|
|
"prop2": "b"
|
|
}',
|
|
'{
|
|
"type": "object",
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
}
|
|
}'
|
|
),
|
|
array(
|
|
'{
|
|
"prop1": "a",
|
|
"prop2": "b"
|
|
}',
|
|
'{
|
|
"type": "object",
|
|
"additionalProperties": true
|
|
}'
|
|
),
|
|
);
|
|
}
|
|
}
|