|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the JsonSchema package. |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +namespace JsonSchema\Tests\Constraints; |
| 11 | + |
| 12 | +class ConstTest extends BaseTestCase |
| 13 | +{ |
| 14 | + protected $schemaSpec = 'http://json-schema.org/draft-06/schema#'; |
| 15 | + protected $validateSchema = true; |
| 16 | + |
| 17 | + public function getInvalidTests() |
| 18 | + { |
| 19 | + return array( |
| 20 | + array( |
| 21 | + '{"value":"foo"}', |
| 22 | + '{ |
| 23 | + "type":"object", |
| 24 | + "properties":{ |
| 25 | + "value":{"type":"string","const":"bar"} |
| 26 | + }, |
| 27 | + "additionalProperties":false |
| 28 | + }' |
| 29 | + ), |
| 30 | + array( |
| 31 | + '{"value":5}', |
| 32 | + '{ |
| 33 | + "type":"object", |
| 34 | + "properties":{ |
| 35 | + "value":{"type":"integer","const":6} |
| 36 | + }, |
| 37 | + "additionalProperties":false |
| 38 | + }' |
| 39 | + ), |
| 40 | + array( |
| 41 | + '{"value":false}', |
| 42 | + '{ |
| 43 | + "type":"object", |
| 44 | + "properties":{ |
| 45 | + "value":{"type":"boolean","const":true} |
| 46 | + }, |
| 47 | + "additionalProperties":false |
| 48 | + }' |
| 49 | + ), |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + public function getValidTests() |
| 54 | + { |
| 55 | + return array( |
| 56 | + array( |
| 57 | + '{"value":"bar"}', |
| 58 | + '{ |
| 59 | + "type":"object", |
| 60 | + "properties":{ |
| 61 | + "value":{"type":"string","const":"bar"} |
| 62 | + }, |
| 63 | + "additionalProperties":false |
| 64 | + }' |
| 65 | + ), |
| 66 | + array( |
| 67 | + '{"value":false}', |
| 68 | + '{ |
| 69 | + "type":"object", |
| 70 | + "properties":{ |
| 71 | + "value":{"type":"boolean","const":false} |
| 72 | + }, |
| 73 | + "additionalProperties":false |
| 74 | + }' |
| 75 | + ), |
| 76 | + array( |
| 77 | + '{"value":true}', |
| 78 | + '{ |
| 79 | + "type":"object", |
| 80 | + "properties":{ |
| 81 | + "value":{"type":"boolean","const":true} |
| 82 | + }, |
| 83 | + "additionalProperties":false |
| 84 | + }' |
| 85 | + ), |
| 86 | + array( |
| 87 | + '{"value":5}', |
| 88 | + '{ |
| 89 | + "type":"object", |
| 90 | + "properties":{ |
| 91 | + "value":{"type":"integer","const":5} |
| 92 | + }, |
| 93 | + "additionalProperties":false |
| 94 | + }' |
| 95 | + ), |
| 96 | + ); |
| 97 | + } |
| 98 | +} |
0 commit comments