Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinsarca committed Mar 7, 2019
1 parent 079bb98 commit 91f2464
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/AbstractOficialDraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,37 @@ public function testOptional()
$this->doTests($this->getFolderPath() . '/optional/format');
}

public function testSelf()
{
$data = json_decode($this->getDraftSource(), false);

$validator = $this->getValidator();

$uri = "http://json-schema.org/draft-0{$this->getDraft()}/schema#";
$result = $validator->uriValidation($data, $uri);
$this->assertTrue($result->isValid());

$result = $validator->schemaValidation($data, new Schema($data));
$this->assertTrue($result->isValid());

$result = $validator->dataValidation($data, $data);
$this->assertTrue($result->isValid());
}

protected function getFolderPath(): string
{
return __DIR__ . '/official/tests/draft' . $this->getDraft();
}

protected function getDraftSource(): string
{
return file_get_contents(__DIR__ . '/official/drafts/draft' . $this->getDraft() . '.json');
}

protected function getValidator(): IValidator
{
$loader = new File( self::URL, [__DIR__ . "/official/remotes"]);
$file = __DIR__ . '/official/drafts/draft' . $this->getDraft() . '.json';
$loader->add(json_decode(file_get_contents($file), false));
$loader->add(json_decode($this->getDraftSource(), false));
return new Validator(null, $loader);
}

Expand Down

0 comments on commit 91f2464

Please sign in to comment.