File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -67,4 +67,31 @@ public function testDeprecatedCoerceDelegatesToValidate(): void
6767
6868 $ this ->assertTrue ($ validator ->isValid (), 'Validation failed, but should have succeeded. ' );
6969 }
70+
71+ /** @dataProvider draftIdentifiersNotSupportedForStrictMode */
72+ public function testItThrowsForStrictValidationOnDraft (DraftIdentifiers $ draft ): void
73+ {
74+ $ data = json_decode ('"42" ' , false );
75+ $ schema = json_decode ('{"type":"integer"} ' , false );
76+ $ factory = new Factory (null , null , Constraint::CHECK_MODE_NORMAL | Constraint::CHECK_MODE_STRICT );
77+ $ factory ->setDefaultDialect ($ draft ->getValue ());
78+ $ validator = new Validator ($ factory );
79+
80+ $ this ->expectException (InvalidArgumentException::class);
81+ $ this ->expectExceptionMessage ('Unknown constraint ' . $ draft ->toConstraintName ());
82+
83+ $ validator ->validate ($ data , $ schema );
84+ }
85+
86+ public function draftIdentifiersNotSupportedForStrictMode (): \Generator
87+ {
88+ foreach (DraftIdentifiers::getEnumerators () as $ draft ) {
89+ switch ($ draft ) {
90+ case DraftIdentifiers::DRAFT_6 ():
91+ break ;
92+ default :
93+ yield $ draft ->toConstraintName () => [$ draft ];
94+ }
95+ }
96+ }
7097}
You can’t perform that action at this time.
0 commit comments