From 6cd8b87b08159350ea2f51ab24f6c248c9dc667e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20HOUZ=C3=89?= Date: Mon, 4 Sep 2017 16:45:57 +0200 Subject: [PATCH] :lipstick: Fixup some forgot pieces of #19 --- src/PayloadValidator.php | 4 ++-- tests/Units/PayloadValidator.php | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/PayloadValidator.php b/src/PayloadValidator.php index 2b34755..a7a7f67 100644 --- a/src/PayloadValidator.php +++ b/src/PayloadValidator.php @@ -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()) { diff --git a/tests/Units/PayloadValidator.php b/tests/Units/PayloadValidator.php index 22346ec..28fbb70 100644 --- a/tests/Units/PayloadValidator.php +++ b/tests/Units/PayloadValidator.php @@ -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( @@ -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 () { @@ -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; }