Skip to content

Commit

Permalink
💄 Fixup some forgot pieces of #19
Browse files Browse the repository at this point in the history
  • Loading branch information
shouze committed Sep 4, 2017
1 parent 19fd50f commit 6cd8b87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/PayloadValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public function validate($payload, $jsonSchemaFilename)
}

$delegateValidator = $this->jsonSchemaTools->createValidator();
$refResolver = $this->jsonSchemaTools->createSchemaStorage();
$schemaStorage = $this->jsonSchemaTools->createSchemaStorage();

$data = json_decode($payload);
$delegateValidator->check(
$data,
$refResolver->resolveRef('file://' . realpath($jsonSchemaFilename))
$schemaStorage->resolveRef('file://' . realpath($jsonSchemaFilename))
);

if (!$delegateValidator->isValid()) {
Expand Down
20 changes: 10 additions & 10 deletions tests/Units/PayloadValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public function test_validation_should_be_delegated_to_internal_validator()
->given(
$validator = $this->mockJsonSchemaValidator(),
$this->calling($validator)->check = null,
$refResolver = $this->mockJsonSchemaRefResolver(),
$this->calling($refResolver)->resolveRef = 'resolvedJsonSchema',
$jsonSchemaTools = $this->mockJsonSchemaTools($validator, $refResolver),
$schemaStorage = $this->mockJsonSchemaStorage(),
$this->calling($schemaStorage)->resolveRef = 'resolvedJsonSchema',
$jsonSchemaTools = $this->mockJsonSchemaTools($validator, $schemaStorage),
$this->newTestedInstance($jsonSchemaTools)
)
->when(
Expand Down Expand Up @@ -50,9 +50,9 @@ public function test_invalid_internal_validation_lead_to_exception()
$this->calling($validator)->check = null,
$this->calling($validator)->isValid = false,
$this->calling($validator)->getErrors = ['error1', 'error2'],
$refResolver = $this->mockJsonSchemaRefResolver(),
$this->calling($refResolver)->resolve = 'resolvedJsonSchema',
$jsonSchemaTools = $this->mockJsonSchemaTools($validator, $refResolver),
$schemaStorage = $this->mockJsonSchemaStorage(),
$this->calling($schemaStorage)->resolveRef = 'resolvedJsonSchema',
$jsonSchemaTools = $this->mockJsonSchemaTools($validator, $schemaStorage),
$this->newTestedInstance($jsonSchemaTools)
)
->exception(function () {
Expand All @@ -71,19 +71,19 @@ private function mockJsonSchemaValidator()
return new \mock\JsonSchema\Validator;
}

private function mockJsonSchemaRefResolver()
private function mockJsonSchemaStorage()
{
$this->mockGenerator->orphanize('__construct');

return new \mock\JsonSchema\JsonStorage();
return new \mock\JsonSchema\SchemaStorage();
}

private function mockJsonSchemaTools($validator = null, $refResolver = null)
private function mockJsonSchemaTools($validator = null, $schemaStorage = null)
{
$this->mockGenerator->orphanize('__construct');
$mock = new \mock\Rezzza\SymfonyRestApiJson\JsonSchemaTools;
$this->calling($mock)->createValidator = $validator;
$this->calling($mock)->createSchemaStorage = $refResolver;
$this->calling($mock)->createSchemaStorage = $schemaStorage;

return $mock;
}
Expand Down

0 comments on commit 6cd8b87

Please sign in to comment.