Skip to content

Commit 6dad7bf

Browse files
committed
Merge pull request #265 from mirfilip/feature/upgrade-json-schema-test-sute-to-1.2.0
Bump json-schema/JSON-Schema-Test-Suite to 1.2.0 + some tests improvements
2 parents c21534c + 346b321 commit 6dad7bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+36
-11
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828
"type": "package",
2929
"package": {
3030
"name": "json-schema/JSON-Schema-Test-Suite",
31-
"version": "1.1.2",
31+
"version": "1.2.0",
3232
"source": {
3333
"url": "https://github.com/json-schema/JSON-Schema-Test-Suite",
3434
"type": "git",
35-
"reference": "1.1.2"
35+
"reference": "1.2.0"
3636
}
3737
}
3838
}],
3939
"require": {
4040
"php": ">=5.3.3"
4141
},
4242
"require-dev": {
43-
"json-schema/JSON-Schema-Test-Suite": "1.1.2",
43+
"json-schema/JSON-Schema-Test-Suite": "1.2.0",
4444
"phpunit/phpunit": "^4.8.22",
4545
"phpdocumentor/phpdocumentor": "~2"
4646
},
4747
"autoload": {
4848
"psr-4": { "JsonSchema\\": "src/JsonSchema/" }
4949
},
5050
"autoload-dev": {
51-
"psr-4": { "JsonSchema\\Tests\\": "tests/JsonSchema/Tests/" }
51+
"psr-4": { "JsonSchema\\Tests\\": "tests/" }
5252
},
5353
"bin": ["bin/validate-json"],
5454
"extra": {

tests/JsonSchema/Tests/Constraints/BaseTestCase.php renamed to tests/Constraints/BaseTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ abstract public function getInvalidTests();
7979
*/
8080
private function resolveSchema($schema)
8181
{
82-
$relativeTestsRoot = realpath(__DIR__ . '/../../../../vendor/json-schema/JSON-Schema-Test-Suite/remotes');
82+
$relativeTestsRoot = realpath(__DIR__ . '/../../vendor/json-schema/JSON-Schema-Test-Suite/remotes');
8383

8484
$jsonSchemaDraft03 = $this->getJsonSchemaDraft03();
8585
$jsonSchemaDraft04 = $this->getJsonSchemaDraft04();

tests/JsonSchema/Tests/Drafts/BaseDraftTestCase.php renamed to tests/Drafts/BaseDraftTestCase.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
abstract class BaseDraftTestCase extends BaseTestCase
1111
{
1212
/** @var string */
13-
protected $relativeTestsRoot = '/../../../../vendor/json-schema/JSON-Schema-Test-Suite/tests';
13+
protected $relativeTestsRoot = '/../../vendor/json-schema/JSON-Schema-Test-Suite/tests';
1414

1515
private function setUpTests($isValid)
1616
{
@@ -20,13 +20,18 @@ private function setUpTests($isValid)
2020

2121
foreach ($filePaths as $path) {
2222
foreach (glob($path . '/*.json') as $file) {
23-
if (!in_array(basename($file), $skippedTests)) {
23+
$filename = basename($file);
24+
if (!in_array($filename, $skippedTests)) {
2425
$suites = json_decode(file_get_contents($file));
2526
foreach ($suites as $suite) {
27+
$suiteDescription = $suite->description;
2628
foreach ($suite->tests as $test) {
29+
$testCaseDescription = $test->description;
2730
if ($isValid === $test->valid) {
28-
$tests[] = array(json_encode($test->data), json_encode($suite->schema));
29-
}
31+
$tests[
32+
$this->createDataSetPath($filename, $suiteDescription, $testCaseDescription)
33+
] = array(json_encode($test->data), json_encode($suite->schema));
34+
}
3035
}
3136
}
3237
}
@@ -61,4 +66,19 @@ protected abstract function getFilePaths();
6166
* @return string[]
6267
*/
6368
protected abstract function getSkippedTests();
69+
70+
/**
71+
* Generates a readable path to Json Schema Test Suite data set under test
72+
*
73+
* @param string $filename
74+
* @param string $suiteDesc
75+
* @param string $testCaseDesc
76+
*
77+
* @return string
78+
*/
79+
private function createDataSetPath($filename, $suiteDesc, $testCaseDesc)
80+
{
81+
$separator = ' / ';
82+
return $filename . $separator . $suiteDesc . $separator . $testCaseDesc;
83+
}
6484
}

tests/JsonSchema/Tests/Drafts/Draft3Test.php renamed to tests/Drafts/Draft3Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ protected function getFilePaths()
3131
protected function getSkippedTests()
3232
{
3333
return array(
34+
// Optional
3435
'bignum.json',
36+
'format.json',
3537
'jsregex.json',
3638
'zeroTerminatedFloats.json'
3739
);

tests/JsonSchema/Tests/Drafts/Draft4Test.php renamed to tests/Drafts/Draft4Test.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ protected function getSkippedTests()
3333
return array(
3434
// Optional
3535
'bignum.json',
36-
'zeroTerminatedFloats.json'
36+
'format.json',
37+
'zeroTerminatedFloats.json',
38+
// Required
39+
'not.json' // only one test case failing
3740
);
3841
}
3942
}
File renamed without changes.

tests/JsonSchema/Tests/Uri/Retrievers/FileGetContentsTest.php renamed to tests/Uri/Retrievers/FileGetContentsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testFetchMissingFile()
2121
public function testFetchFile()
2222
{
2323
$res = new FileGetContents();
24-
$result = $res->retrieve(__DIR__.'/../Fixture/child.json');
24+
$result = $res->retrieve(__DIR__ . '/../Fixture/child.json');
2525
$this->assertNotEmpty($result);
2626
}
2727
}

0 commit comments

Comments
 (0)