Skip to content

Unskip official test + various test suite enhancements #191

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

Closed
wants to merge 3 commits into from

Conversation

stefk
Copy link

@stefk stefk commented Oct 11, 2015

Hi,

The main goal of this PR is to unskip the zero terminated floats test from the official suite.

It turns out that the issue doesn't come from the validator itself, but from the way test cases are loaded, i.e. using a json_encode extra step (here) which casts zero terminated floats to integers. The encoding option JSON_PRESERVE_ZERO_FRACTION could help, but it's only available as of PHP 5.6.6.

So... long story short, I took the liberty to refactor the test suite in order to address this issue, and while I was at it, to make improvements where I could in the testing setup. Here are the results:

  • All the tests in Tests\Constraints which previously used PHP strings to store JSON data are now based entirely on independent JSON files, containing the data needed to execute them, just like in the official JSON Schema suite.
  • A new test case class, ValidatorTestCase, provides the main test method as well as helpers for all the tests based on JSON files (i.e. both constraint and draft tests).
  • The getSkippedTests method is replaced by a whitelist/blacklist functionality, allowing to quickly include/exclude tests during development.
  • Default failure messages and diffs from PHPUnit are minimized and errors now appear in a clean and readable format. Example:
**********************************************************************

File: arrays.json

Test: valid test #2 (check mode: 1)

Schema: {
    "type": "object",
    ...
}

Instance: {
    "data": [
        1,
        2,
       ...
    ]
}

Expected: no error

Actual: [
    {
        "property": "data[3]",
        "message": "string value found, but an integer is required"
    }
]

**********************************************************************
  • There're now 4 more tests in the suite (zero terminated floats for draft3 and 4).Obviously, all the previous tests are still working.

@@ -3,6 +3,7 @@
!/bin/validate-json
coverage
.buildpath
.idea
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the global ignore

@bighappyface
Copy link
Collaborator

@stefk thanks a ton for this work. The improved consistency with the full JSON Schema test suite is very welcome.

I must admit that it is a large PR and difficult to review considering the amount of PHP string to JSON conversion, but it looks like we are good to go.

All that I ask now is for another member in the community to approve and I will move forward with a merge and rolling another version.

+1

@bighappyface
Copy link
Collaborator

@stefk I have merged #186 and you can rework this PR upon it. I'll merge this in when ready.

@stefk stefk force-pushed the zero-terminated-floats branch from 7ca151c to 09a44ce Compare November 11, 2015 17:09
@stefk stefk force-pushed the zero-terminated-floats branch from 09a44ce to 8db4faf Compare November 11, 2015 17:44
@stefk
Copy link
Author

stefk commented Nov 11, 2015

@bighappyface, done and rebased.

@bighappyface
Copy link
Collaborator

@stefk oops, this has gone into conflict again. Please rebase once more and I'll get this through.

@bighappyface
Copy link
Collaborator

Closed due to age

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants