@@ -67,4 +67,65 @@ public function testFileResolver()
67
67
}
68
68
}
69
69
70
+
71
+ function testFileReference ()
72
+ {
73
+ $ pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json ' ;
74
+ $ schemaData = json_decode (<<<JSON
75
+ {" \$ref": "file:// $ pathToExternalSchema#/integer"}
76
+ JSON
77
+ );
78
+
79
+ $ schema = Schema::import ($ schemaData );
80
+ $ schema ->in (123 );
81
+
82
+ $ this ->setExpectedException (get_class (new InvalidValue ()));
83
+ $ schema ->in ('abc ' );
84
+ }
85
+
86
+ function testFileReferenceCapitalized ()
87
+ {
88
+ $ pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json ' ;
89
+ $ schemaData = json_decode (<<<JSON
90
+ {" \$ref": "FILE:// $ pathToExternalSchema#/integer"}
91
+ JSON
92
+ );
93
+
94
+ $ schema = Schema::import ($ schemaData );
95
+ $ schema ->in (123 );
96
+
97
+ $ this ->setExpectedException (get_class (new InvalidValue ()));
98
+ $ schema ->in ('abc ' );
99
+ }
100
+
101
+ function testFileReferenceRealpath ()
102
+ {
103
+ $ pathToExternalSchema = realpath (__DIR__ . '/../../../resources/remotes/subSchemas.json ' );
104
+ $ schemaData = json_decode (<<<JSON
105
+ {" \$ref": "file:// $ pathToExternalSchema#/integer"}
106
+ JSON
107
+ );
108
+
109
+ $ schema = Schema::import ($ schemaData );
110
+ $ schema ->in (123 );
111
+
112
+ $ this ->setExpectedException (get_class (new InvalidValue ()));
113
+ $ schema ->in ('abc ' );
114
+ }
115
+
116
+ function testFileReferenceNoProtocolScheme ()
117
+ {
118
+ $ pathToExternalSchema = __DIR__ . '/../../../resources/remotes/subSchemas.json ' ;
119
+ $ schemaData = json_decode (<<<JSON
120
+ {" \$ref": " $ pathToExternalSchema#/integer"}
121
+ JSON
122
+ );
123
+
124
+ $ schema = Schema::import ($ schemaData );
125
+ $ schema ->in (123 );
126
+
127
+ $ this ->setExpectedException (get_class (new InvalidValue ()));
128
+ $ schema ->in ('abc ' );
129
+ }
130
+
70
131
}
0 commit comments