77use  CallbackFilterIterator ;
88use  JsonSchema \Constraints \Constraint ;
99use  JsonSchema \Constraints \Factory ;
10+ use  JsonSchema \DraftIdentifiers ;
1011use  JsonSchema \SchemaStorage ;
1112use  JsonSchema \SchemaStorageInterface ;
1213use  JsonSchema \Validator ;
@@ -28,14 +29,17 @@ public function testTestCaseValidatesCorrectly(
2829        $ schema ,
2930        $ data ,
3031        int  $ checkMode ,
32+         DraftIdentifiers   $ draft ,
3133        bool  $ expectedValidationResult ,
3234        bool  $ optional
3335    ): void  {
3436        $ schemaStorage  = new  SchemaStorage ();
3537        $ id  = is_object ($ schema ) && property_exists ($ schema , 'id ' ) ? $ schema ->id  : SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI ;
3638        $ schemaStorage ->addSchema ($ id , $ schema );
3739        $ this  ->loadRemotesIntoStorage ($ schemaStorage );
38-         $ validator  = new  Validator (new  Factory ($ schemaStorage ));
40+         $ factory  = new  Factory ($ schemaStorage );
41+         $ factory ->setDefaultDialect ($ draft ->getValue ());
42+         $ validator  = new  Validator ($ factory );
3943
4044        try  {
4145            $ validator ->validate ($ data , $ schema , $ checkMode );
@@ -64,7 +68,7 @@ public function casesDataProvider(): \Generator
6468        $ drafts  = array_filter (glob ($ testDir  . '/* ' ), static  function  (string  $ filename ) {
6569            return  is_dir ($ filename );
6670        });
67-         $ skippedDrafts  = ['draft2019-09 ' , 'draft2020-12 ' , 'draft-next ' , 'latest ' ];
71+         $ skippedDrafts  = ['draft3 '  ,  ' draft4 ' ,  ' draft6 ' ,  ' draft2019-09 ' , 'draft2020-12 ' , 'draft-next ' , 'latest ' ];
6872
6973        foreach  ($ drafts  as  $ draft ) {
7074            $ baseDraftName  = basename ($ draft );
@@ -105,6 +109,7 @@ function ($file) {
105109                            'schema '  => $ testCase ->schema ,
106110                            'data '  => $ test ->data ,
107111                            'checkMode '  => $ this  ->getCheckModeForDraft ($ baseDraftName ),
112+                             'draft '  => DraftIdentifiers::fromConstraintName ($ baseDraftName ),
108113                            'expectedValidationResult '  => $ test ->valid ,
109114                            'optional '  => str_contains ($ file ->getPathname (), '/optional/ ' )
110115                        ];
0 commit comments