From df9e86df570f6112135d9f8fad35c13b4b109e70 Mon Sep 17 00:00:00 2001 From: Emmanuel Vella Date: Fri, 10 Oct 2014 16:44:58 +0200 Subject: [PATCH] Fix json schema validation --- src/Json/Json.php | 5 +++++ src/Json/JsonSchema.php | 2 +- tests/units/Json/JsonSchema.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Json/Json.php b/src/Json/Json.php index a95dacb6..8f7e6294 100644 --- a/src/Json/Json.php +++ b/src/Json/Json.php @@ -13,6 +13,11 @@ public function __construct($content) $this->content = $this->decode((string) $content); } + public function getContent() + { + return $this->content; + } + public function read($expression, PropertyAccessor $accessor) { if (is_array($this->content)) { diff --git a/src/Json/JsonSchema.php b/src/Json/JsonSchema.php index 32b9835f..659ada01 100644 --- a/src/Json/JsonSchema.php +++ b/src/Json/JsonSchema.php @@ -28,7 +28,7 @@ public function resolve(RefResolver $resolver) public function validate(Json $json, Validator $validator) { - $validator->check($json, $this); + $validator->check($json->getContent(), $this->getContent()); if (!$validator->isValid()) { $msg = "JSON does not validate. Violations:".PHP_EOL; diff --git a/tests/units/Json/JsonSchema.php b/tests/units/Json/JsonSchema.php index 80403777..02b97b18 100644 --- a/tests/units/Json/JsonSchema.php +++ b/tests/units/Json/JsonSchema.php @@ -60,7 +60,7 @@ public function test_should_validate_correct_json() ) ->mock($validator) ->call('check') - ->withArguments($json, $schema) + ->withArguments($json->getContent(), $schema->getContent()) ->once() ->boolean($result)