Skip to content

Commit 91f2464

Browse files
committed
Added tests
1 parent 079bb98 commit 91f2464

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/AbstractOficialDraft.php

+23-2
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,37 @@ public function testOptional()
4040
$this->doTests($this->getFolderPath() . '/optional/format');
4141
}
4242

43+
public function testSelf()
44+
{
45+
$data = json_decode($this->getDraftSource(), false);
46+
47+
$validator = $this->getValidator();
48+
49+
$uri = "http://json-schema.org/draft-0{$this->getDraft()}/schema#";
50+
$result = $validator->uriValidation($data, $uri);
51+
$this->assertTrue($result->isValid());
52+
53+
$result = $validator->schemaValidation($data, new Schema($data));
54+
$this->assertTrue($result->isValid());
55+
56+
$result = $validator->dataValidation($data, $data);
57+
$this->assertTrue($result->isValid());
58+
}
59+
4360
protected function getFolderPath(): string
4461
{
4562
return __DIR__ . '/official/tests/draft' . $this->getDraft();
4663
}
4764

65+
protected function getDraftSource(): string
66+
{
67+
return file_get_contents(__DIR__ . '/official/drafts/draft' . $this->getDraft() . '.json');
68+
}
69+
4870
protected function getValidator(): IValidator
4971
{
5072
$loader = new File( self::URL, [__DIR__ . "/official/remotes"]);
51-
$file = __DIR__ . '/official/drafts/draft' . $this->getDraft() . '.json';
52-
$loader->add(json_decode(file_get_contents($file), false));
73+
$loader->add(json_decode($this->getDraftSource(), false));
5374
return new Validator(null, $loader);
5475
}
5576

0 commit comments

Comments
 (0)