Skip to content

Commit ba902a2

Browse files
author
Andy Raines
committed
Sort out UriRetriever unit test issues
1 parent f1e367e commit ba902a2

File tree

2 files changed

+7
-36
lines changed

2 files changed

+7
-36
lines changed

src/JsonSchema/Uri/UriRetriever.php

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ public function resolvePointer($jsonSchema, $uri)
103103

104104
$pointer = new Pointer($jsonSchema);
105105

106-
return $pointer->get($parsed['fragment']);
106+
$reference = $pointer->get($parsed['fragment']);
107+
108+
if (!is_object($reference)) {
109+
throw new ResourceNotFoundException("Pointer was not an object");
110+
}
111+
112+
return $reference;
107113
}
108114

109115
/**
@@ -231,30 +237,6 @@ public function generate(array $components)
231237
return $uri;
232238
}
233239

234-
/**
235-
* Resolves a URI
236-
*
237-
* @param string $uri Absolute or relative
238-
* @param string $baseUri Optional base URI
239-
* @return string
240-
*/
241-
public function resolve($uri, $baseUri = null)
242-
{
243-
$components = $this->parse($uri);
244-
$path = $components['path'];
245-
246-
if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
247-
return $uri;
248-
}
249-
250-
$baseComponents = $this->parse($baseUri);
251-
$basePath = $baseComponents['path'];
252-
253-
$baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
254-
255-
return $this->generate($baseComponents);
256-
}
257-
258240
/**
259241
* @param string $uri
260242
* @return boolean

tests/JsonSchema/Tests/Uri/UriRetrieverTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,4 @@ public function testResolvePointerFragmentNoArray()
222222
$schema, 'http://example.org/schema.json#/definitions/foo'
223223
);
224224
}
225-
226-
/**
227-
* @expectedException JsonSchema\Exception\UriResolverException
228-
*/
229-
public function testResolveExcessLevelUp()
230-
{
231-
$retriever = new \JsonSchema\Uri\UriRetriever();
232-
$retriever->resolve(
233-
'../schema.json#', 'http://example.org/schema.json#'
234-
);
235-
}
236225
}

0 commit comments

Comments
 (0)