@@ -40,16 +40,37 @@ public function testOptional()
40
40
$ this ->doTests ($ this ->getFolderPath () . '/optional/format ' );
41
41
}
42
42
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
+
43
60
protected function getFolderPath (): string
44
61
{
45
62
return __DIR__ . '/official/tests/draft ' . $ this ->getDraft ();
46
63
}
47
64
65
+ protected function getDraftSource (): string
66
+ {
67
+ return file_get_contents (__DIR__ . '/official/drafts/draft ' . $ this ->getDraft () . '.json ' );
68
+ }
69
+
48
70
protected function getValidator (): IValidator
49
71
{
50
72
$ 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 ));
53
74
return new Validator (null , $ loader );
54
75
}
55
76
0 commit comments