9
9
10
10
namespace JsonSchema \Tests \Constraints ;
11
11
12
+ use JsonSchema \RefResolver ;
13
+ use JsonSchema \Uri \UriRetriever ;
12
14
use JsonSchema \Validator ;
13
15
14
16
abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
@@ -18,9 +20,14 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
18
20
*/
19
21
public function testInvalidCases ($ input , $ schema , $ checkMode = Validator::CHECK_MODE_NORMAL , $ errors = array ())
20
22
{
23
+ $ schema = json_decode ($ schema );
24
+
25
+ $ refResolver = new RefResolver (new UriRetriever );
26
+ $ refResolver ->resolve ($ schema );
27
+
21
28
$ validator = new Validator ($ checkMode );
22
29
23
- $ validator ->check (json_decode ($ input ), json_decode ( $ schema) );
30
+ $ validator ->check (json_decode ($ input ), $ schema );
24
31
25
32
if (array () !== $ errors ) {
26
33
$ this ->assertEquals ($ errors , $ validator ->getErrors (), print_r ($ validator ->getErrors (),true ));
@@ -33,13 +40,18 @@ public function testInvalidCases($input, $schema, $checkMode = Validator::CHECK_
33
40
*/
34
41
public function testValidCases ($ input , $ schema , $ checkMode = Validator::CHECK_MODE_NORMAL )
35
42
{
43
+ $ schema = json_decode ($ schema );
44
+
45
+ $ refResolver = new RefResolver (new UriRetriever );
46
+ $ refResolver ->resolve ($ schema );
47
+
36
48
$ validator = new Validator ($ checkMode );
37
49
38
- $ validator ->check (json_decode ($ input ), json_decode ( $ schema) );
50
+ $ validator ->check (json_decode ($ input ), $ schema );
39
51
$ this ->assertTrue ($ validator ->isValid (), print_r ($ validator ->getErrors (), true ));
40
52
}
41
53
42
54
abstract public function getValidTests ();
43
55
44
56
abstract public function getInvalidTests ();
45
- }
57
+ }
0 commit comments