File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
src/JsonSchema/Uri/Retrievers
tests/JsonSchema/Tests/Uri Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,13 @@ public function retrieve($uri)
3232 'method ' => 'GET ' ,
3333 'header ' => "Accept: " . Validator::SCHEMA_MEDIA_TYPE
3434 )));
35-
35+
36+ set_error_handler (function () use ($ uri ) {
37+ throw new ResourceNotFoundException ('JSON schema not found at ' . $ uri );
38+ });
3639 $ response = file_get_contents ($ uri );
40+ restore_error_handler ();
41+
3742 if (false === $ response ) {
3843 throw new ResourceNotFoundException ('JSON schema not found at ' . $ uri );
3944 }
Original file line number Diff line number Diff line change 1+ {
2+ "type" :" object" ,
3+ "title" :" parent" ,
4+ "properties" :
5+ {
6+ "parentProp" :
7+ {
8+ "type" :" boolean"
9+ }
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace JsonSchema \Tests \Uri \Retrievers ;
4+
5+ use JsonSchema \Uri \Retrievers \FileGetContents ;
6+
7+ /**
8+ * @group FileGetContents
9+ */
10+ class FileGetContentsTest extends \PHPUnit_Framework_TestCase
11+ {
12+ /**
13+ * @expectedException JsonSchema\Exception\ResourceNotFoundException
14+ */
15+ public function testFetchMissingFile ()
16+ {
17+ $ res = new FileGetContents ();
18+ $ res ->retrieve (__DIR__ .'/Fixture/missing.json ' );
19+ }
20+
21+ public function testFetchFile ()
22+ {
23+ $ res = new FileGetContents ();
24+ $ result = $ res ->retrieve (__DIR__ .'/../Fixture/child.json ' );
25+ $ this ->assertNotEmpty ($ result );
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments