Repository navigation
test: Keep the #926 keyword dispatch map in sync and fix its tests - #993
Open
Roman3349 wants to merge 3 commits into
Conversation
…ints The draft constraints only dispatch a keyword when one of the schema properties mapped to it is present. A keyword whose schema property differs from its name and is missing from KEYWORD_SCHEMA_PROPERTIES is silently never checked. The test compares, for every keyword in each draft factory, the schema properties in the first condition of the constraint's check() with the properties the dispatcher checks. Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
- The test named after dependentSchemas and dependentRequired only used dependentRequired, so dependentSchemas was not covered. Both are now covered separately. - The draft constraints always run with their own draft factory, and may call methods only that factory has, such as getDynamicScope() needed for $recursiveRef in Draft 2019-09. A mock of the base factory lacks them, so the tests mock the draft factory. Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #926, targeting its branch. It addresses the review comments on #926:
KeywordSchemaPropertiesTest: keepsKEYWORD_SCHEMA_PROPERTIESin sync with the keyword constraints. For every keyword in each draft factory'sconstraintMap, it compares the schema properties in the first condition of the constraint'scheck()with the properties the dispatcher checks. A keyword whose schema property differs from its name and is missing from the map would otherwise silently never run.contentis skipped, because itscheck()is a no-op.Draft2019Constraint: recursiveRefuntil'recursiveRef' => ['$recursiveRef']is added to the map. With that entry, the whole suite passes.dependentSchemasanddependentRequiredonly useddependentRequired(the Copilot review comment). Both are now covered separately.JsonSchema\Constraints\Factory, but the draft constraints always run with their own draft factory and may call methods only that factory has. Merged with feat: Support $recursiveRef in Draft 2019-09 #984, all Draft 2019-09 dispatcher tests failed withCall to undefined method Mock_Factory_…::getDynamicScope(). The tests now mock the draft factory.KEYWORD_SCHEMA_PROPERTIESis declared at the top of the class instead of betweencheck()andcheckForKeyword().Related Issue
Related to #920 and #926
Type of Change
Checklist
Additional Notes
Verified on this branch merged with the current
main(10162 tests pass), and additionally merged with #984 plus therecursiveRefmap entry (10186 tests pass).A correction to the BC concern I raised on #926: custom constraint classes registered with
Factory::setConstraintClass()on the factory passed to theValidatornever reach strict mode at all, because eachDraft*Constraintcreates its own draft factory and only takes the schema storage, URI retriever and config from the given one. So the gating only affects a subclass of aDraft*Constraintthat registers a custom keyword on the draft factory, and only when that keyword's name differs from its schema property. That is narrow enough not to block #926.