Inheritance: extends Json
Esempio n. 1
0
    public function test_should_throw_exception_for_incorrect_json()
    {
        $this->given($schema = new TestedClass('{}'), $json = new \Sanpi\Behatch\Json\Json('{}'), $validator = new \mock\JsonSchema\Validator(), $validator->getMockController()->check = false, $validator->getMockController()->getErrors = array(array('property' => 'foo', 'message' => 'invalid'), array('property' => 'bar', 'message' => 'not found')))->exception(function () use($schema, $json, $validator) {
            $schema->validate($json, $validator);
        })->hasMessage(<<<ERROR
JSON does not validate. Violations:
  - [foo] invalid
  - [bar] not found

ERROR
);
    }
Esempio n. 2
0
 public function validate(Json $json, JsonSchema $schema)
 {
     return $schema->resolve(new RefResolver(new UriRetriever()))->validate($json, new Validator());
 }