Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .atoum.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
[fr] http://docs.atoum.org/fr/latest/lancement_des_tests.html#fichier-de-configuration
*/

use \mageekguy\atoum;

$report = $script->addDefaultReport();

// This will add a green or red logo after each run depending on its status.
Expand Down
12 changes: 0 additions & 12 deletions .bootstrap.atoum.php

This file was deleted.

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