Skip to content

Instantly share code, notes, and snippets.

@jubianchi
Created March 19, 2014 21:35
Show Gist options
  • Save jubianchi/9651901 to your computer and use it in GitHub Desktop.
Save jubianchi/9651901 to your computer and use it in GitHub Desktop.
<?php
namespace tests\units;
use mageekguy\atoum;
class stdClass extends atoum\test
{
public function testJsonObject()
{
$this
->json('
{
"message": "Validation Failed",
"errors": [
{
"resource": "Issue",
"field": "title",
"code": "missing_field"
}
]
}
')
->validates('
{
"title": "error message",
"type": "object",
"properties": {
"message": { "type": "string" },
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"resource": { "type": "string" },
"field": { "type": "string" },
"code": { "type": "string" }
}
},
"required": ["resource", "field", "code"]
}
},
"required": ["message", "errors"]
}
')
->json('
[
{
"message": "Validation Failed"
},
{
"message": "Internal Error"
}
]
')
->validates('
{
"title": "error message",
"type": "array",
"properties": {
"items": {
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
}
}
}
')
->object[0]->isEqualTo(json_decode('{"message": "Validation Failed"}'))
->object[1]->isEqualTo(json_decode('{"message": "Internal Error"}'))
;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment