-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from schrobak/bugfix/conditional-min-max-prop…
…erties-validation Fixes min/max properties validation for non objects
- Loading branch information
Showing
2 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
tests/JsonSchema/Tests/Constraints/MinMaxPropertiesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?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; | ||
|
||
class MinMaxPropertiesTest extends BaseTestCase | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getValidTests() | ||
{ | ||
return array( | ||
array( | ||
'{ | ||
"value": {} | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "minProperties": 0} | ||
} | ||
}' | ||
), | ||
array( | ||
'{ | ||
"value": {} | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "maxProperties": 1} | ||
} | ||
}' | ||
), | ||
array( | ||
'{ | ||
"value": {} | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "minProperties": 0,"maxProperties": 1} | ||
} | ||
}' | ||
), | ||
array( | ||
'{ | ||
"value": {"foo": 1, "bar": 2} | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "minProperties": 1,"maxProperties": 2} | ||
} | ||
}' | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getInvalidTests() | ||
{ | ||
return array( | ||
array( | ||
'{ | ||
"value": 1 | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "minProperties": 1} | ||
} | ||
}' | ||
), | ||
array( | ||
'{ | ||
"value": 1 | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "maxProperties": 1} | ||
} | ||
}' | ||
), | ||
array( | ||
'{ | ||
"value": {"foo": 1, "bar": 2, "baz": 3} | ||
}', | ||
'{ | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "object", "minProperties": 1,"maxProperties": 2} | ||
} | ||
}' | ||
), | ||
); | ||
} | ||
} |