Skip to content

Commit 6ede6f8

Browse files
authored
Merge pull request #19 from shouze/upgrade-json-schema-dependency
Upgrade justinrainbow/json-schema >=3.0.0 <6.0.0
2 parents 67639f9 + 3221937 commit 6ede6f8

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

.travis.yml

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
11
language: php
2+
dist: trusty
23

34
php:
4-
- 5.5
55
- 5.6
66
- 7.0
7+
- 7.1
8+
- nightly
9+
10+
env:
11+
matrix:
12+
- COMPOSER_PREFER="--prefer-stable"
13+
- COMPOSER_PREFER="--prefer-lowest"
14+
15+
matrix:
16+
allow_failures:
17+
- php: nightly
18+
fast_finish: true
719

820
before_script:
921
- echo 'always_populate_raw_post_data = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
10-
- phpenv config-rm xdebug.ini
11-
- composer install --prefer-dist --optimize-autoloader
22+
- |
23+
if [ ! $(php -m | grep -ci xdebug) -eq 0 ] ; then
24+
phpenv config-rm xdebug.ini
25+
fi
26+
- composer global require hirak/prestissimo
27+
- composer update $COMPOSER_PREFER
1228
- php -S 127.0.0.1:4224 -t "$TRAVIS_BUILD_DIR/testapp" &> /dev/null &
1329

1430
script:

composer.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,22 @@
2020
"symfony/http-foundation": "^2.8|^3.0",
2121
"symfony/debug": "^2.8|^3.0",
2222
"jakeasmith/http_build_url": "^1.0",
23-
"justinrainbow/json-schema": "^2.0"
23+
"justinrainbow/json-schema": ">=3.0 <6.0"
24+
},
25+
"config": {
26+
"optimize-autoloader": true,
27+
"preferred-install": {
28+
"*": "dist"
29+
}
2430
},
2531
"require-dev": {
26-
"atoum/atoum": "^2.6",
32+
"atoum/atoum": "^3.1",
2733
"fzaninotto/faker": "^1.5",
2834
"league/tactician-bundle": "^0.4.1",
2935
"symfony/serializer": "^3.0",
3036
"symfony/validator": "^3.0",
3137
"symfony/framework-bundle": "^3.0",
32-
"rezzza/rest-api-behat-extension": "^5.0",
38+
"rezzza/rest-api-behat-extension": "^6.0",
3339
"php-http/curl-client": "^1.5",
3440
"guzzlehttp/psr7": "^1.3"
3541
},

src/JsonSchemaTools.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Rezzza\SymfonyRestApiJson;
44

55
use JsonSchema\Validator;
6-
use JsonSchema\RefResolver;
6+
use JsonSchema\SchemaStorage;
77
use JsonSchema\Uri;
88

99
/**
10-
* Used as factory because JsonSchema\Validator and JsonSchema\RefResolver are not stateless
10+
* Used as factory because JsonSchema\Validator and JsonSchema\SchemaStorage are not stateless
1111
*/
1212
class JsonSchemaTools
1313
{
@@ -16,10 +16,11 @@ public function createValidator()
1616
return new Validator;
1717
}
1818

19-
public function createRefResolver()
19+
public function createSchemaStorage()
2020
{
21-
return new RefResolver(
22-
new Uri\UriRetriever(), new Uri\UriResolver()
21+
return new SchemaStorage(
22+
new Uri\UriRetriever(),
23+
new Uri\UriResolver()
2324
);
2425
}
2526
}

src/PayloadValidator.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public function validate($payload, $jsonSchemaFilename)
1818
}
1919

2020
$delegateValidator = $this->jsonSchemaTools->createValidator();
21-
$refResolver = $this->jsonSchemaTools->createRefResolver();
21+
$refResolver = $this->jsonSchemaTools->createSchemaStorage();
2222

23+
$data = json_decode($payload);
2324
$delegateValidator->check(
24-
json_decode($payload),
25-
$refResolver->resolve('file://' . realpath($jsonSchemaFilename))
25+
$data,
26+
$refResolver->resolveRef('file://' . realpath($jsonSchemaFilename))
2627
);
2728

2829
if (!$delegateValidator->isValid()) {

tests/Units/PayloadValidator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function test_validation_should_be_delegated_to_internal_validator()
1313
$validator = $this->mockJsonSchemaValidator(),
1414
$this->calling($validator)->check = null,
1515
$refResolver = $this->mockJsonSchemaRefResolver(),
16-
$this->calling($refResolver)->resolve = 'resolvedJsonSchema',
16+
$this->calling($refResolver)->resolveRef = 'resolvedJsonSchema',
1717
$jsonSchemaTools = $this->mockJsonSchemaTools($validator, $refResolver),
1818
$this->newTestedInstance($jsonSchemaTools)
1919
)
@@ -75,15 +75,15 @@ private function mockJsonSchemaRefResolver()
7575
{
7676
$this->mockGenerator->orphanize('__construct');
7777

78-
return new \mock\JsonSchema\RefResolver;
78+
return new \mock\JsonSchema\JsonStorage();
7979
}
8080

8181
private function mockJsonSchemaTools($validator = null, $refResolver = null)
8282
{
8383
$this->mockGenerator->orphanize('__construct');
8484
$mock = new \mock\Rezzza\SymfonyRestApiJson\JsonSchemaTools;
8585
$this->calling($mock)->createValidator = $validator;
86-
$this->calling($mock)->createRefResolver = $refResolver;
86+
$this->calling($mock)->createSchemaStorage = $refResolver;
8787

8888
return $mock;
8989
}

0 commit comments

Comments
 (0)