@@ -16,142 +16,146 @@ class UniqueItemsTest extends BaseTestCase
16
16
public function getInvalidTests (): array
17
17
{
18
18
return [
19
- [
20
- '[1,2,2] ' ,
21
- '{
19
+ ' Non unique integers ' => [
20
+ 'input ' => ' [1,2,2] ' ,
21
+ 'schema ' => ' {
22
22
"type":"array",
23
23
"uniqueItems": true
24
24
} '
25
25
],
26
- [
27
- '[{"a":"b"},{"a":"c"},{"a":"b"}] ' ,
28
- '{
26
+ ' Non unique objects ' => [
27
+ 'input ' => ' [{"a":"b"},{"a":"c"},{"a":"b"}] ' ,
28
+ 'schema ' => ' {
29
29
"type":"array",
30
30
"uniqueItems": true
31
31
} '
32
32
],
33
- [
34
- '[{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : true}}}] ' ,
35
- '{
33
+ ' Non unique objects - three levels deep ' => [
34
+ 'input ' => ' [{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : true}}}] ' ,
35
+ 'schema ' => ' {
36
36
"type": "array",
37
37
"uniqueItems": true
38
38
} '
39
39
],
40
- [
41
- '[1.0, 1.00, 1] ' ,
42
- '{
40
+ ' Non unique mathematical values for the number one ' => [
41
+ 'input ' => ' [1.0, 1.00, 1] ' ,
42
+ 'schema ' => ' {
43
43
"type": "array",
44
44
"uniqueItems": true
45
45
} '
46
46
],
47
- [
48
- '[["foo"], ["foo"]] ' ,
49
- '{
47
+ ' Non unique arrays ' => [
48
+ 'input ' => ' [["foo"], ["foo"]] ' ,
49
+ 'schema ' => ' {
50
50
"type": "array",
51
51
"uniqueItems": true
52
52
} '
53
53
],
54
- [
55
- '[{}, [1], true, null, {}, 1] ' ,
56
- '{
54
+ ' Non unique mix of different types ' => [
55
+ 'input ' => ' [{}, [1], true, null, {}, 1] ' ,
56
+ 'schema ' => ' {
57
57
"type": "array",
58
58
"uniqueItems": true
59
59
} '
60
+ ],
61
+ 'objects are non-unique despite key order ' => [
62
+ 'input ' => '[{"a": 1, "b": 2}, {"b": 2, "a": 1}] ' ,
63
+ 'schema ' => '{"uniqueItems": true} ' ,
60
64
]
61
65
];
62
66
}
63
67
64
68
public function getValidTests (): array
65
69
{
66
70
return [
67
- [
68
- '[1,2,3] ' ,
69
- '{
70
- "type":"array",
71
- "uniqueItems": true
71
+ ' unique integers ' => [
72
+ 'input ' => ' [1,2,3] ' ,
73
+ 'schema ' => ' {
74
+ "type":"array",
75
+ "uniqueItems": true
72
76
} '
73
77
],
74
- [
75
- '[{"foo": 12}, {"bar": false}] ' ,
76
- '{
78
+ ' unique objects ' => [
79
+ 'input ' => ' [{"foo": 12}, {"bar": false}] ' ,
80
+ 'schema ' => ' {
77
81
"type": "array",
78
82
"uniqueItems": true
79
83
} '
80
84
],
81
- [
82
- '[1, true] ' ,
83
- '{
85
+ ' Integer one and boolean true ' => [
86
+ 'input ' => ' [1, true] ' ,
87
+ 'schema ' => ' {
84
88
"type": "array",
85
89
"uniqueItems": true
86
90
} '
87
91
],
88
- [
89
- '[0, false] ' ,
90
- '{
92
+ ' Integer zero and boolean false ' => [
93
+ 'input ' => ' [0, false] ' ,
94
+ 'schema ' => ' {
91
95
"type": "array",
92
96
"uniqueItems": true
93
97
} '
94
98
],
95
- [
96
- '[{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : false}}}] ' ,
97
- '{
99
+ ' Objects with different value three levels deep ' => [
100
+ 'input ' => ' [{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : false}}}] ' ,
101
+ 'schema ' => ' {
98
102
"type": "array",
99
103
"uniqueItems": true
100
104
} '
101
105
],
102
- [
103
- '[["foo"], ["bar"]] ' ,
104
- '{
106
+ ' Array of strings ' => [
107
+ 'input ' => ' [["foo"], ["bar"]] ' ,
108
+ 'schema ' => ' {
105
109
"type": "array",
106
110
"uniqueItems": true
107
111
} '
108
112
],
109
- [
110
- '[{}, [1], true, null, 1] ' ,
111
- '{
113
+ ' Object, Array, boolean, null and integer ' => [
114
+ 'input ' => ' [{}, [1], true, null, 1] ' ,
115
+ 'schema ' => ' {
112
116
"type": "array",
113
117
"uniqueItems": true
114
118
} '
115
119
],
116
120
// below equals the invalid tests, but with uniqueItems set to false
117
- [
118
- '[1,2,2] ' ,
119
- '{
121
+ ' Non unique integers ' => [
122
+ 'input ' => ' [1,2,2] ' ,
123
+ 'schema ' => ' {
120
124
"type":"array",
121
125
"uniqueItems": false
122
126
} '
123
127
],
124
- [
125
- '[{"a":"b"},{"a":"c"},{"a":"b"}] ' ,
126
- '{
128
+ ' Non unique objects ' => [
129
+ 'input ' => ' [{"a":"b"},{"a":"c"},{"a":"b"}] ' ,
130
+ 'schema ' => ' {
127
131
"type":"array",
128
132
"uniqueItems": false
129
133
} '
130
134
],
131
- [
132
- '[{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : true}}}] ' ,
133
- '{
135
+ ' Non unique objects - three levels deep ' => [
136
+ 'input ' => ' [{"foo": {"bar" : {"baz" : true}}}, {"foo": {"bar" : {"baz" : true}}}] ' ,
137
+ 'schema ' => ' {
134
138
"type": "array",
135
139
"uniqueItems": false
136
140
} '
137
141
],
138
- [
139
- '[1.0, 1.00, 1] ' ,
140
- '{
142
+ ' Non unique mathematical values for the number one ' => [
143
+ 'input ' => ' [1.0, 1.00, 1] ' ,
144
+ 'schema ' => ' {
141
145
"type": "array",
142
146
"uniqueItems": false
143
147
} '
144
148
],
145
- [
146
- '[["foo"], ["foo"]] ' ,
147
- '{
149
+ ' Non unique arrays ' => [
150
+ 'input ' => ' [["foo"], ["foo"]] ' ,
151
+ 'schema ' => ' {
148
152
"type": "array",
149
153
"uniqueItems": false
150
154
} '
151
155
],
152
- [
153
- '[{}, [1], true, null, {}, 1] ' ,
154
- '{
156
+ ' Non unique mix of different types ' => [
157
+ 'input ' => ' [{}, [1], true, null, {}, 1] ' ,
158
+ 'schema ' => ' {
155
159
"type": "array",
156
160
"uniqueItems": false
157
161
} '
0 commit comments