public function test_should_throw_exception_for_incorrect_json() { $this->given($sut = new SUT('schema.json'), $json = new \Rezzza\RestApiBehatExtension\Json\Json('{}'), $validator = new \mock\JsonSchema\Validator(), $validator->getMockController()->check = false, $validator->getMockController()->getErrors = [['property' => 'foo', 'message' => 'invalid'], ['property' => 'bar', 'message' => 'not found']], $this->mockGenerator->orphanize('__construct'), $refResolver = new \mock\JsonSchema\RefResolver(), $refResolver->getMockController()->resolve = 'mySchema')->exception(function () use($sut, $json, $validator, $refResolver) { $sut->validate($json, $validator, $refResolver); })->hasMessage(<<<ERROR JSON does not validate. Violations: - [foo] invalid - [bar] not found ERROR ); }
public function test_should_resolve_with_uri() { $this->given($schema = $this->newTestedInstance('{}', 'file://test'), $this->mockGenerator->orphanize('__construct'), $resolver = new \mock\JsonSchema\RefResolver(), $resolver->getMockController()->resolve = true)->when($result = $schema->resolve($resolver))->mock($resolver)->call('resolve')->withArguments('{}', 'file://test')->once()->object($result)->isIdenticalTo($schema); }