@@ -14,7 +14,8 @@ public function test_validation_should_be_delegated_to_internal_validator()
14
14
$ this ->calling ($ validator )->check = null ,
15
15
$ refResolver = $ this ->mockJsonSchemaRefResolver (),
16
16
$ this ->calling ($ refResolver )->resolve = 'resolvedJsonSchema ' ,
17
- $ this ->newTestedInstance ($ validator , $ refResolver )
17
+ $ jsonSchemaTools = $ this ->mockJsonSchemaTools ($ validator , $ refResolver ),
18
+ $ this ->newTestedInstance ($ jsonSchemaTools )
18
19
)
19
20
->when (
20
21
$ this ->testedInstance ->validate ('"json" ' , __DIR__ .'/../Fixtures/mySchema.json ' )
@@ -31,7 +32,8 @@ public function test_unknown_json_schema_lead_to_exception()
31
32
{
32
33
$ this
33
34
->given (
34
- $ this ->newTestedInstance ($ this ->mockJsonSchemaValidator (), $ this ->mockJsonSchemaRefResolver ())
35
+ $ jsonSchemaTools = $ this ->mockJsonSchemaTools (),
36
+ $ this ->newTestedInstance ($ jsonSchemaTools )
35
37
)
36
38
->exception (function () {
37
39
$ this ->testedInstance ->validate ('"json" ' , 'hello.json ' );
@@ -50,7 +52,8 @@ public function test_invalid_internal_validation_lead_to_exception()
50
52
$ this ->calling ($ validator )->getErrors = ['error1 ' , 'error2 ' ],
51
53
$ refResolver = $ this ->mockJsonSchemaRefResolver (),
52
54
$ this ->calling ($ refResolver )->resolve = 'resolvedJsonSchema ' ,
53
- $ this ->newTestedInstance ($ validator , $ refResolver )
55
+ $ jsonSchemaTools = $ this ->mockJsonSchemaTools ($ validator , $ refResolver ),
56
+ $ this ->newTestedInstance ($ jsonSchemaTools )
54
57
)
55
58
->exception (function () {
56
59
$ this ->testedInstance ->validate ('"json" ' , __DIR__ .'/../Fixtures/mySchema.json ' );
@@ -74,4 +77,14 @@ private function mockJsonSchemaRefResolver()
74
77
75
78
return new \mock \JsonSchema \RefResolver ;
76
79
}
80
+
81
+ private function mockJsonSchemaTools ($ validator = null , $ refResolver = null )
82
+ {
83
+ $ this ->mockGenerator ->orphanize ('__construct ' );
84
+ $ mock = new \mock \Rezzza \SymfonyRestApiJson \JsonSchemaTools ;
85
+ $ this ->calling ($ mock )->createValidator = $ validator ;
86
+ $ this ->calling ($ mock )->createRefResolver = $ refResolver ;
87
+
88
+ return $ mock ;
89
+ }
77
90
}
0 commit comments