Skip to content

Commit 42071af

Browse files
committed
Add test for double-resolve bugfix
1 parent 8d7af76 commit 42071af

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/SchemaStorageTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,25 @@ public function testMetaSchemaFixes()
302302
$this->assertEquals('uri-reference', $draft_03->properties->{'$ref'}->format);
303303
$this->assertEquals('uri-reference', $draft_04->properties->id->format);
304304
}
305+
306+
public function testNoDoubleResolve()
307+
{
308+
$schemaOne = json_decode('{"id": "test/schema", "$ref": "../test2/schema2"}');
309+
310+
$uriRetriever = $this->prophesize('JsonSchema\UriRetrieverInterface');
311+
$uriRetriever->retrieve('test/schema')->willReturn($schemaOne)->shouldBeCalled();
312+
313+
$s = new SchemaStorage($uriRetriever->reveal());
314+
$schema = $s->addSchema('test/schema');
315+
316+
$r = new \ReflectionObject($s);
317+
$p = $r->getProperty('schemas');
318+
$p->setAccessible(true);
319+
$schemas = $p->getValue($s);
320+
321+
$this->assertEquals(
322+
'file://' . getcwd() . '/test2/schema2#',
323+
$schemas['test/schema']->{'$ref'}
324+
);
325+
}
305326
}

0 commit comments

Comments
 (0)