Skip to content

Bump json-schema/JSON-Schema-Test-Suite to 1.2.0 + some tests improvements #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
"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"
}
}
}],
"require": {
"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"
},
"autoload": {
"psr-4": { "JsonSchema\\": "src/JsonSchema/" }
},
"autoload-dev": {
"psr-4": { "JsonSchema\\Tests\\": "tests/JsonSchema/Tests/" }
"psr-4": { "JsonSchema\\Tests\\": "tests/" }
},
"bin": ["bin/validate-json"],
"extra": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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));
}
}
}
}
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ protected function getFilePaths()
protected function getSkippedTests()
{
return array(
// Optional
'bignum.json',
'format.json',
'jsregex.json',
'zeroTerminatedFloats.json'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}