Sanpi\Behatch\Json\JsonInspector::validate PHP Метод

validate() публичный Метод

public validate ( Json $json, JsonSchema $schema )
$json Json
$schema JsonSchema
    public function validate(Json $json, JsonSchema $schema)
    {
        return $schema->resolve(new RefResolver(new UriRetriever()))->validate($json, new Validator());
    }

Usage Example

Пример #1
0
 public function test_should_valid_json_through_its_schema()
 {
     $this->given($json = new \mock\Sanpi\Behatch\Json\Json('{}'), $schema = new \mock\Sanpi\Behatch\Json\JsonSchema('{}'), $schema->getMockController()->resolve = $schema, $schema->getMockController()->validate = 'foobar', $inspector = new TestedClass('foo'))->when($result = $inspector->validate($json, $schema))->variable($result)->isEqualTo('foobar')->mock($schema)->call('resolve')->withArguments(new RefResolver(new UriRetriever()))->once()->call('validate')->withArguments($json, new Validator())->once();
 }