Created
March 19, 2014 21:35
-
-
Save jubianchi/9651901 to your computer and use it in GitHub Desktop.
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
<?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