Skip to content

Commit

Permalink
Add test for double-resolve bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Oct 4, 2017
1 parent 8d7af76 commit 42071af
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/SchemaStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,25 @@ public function testMetaSchemaFixes()
$this->assertEquals('uri-reference', $draft_03->properties->{'$ref'}->format);
$this->assertEquals('uri-reference', $draft_04->properties->id->format);
}

public function testNoDoubleResolve()
{
$schemaOne = json_decode('{"id": "test/schema", "$ref": "../test2/schema2"}');

$uriRetriever = $this->prophesize('JsonSchema\UriRetrieverInterface');
$uriRetriever->retrieve('test/schema')->willReturn($schemaOne)->shouldBeCalled();

$s = new SchemaStorage($uriRetriever->reveal());
$schema = $s->addSchema('test/schema');

$r = new \ReflectionObject($s);
$p = $r->getProperty('schemas');
$p->setAccessible(true);
$schemas = $p->getValue($s);

$this->assertEquals(
'file://' . getcwd() . '/test2/schema2#',
$schemas['test/schema']->{'$ref'}
);
}
}

0 comments on commit 42071af

Please sign in to comment.