From 346b3218dd300a94a5e1dc698b68d6e505efe5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miros=C5=82aw=20Filip?= Date: Mon, 9 May 2016 22:38:52 +0200 Subject: [PATCH] Bump json-schema/JSON-Schema-Test-Suite to 1.2.0. Add data set description for failing tests. Flatten directory structure Use "test.json / suite description / test case description" notation in data provider to allow a readable test output Skip Draft3Test / Draft4Test tests which are not passing Add some comment to skipped tests --- composer.json | 8 +++--- .../Constraints/AdditionalPropertiesTest.php | 0 .../Tests => }/Constraints/ArraysTest.php | 0 .../Tests => }/Constraints/BaseTestCase.php | 2 +- .../Tests => }/Constraints/BasicTypesTest.php | 0 .../Constraints/DependenciesTest.php | 0 .../Tests => }/Constraints/DisallowTest.php | 0 .../Constraints/DivisibleByTest.php | 0 .../Tests => }/Constraints/EnumTest.php | 0 .../Tests => }/Constraints/ExtendsTest.php | 0 .../Tests => }/Constraints/FactoryTest.php | 0 .../Tests => }/Constraints/FormatTest.php | 0 .../Constraints/MinItemsMaxItemsTest.php | 0 .../MinLengthMaxLengthMultiByteTest.php | 0 .../Constraints/MinLengthMaxLengthTest.php | 0 .../Constraints/MinimumMaximumTest.php | 0 .../Tests => }/Constraints/NotTest.php | 0 .../Constraints/NumberAndIntegerTypesTest.php | 0 .../Constraints/OfPropertiesTest.php | 0 .../Constraints/PatternPropertiesTest.php | 0 .../Tests => }/Constraints/PatternTest.php | 0 .../Tests => }/Constraints/ReadOnlyTest.php | 0 .../Tests => }/Constraints/RequireTest.php | 0 .../Constraints/RequiredPropertyTest.php | 0 .../Constraints/SelfDefinedSchemaTest.php | 0 .../Constraints/TupleTypingTest.php | 0 .../Tests => }/Constraints/TypeTest.php | 0 .../Tests => }/Constraints/UnionTypesTest.php | 0 .../Constraints/UnionWithNullValueTest.php | 0 .../Constraints/UniqueItemsTest.php | 0 .../WrongMessagesFailingTestCaseTest.php | 0 .../Tests => }/Drafts/BaseDraftTestCase.php | 28 ++++++++++++++++--- .../Tests => }/Drafts/Draft3Test.php | 2 ++ .../Tests => }/Drafts/Draft4Test.php | 5 +++- .../Tests => }/Entity/JsonPointerTest.php | 0 .../Tests => }/RefResolverTest.php | 0 tests/{JsonSchema/Tests => }/Rfc3339Test.php | 0 .../Tests => }/Uri/Fixture/child.json | 0 .../Uri/Retrievers/FileGetContentsTest.php | 2 +- .../Uri/Retrievers/PredefinedArrayTest.php | 0 .../Tests => }/Uri/UriResolverTest.php | 0 .../Tests => }/Uri/UriRetrieverTest.php | 0 .../fixtures/json-schema-draft-03.json | 0 .../fixtures/json-schema-draft-04.json | 0 44 files changed, 36 insertions(+), 11 deletions(-) rename tests/{JsonSchema/Tests => }/Constraints/AdditionalPropertiesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/ArraysTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/BaseTestCase.php (97%) rename tests/{JsonSchema/Tests => }/Constraints/BasicTypesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/DependenciesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/DisallowTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/DivisibleByTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/EnumTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/ExtendsTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/FactoryTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/FormatTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/MinItemsMaxItemsTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/MinLengthMaxLengthMultiByteTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/MinLengthMaxLengthTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/MinimumMaximumTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/NotTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/NumberAndIntegerTypesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/OfPropertiesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/PatternPropertiesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/PatternTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/ReadOnlyTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/RequireTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/RequiredPropertyTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/SelfDefinedSchemaTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/TupleTypingTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/TypeTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/UnionTypesTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/UnionWithNullValueTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/UniqueItemsTest.php (100%) rename tests/{JsonSchema/Tests => }/Constraints/WrongMessagesFailingTestCaseTest.php (100%) rename tests/{JsonSchema/Tests => }/Drafts/BaseDraftTestCase.php (55%) rename tests/{JsonSchema/Tests => }/Drafts/Draft3Test.php (94%) rename tests/{JsonSchema/Tests => }/Drafts/Draft4Test.php (84%) rename tests/{JsonSchema/Tests => }/Entity/JsonPointerTest.php (100%) rename tests/{JsonSchema/Tests => }/RefResolverTest.php (100%) rename tests/{JsonSchema/Tests => }/Rfc3339Test.php (100%) rename tests/{JsonSchema/Tests => }/Uri/Fixture/child.json (100%) rename tests/{JsonSchema/Tests => }/Uri/Retrievers/FileGetContentsTest.php (88%) rename tests/{JsonSchema/Tests => }/Uri/Retrievers/PredefinedArrayTest.php (100%) rename tests/{JsonSchema/Tests => }/Uri/UriResolverTest.php (100%) rename tests/{JsonSchema/Tests => }/Uri/UriRetrieverTest.php (100%) rename tests/{JsonSchema/Tests => }/fixtures/json-schema-draft-03.json (100%) rename tests/{JsonSchema/Tests => }/fixtures/json-schema-draft-04.json (100%) diff --git a/composer.json b/composer.json index 43bf0c9f..9ebba06b 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,11 @@ "type": "package", "package": { "name": "json-schema/JSON-Schema-Test-Suite", - "version": "1.1.2", + "version": "1.2.0", "source": { "url": "https://github.com/json-schema/JSON-Schema-Test-Suite", "type": "git", - "reference": "1.1.2" + "reference": "1.2.0" } } }], @@ -40,7 +40,7 @@ "php": ">=5.3.3" }, "require-dev": { - "json-schema/JSON-Schema-Test-Suite": "1.1.2", + "json-schema/JSON-Schema-Test-Suite": "1.2.0", "phpunit/phpunit": "^4.8.22", "phpdocumentor/phpdocumentor": "~2" }, @@ -48,7 +48,7 @@ "psr-4": { "JsonSchema\\": "src/JsonSchema/" } }, "autoload-dev": { - "psr-4": { "JsonSchema\\Tests\\": "tests/JsonSchema/Tests/" } + "psr-4": { "JsonSchema\\Tests\\": "tests/" } }, "bin": ["bin/validate-json"], "extra": { diff --git a/tests/JsonSchema/Tests/Constraints/AdditionalPropertiesTest.php b/tests/Constraints/AdditionalPropertiesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/AdditionalPropertiesTest.php rename to tests/Constraints/AdditionalPropertiesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/ArraysTest.php b/tests/Constraints/ArraysTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/ArraysTest.php rename to tests/Constraints/ArraysTest.php diff --git a/tests/JsonSchema/Tests/Constraints/BaseTestCase.php b/tests/Constraints/BaseTestCase.php similarity index 97% rename from tests/JsonSchema/Tests/Constraints/BaseTestCase.php rename to tests/Constraints/BaseTestCase.php index 7ca630dd..27cb6b09 100644 --- a/tests/JsonSchema/Tests/Constraints/BaseTestCase.php +++ b/tests/Constraints/BaseTestCase.php @@ -79,7 +79,7 @@ abstract public function getInvalidTests(); */ private function resolveSchema($schema) { - $relativeTestsRoot = realpath(__DIR__ . '/../../../../vendor/json-schema/JSON-Schema-Test-Suite/remotes'); + $relativeTestsRoot = realpath(__DIR__ . '/../../vendor/json-schema/JSON-Schema-Test-Suite/remotes'); $jsonSchemaDraft03 = $this->getJsonSchemaDraft03(); $jsonSchemaDraft04 = $this->getJsonSchemaDraft04(); diff --git a/tests/JsonSchema/Tests/Constraints/BasicTypesTest.php b/tests/Constraints/BasicTypesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/BasicTypesTest.php rename to tests/Constraints/BasicTypesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/DependenciesTest.php b/tests/Constraints/DependenciesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/DependenciesTest.php rename to tests/Constraints/DependenciesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/DisallowTest.php b/tests/Constraints/DisallowTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/DisallowTest.php rename to tests/Constraints/DisallowTest.php diff --git a/tests/JsonSchema/Tests/Constraints/DivisibleByTest.php b/tests/Constraints/DivisibleByTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/DivisibleByTest.php rename to tests/Constraints/DivisibleByTest.php diff --git a/tests/JsonSchema/Tests/Constraints/EnumTest.php b/tests/Constraints/EnumTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/EnumTest.php rename to tests/Constraints/EnumTest.php diff --git a/tests/JsonSchema/Tests/Constraints/ExtendsTest.php b/tests/Constraints/ExtendsTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/ExtendsTest.php rename to tests/Constraints/ExtendsTest.php diff --git a/tests/JsonSchema/Tests/Constraints/FactoryTest.php b/tests/Constraints/FactoryTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/FactoryTest.php rename to tests/Constraints/FactoryTest.php diff --git a/tests/JsonSchema/Tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/FormatTest.php rename to tests/Constraints/FormatTest.php diff --git a/tests/JsonSchema/Tests/Constraints/MinItemsMaxItemsTest.php b/tests/Constraints/MinItemsMaxItemsTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/MinItemsMaxItemsTest.php rename to tests/Constraints/MinItemsMaxItemsTest.php diff --git a/tests/JsonSchema/Tests/Constraints/MinLengthMaxLengthMultiByteTest.php b/tests/Constraints/MinLengthMaxLengthMultiByteTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/MinLengthMaxLengthMultiByteTest.php rename to tests/Constraints/MinLengthMaxLengthMultiByteTest.php diff --git a/tests/JsonSchema/Tests/Constraints/MinLengthMaxLengthTest.php b/tests/Constraints/MinLengthMaxLengthTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/MinLengthMaxLengthTest.php rename to tests/Constraints/MinLengthMaxLengthTest.php diff --git a/tests/JsonSchema/Tests/Constraints/MinimumMaximumTest.php b/tests/Constraints/MinimumMaximumTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/MinimumMaximumTest.php rename to tests/Constraints/MinimumMaximumTest.php diff --git a/tests/JsonSchema/Tests/Constraints/NotTest.php b/tests/Constraints/NotTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/NotTest.php rename to tests/Constraints/NotTest.php diff --git a/tests/JsonSchema/Tests/Constraints/NumberAndIntegerTypesTest.php b/tests/Constraints/NumberAndIntegerTypesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/NumberAndIntegerTypesTest.php rename to tests/Constraints/NumberAndIntegerTypesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php b/tests/Constraints/OfPropertiesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php rename to tests/Constraints/OfPropertiesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/PatternPropertiesTest.php b/tests/Constraints/PatternPropertiesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/PatternPropertiesTest.php rename to tests/Constraints/PatternPropertiesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/PatternTest.php b/tests/Constraints/PatternTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/PatternTest.php rename to tests/Constraints/PatternTest.php diff --git a/tests/JsonSchema/Tests/Constraints/ReadOnlyTest.php b/tests/Constraints/ReadOnlyTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/ReadOnlyTest.php rename to tests/Constraints/ReadOnlyTest.php diff --git a/tests/JsonSchema/Tests/Constraints/RequireTest.php b/tests/Constraints/RequireTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/RequireTest.php rename to tests/Constraints/RequireTest.php diff --git a/tests/JsonSchema/Tests/Constraints/RequiredPropertyTest.php b/tests/Constraints/RequiredPropertyTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/RequiredPropertyTest.php rename to tests/Constraints/RequiredPropertyTest.php diff --git a/tests/JsonSchema/Tests/Constraints/SelfDefinedSchemaTest.php b/tests/Constraints/SelfDefinedSchemaTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/SelfDefinedSchemaTest.php rename to tests/Constraints/SelfDefinedSchemaTest.php diff --git a/tests/JsonSchema/Tests/Constraints/TupleTypingTest.php b/tests/Constraints/TupleTypingTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/TupleTypingTest.php rename to tests/Constraints/TupleTypingTest.php diff --git a/tests/JsonSchema/Tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/TypeTest.php rename to tests/Constraints/TypeTest.php diff --git a/tests/JsonSchema/Tests/Constraints/UnionTypesTest.php b/tests/Constraints/UnionTypesTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/UnionTypesTest.php rename to tests/Constraints/UnionTypesTest.php diff --git a/tests/JsonSchema/Tests/Constraints/UnionWithNullValueTest.php b/tests/Constraints/UnionWithNullValueTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/UnionWithNullValueTest.php rename to tests/Constraints/UnionWithNullValueTest.php diff --git a/tests/JsonSchema/Tests/Constraints/UniqueItemsTest.php b/tests/Constraints/UniqueItemsTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/UniqueItemsTest.php rename to tests/Constraints/UniqueItemsTest.php diff --git a/tests/JsonSchema/Tests/Constraints/WrongMessagesFailingTestCaseTest.php b/tests/Constraints/WrongMessagesFailingTestCaseTest.php similarity index 100% rename from tests/JsonSchema/Tests/Constraints/WrongMessagesFailingTestCaseTest.php rename to tests/Constraints/WrongMessagesFailingTestCaseTest.php diff --git a/tests/JsonSchema/Tests/Drafts/BaseDraftTestCase.php b/tests/Drafts/BaseDraftTestCase.php similarity index 55% rename from tests/JsonSchema/Tests/Drafts/BaseDraftTestCase.php rename to tests/Drafts/BaseDraftTestCase.php index b8835459..59dcc972 100644 --- a/tests/JsonSchema/Tests/Drafts/BaseDraftTestCase.php +++ b/tests/Drafts/BaseDraftTestCase.php @@ -10,7 +10,7 @@ abstract class BaseDraftTestCase extends BaseTestCase { /** @var string */ - protected $relativeTestsRoot = '/../../../../vendor/json-schema/JSON-Schema-Test-Suite/tests'; + protected $relativeTestsRoot = '/../../vendor/json-schema/JSON-Schema-Test-Suite/tests'; private function setUpTests($isValid) { @@ -20,13 +20,18 @@ private function setUpTests($isValid) foreach ($filePaths as $path) { foreach (glob($path . '/*.json') as $file) { - if (!in_array(basename($file), $skippedTests)) { + $filename = basename($file); + if (!in_array($filename, $skippedTests)) { $suites = json_decode(file_get_contents($file)); foreach ($suites as $suite) { + $suiteDescription = $suite->description; foreach ($suite->tests as $test) { + $testCaseDescription = $test->description; if ($isValid === $test->valid) { - $tests[] = array(json_encode($test->data), json_encode($suite->schema)); - } + $tests[ + $this->createDataSetPath($filename, $suiteDescription, $testCaseDescription) + ] = array(json_encode($test->data), json_encode($suite->schema)); + } } } } @@ -61,4 +66,19 @@ protected abstract function getFilePaths(); * @return string[] */ protected abstract function getSkippedTests(); + + /** + * Generates a readable path to Json Schema Test Suite data set under test + * + * @param string $filename + * @param string $suiteDesc + * @param string $testCaseDesc + * + * @return string + */ + private function createDataSetPath($filename, $suiteDesc, $testCaseDesc) + { + $separator = ' / '; + return $filename . $separator . $suiteDesc . $separator . $testCaseDesc; + } } diff --git a/tests/JsonSchema/Tests/Drafts/Draft3Test.php b/tests/Drafts/Draft3Test.php similarity index 94% rename from tests/JsonSchema/Tests/Drafts/Draft3Test.php rename to tests/Drafts/Draft3Test.php index f1ca8f46..ee10f66a 100644 --- a/tests/JsonSchema/Tests/Drafts/Draft3Test.php +++ b/tests/Drafts/Draft3Test.php @@ -31,7 +31,9 @@ protected function getFilePaths() protected function getSkippedTests() { return array( + // Optional 'bignum.json', + 'format.json', 'jsregex.json', 'zeroTerminatedFloats.json' ); diff --git a/tests/JsonSchema/Tests/Drafts/Draft4Test.php b/tests/Drafts/Draft4Test.php similarity index 84% rename from tests/JsonSchema/Tests/Drafts/Draft4Test.php rename to tests/Drafts/Draft4Test.php index 2f7f0cbd..320cf61c 100644 --- a/tests/JsonSchema/Tests/Drafts/Draft4Test.php +++ b/tests/Drafts/Draft4Test.php @@ -33,7 +33,10 @@ protected function getSkippedTests() return array( // Optional 'bignum.json', - 'zeroTerminatedFloats.json' + 'format.json', + 'zeroTerminatedFloats.json', + // Required + 'not.json' // only one test case failing ); } } diff --git a/tests/JsonSchema/Tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php similarity index 100% rename from tests/JsonSchema/Tests/Entity/JsonPointerTest.php rename to tests/Entity/JsonPointerTest.php diff --git a/tests/JsonSchema/Tests/RefResolverTest.php b/tests/RefResolverTest.php similarity index 100% rename from tests/JsonSchema/Tests/RefResolverTest.php rename to tests/RefResolverTest.php diff --git a/tests/JsonSchema/Tests/Rfc3339Test.php b/tests/Rfc3339Test.php similarity index 100% rename from tests/JsonSchema/Tests/Rfc3339Test.php rename to tests/Rfc3339Test.php diff --git a/tests/JsonSchema/Tests/Uri/Fixture/child.json b/tests/Uri/Fixture/child.json similarity index 100% rename from tests/JsonSchema/Tests/Uri/Fixture/child.json rename to tests/Uri/Fixture/child.json diff --git a/tests/JsonSchema/Tests/Uri/Retrievers/FileGetContentsTest.php b/tests/Uri/Retrievers/FileGetContentsTest.php similarity index 88% rename from tests/JsonSchema/Tests/Uri/Retrievers/FileGetContentsTest.php rename to tests/Uri/Retrievers/FileGetContentsTest.php index 93fc7d6f..9c37a1cf 100644 --- a/tests/JsonSchema/Tests/Uri/Retrievers/FileGetContentsTest.php +++ b/tests/Uri/Retrievers/FileGetContentsTest.php @@ -21,7 +21,7 @@ public function testFetchMissingFile() public function testFetchFile() { $res = new FileGetContents(); - $result = $res->retrieve(__DIR__.'/../Fixture/child.json'); + $result = $res->retrieve(__DIR__ . '/../Fixture/child.json'); $this->assertNotEmpty($result); } } diff --git a/tests/JsonSchema/Tests/Uri/Retrievers/PredefinedArrayTest.php b/tests/Uri/Retrievers/PredefinedArrayTest.php similarity index 100% rename from tests/JsonSchema/Tests/Uri/Retrievers/PredefinedArrayTest.php rename to tests/Uri/Retrievers/PredefinedArrayTest.php diff --git a/tests/JsonSchema/Tests/Uri/UriResolverTest.php b/tests/Uri/UriResolverTest.php similarity index 100% rename from tests/JsonSchema/Tests/Uri/UriResolverTest.php rename to tests/Uri/UriResolverTest.php diff --git a/tests/JsonSchema/Tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php similarity index 100% rename from tests/JsonSchema/Tests/Uri/UriRetrieverTest.php rename to tests/Uri/UriRetrieverTest.php diff --git a/tests/JsonSchema/Tests/fixtures/json-schema-draft-03.json b/tests/fixtures/json-schema-draft-03.json similarity index 100% rename from tests/JsonSchema/Tests/fixtures/json-schema-draft-03.json rename to tests/fixtures/json-schema-draft-03.json diff --git a/tests/JsonSchema/Tests/fixtures/json-schema-draft-04.json b/tests/fixtures/json-schema-draft-04.json similarity index 100% rename from tests/JsonSchema/Tests/fixtures/json-schema-draft-04.json rename to tests/fixtures/json-schema-draft-04.json