@@ -39,7 +39,7 @@ private function getRetrieverMock($returnSchema)
39
39
$ retriever ->expects ($ this ->at (0 ))
40
40
->method ('retrieve ' )
41
41
->with ($ this ->equalTo (null ), $ this ->equalTo ('http://some.host.at/somewhere/parent ' ))
42
- ->will ( $ this -> returnValue ( $ jsonSchema) );
42
+ ->willReturn ( $ jsonSchema );
43
43
44
44
return $ retriever ;
45
45
}
@@ -153,7 +153,7 @@ public function testResolvePointerNoFragment()
153
153
'title ' => 'schema '
154
154
);
155
155
156
- $ retriever = new \ JsonSchema \ Uri \ UriRetriever ();
156
+ $ retriever = new UriRetriever ();
157
157
$ this ->assertEquals (
158
158
$ schema ,
159
159
$ retriever ->resolvePointer (
@@ -173,7 +173,7 @@ public function testResolvePointerFragment()
173
173
'title ' => 'schema '
174
174
);
175
175
176
- $ retriever = new \ JsonSchema \ Uri \ UriRetriever ();
176
+ $ retriever = new UriRetriever ();
177
177
$ this ->assertEquals (
178
178
$ schema ->definitions ->foo ,
179
179
$ retriever ->resolvePointer (
@@ -196,7 +196,7 @@ public function testResolvePointerFragmentNotFound()
196
196
'title ' => 'schema '
197
197
);
198
198
199
- $ retriever = new \ JsonSchema \ Uri \ UriRetriever ();
199
+ $ retriever = new UriRetriever ();
200
200
$ retriever ->resolvePointer (
201
201
$ schema , 'http://example.org/schema.json#/definitions/bar '
202
202
);
@@ -216,7 +216,7 @@ public function testResolvePointerFragmentNoArray()
216
216
'title ' => 'schema '
217
217
);
218
218
219
- $ retriever = new \ JsonSchema \ Uri \ UriRetriever ();
219
+ $ retriever = new UriRetriever ();
220
220
$ retriever ->resolvePointer (
221
221
$ schema , 'http://example.org/schema.json#/definitions/foo '
222
222
);
@@ -227,46 +227,49 @@ public function testResolvePointerFragmentNoArray()
227
227
*/
228
228
public function testResolveExcessLevelUp ()
229
229
{
230
- $ retriever = new \ JsonSchema \ Uri \ UriRetriever ();
230
+ $ retriever = new UriRetriever ();
231
231
$ retriever ->resolve (
232
232
'../schema.json# ' , 'http://example.org/schema.json# '
233
233
);
234
234
}
235
235
236
236
public function testConfirmMediaTypeAcceptsJsonSchemaType ()
237
237
{
238
- $ retriever = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ('getContentType ' ));
238
+ $ uriRetriever = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
239
+ $ retriever = new UriRetriever ();
239
240
240
- $ retriever ->expects ($ this ->at (0 ))
241
+ $ uriRetriever ->expects ($ this ->at (0 ))
241
242
->method ('getContentType ' )
242
- ->will ( $ this -> returnValue ( 'application/schema+json ' ) );
243
+ ->willReturn ( 'application/schema+json ' );
243
244
244
- $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ retriever , null ));
245
+ $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ uriRetriever , null ));
245
246
}
246
247
247
248
public function testConfirmMediaTypeAcceptsJsonType ()
248
249
{
249
- $ retriever = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ('getContentType ' ));
250
+ $ uriRetriever = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
251
+ $ retriever = new UriRetriever ();
250
252
251
- $ retriever ->expects ($ this ->at (0 ))
253
+ $ uriRetriever ->expects ($ this ->at (0 ))
252
254
->method ('getContentType ' )
253
- ->will ( $ this -> returnValue ( 'application/json ' ) );
255
+ ->willReturn ( 'application/json ' );
254
256
255
- $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ retriever , null ));
257
+ $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ uriRetriever , null ));
256
258
}
257
259
258
260
/**
259
261
* @expectedException \JsonSchema\Exception\InvalidSchemaMediaTypeException
260
262
*/
261
263
public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes ()
262
264
{
263
- $ retriever = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ('getContentType ' ));
265
+ $ uriRetriever = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
266
+ $ retriever = new UriRetriever ();
264
267
265
- $ retriever ->expects ($ this ->at (0 ))
268
+ $ uriRetriever ->expects ($ this ->at (0 ))
266
269
->method ('getContentType ' )
267
- ->will ( $ this -> returnValue ( 'text/html ' ) );
270
+ ->willReturn ( 'text/html ' );
268
271
269
- $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ retriever , null ));
272
+ $ this ->assertEquals (null , $ retriever ->confirmMediaType ($ uriRetriever , null ));
270
273
}
271
274
272
275
private function mockRetriever ($ schema )
@@ -332,7 +335,7 @@ public function testRetrieveSchemaFromPackage()
332
335
333
336
public function testInvalidContentTypeEndpointsDefault ()
334
337
{
335
- $ mock = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ( ' getContentType ' ) );
338
+ $ mock = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
336
339
$ mock ->method ('getContentType ' )->willReturn ('Application/X-Fake-Type ' );
337
340
$ retriever = new UriRetriever ();
338
341
@@ -345,7 +348,7 @@ public function testInvalidContentTypeEndpointsDefault()
345
348
*/
346
349
public function testInvalidContentTypeEndpointsUnknown ()
347
350
{
348
- $ mock = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ( ' getContentType ' ) );
351
+ $ mock = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
349
352
$ mock ->method ('getContentType ' )->willReturn ('Application/X-Fake-Type ' );
350
353
$ retriever = new UriRetriever ();
351
354
@@ -354,7 +357,7 @@ public function testInvalidContentTypeEndpointsUnknown()
354
357
355
358
public function testInvalidContentTypeEndpointsAdded ()
356
359
{
357
- $ mock = $ this ->getMock ('JsonSchema\Uri\UriRetriever ' , array ( ' getContentType ' ) );
360
+ $ mock = $ this ->getMock ('JsonSchema\Uri\Retrievers\UriRetrieverInterface ' );
358
361
$ mock ->method ('getContentType ' )->willReturn ('Application/X-Fake-Type ' );
359
362
$ retriever = new UriRetriever ();
360
363
$ retriever ->addInvalidContentTypeEndpoint ('http://example.com ' );
@@ -389,7 +392,7 @@ public function testLoadSchemaJSONDecodingException()
389
392
'JsonSchema\Exception\JsonDecodingException ' ,
390
393
'JSON syntax is malformed '
391
394
);
392
- $ schema = $ retriever ->retrieve ('package://tests/fixtures/bad-syntax.json ' );
395
+ $ retriever ->retrieve ('package://tests/fixtures/bad-syntax.json ' );
393
396
}
394
397
395
398
public function testGenerateURI ()
0 commit comments