Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArraysTest for array items with enum validation #559

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions tests/Constraints/ArraysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,51 @@ public function getInvalidTests()
}
}
}'
),
array( // Test array items.enum where type string fail validation if value(s) is/are not in items.enum
'{"data": ["a", "b"]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "string",
"enum": ["b", "c"]
}
}
}
}'
),
array( // Test array items.enum where type integer fail validation if value(s) is/are not in items.enum
'{"data": [1, 2]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "integer",
"enum": [2, 3]
}
}
}
}'
),
array( // Test array items.enum where type number fail validation if value(s) is/are not in items.enum
'{"data": [1.25, 2.25]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "number",
"enum": [1.25, 2]
}
}
}
}'
)
);
}
Expand Down Expand Up @@ -168,6 +213,51 @@ public function getValidTests()
}
}
}'
),
array( // Test array items.enum where type string passes validation if value(s) is/are in items.enum
'{"data": ["c", "c", "b"]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "string",
"enum": ["b", "c"]
}
}
}
}'
),
array( // Test array items.enum where type integer passes validation if value(s) is/are in items.enum
'{"data": [1, 1, 2]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "integer",
"enum": [1, 2]
}
}
}
}'
),
array( // Test array items.enum where type number passes validation if value(s) is/are in items.enum
'{"data": [1.25, 1.25, 2.25]}',
'{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "number",
"enum": [1.25, 2.25]
}
}
}
}'
)
);
}
Expand Down