Skip to content

Commit d37f896

Browse files
committed
Merge branch 'pull-67'
* pull-67: Fix Issue #65. Use JsonSchema\Exception\ResourceNotFoundException Remove tabs/whitespace. Add unit test coverage. Add code comments.
2 parents 91d1d21 + 3bc96c0 commit d37f896

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

src/JsonSchema/Uri/Retrievers/Curl.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
use JsonSchema\Validator;
1313

14-
use JsonSchema\Exception\ResourceNotFoundException;
15-
1614
/**
1715
* Tries to retrieve JSON schemas from a URI using cURL library
1816
*
@@ -44,7 +42,7 @@ public function retrieve($uri)
4442

4543
$response = curl_exec($ch);
4644
if (false === $response) {
47-
throw new ResourceNotFoundException('JSON schema not found');
45+
throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
4846
}
4947

5048
$this->fetchMessageBody($response);

src/JsonSchema/Uri/Retrievers/PredefinedArray.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use JsonSchema\Validator;
66
use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
7-
use JsonSchema\Exception\ResourceNotFoundException;
87

98
/**
109
* URI retrieved based on a predefined array of schemas
@@ -45,7 +44,7 @@ public function __construct(array $schemas, $contentType = Validator::SCHEMA_MED
4544
public function retrieve($uri)
4645
{
4746
if (!array_key_exists($uri, $this->schemas)) {
48-
throw new ResourceNotFoundException(sprintf(
47+
throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
4948
'The JSON schema "%s" was not found.',
5049
$uri
5150
));

tests/JsonSchema/Tests/RefResolverTest.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -156,37 +156,37 @@ public function testResolveRef($expected, $input) {
156156
$this->assertEquals($expected, $input);
157157
}
158158

159-
public function refProvider() {
160-
return array(
161-
'no ref' => array(
162-
(object) array('test' => 'one'),
163-
(object) array('test' => 'one')
164-
),
165-
// The $ref is not removed here
166-
'empty ref' => array(
167-
(object) array(
168-
'test' => 'two',
169-
'$ref' => ''
170-
),
171-
(object) array(
172-
'test' => 'two',
173-
'$ref' => ''
174-
)
175-
),
176-
// $ref is removed
177-
'qualified ref' => array(
178-
(object) array(
179-
'this is' => 'another test',
180-
'this was' => array('added', 'because'),
181-
'the' => (object) array('$ref resolved' => true)
182-
),
183-
(object) array(
184-
'$ref' => 'http://example.com/',
185-
'this is' => 'another test'
186-
)
187-
),
188-
);
189-
}
159+
public function refProvider() {
160+
return array(
161+
'no ref' => array(
162+
(object) array('test' => 'one'),
163+
(object) array('test' => 'one')
164+
),
165+
// The $ref is not removed here
166+
'empty ref' => array(
167+
(object) array(
168+
'test' => 'two',
169+
'$ref' => ''
170+
),
171+
(object) array(
172+
'test' => 'two',
173+
'$ref' => ''
174+
)
175+
),
176+
// $ref is removed
177+
'qualified ref' => array(
178+
(object) array(
179+
'this is' => 'another test',
180+
'this was' => array('added', 'because'),
181+
'the' => (object) array('$ref resolved' => true)
182+
),
183+
(object) array(
184+
'$ref' => 'http://example.com/',
185+
'this is' => 'another test'
186+
)
187+
),
188+
);
189+
}
190190

191191
public function testFetchRefAbsolute()
192192
{

0 commit comments

Comments
 (0)