@@ 27-44 (lines=18) @@ | ||
24 | * @expectedException \Graviton\JsonSchemaBundle\Validator\InvalidJsonException |
|
25 | * @expectedExceptionMessage Malformed JSON |
|
26 | */ |
|
27 | public function testValidateJsonDefinitionMalformedJson() |
|
28 | { |
|
29 | $schema = new \stdClass(); |
|
30 | $json = '[}'; |
|
31 | ||
32 | $validator = $this->getMockBuilder('JsonSchema\Validator') |
|
33 | ->disableOriginalConstructor() |
|
34 | ->getMock(); |
|
35 | $validator->expects($this->never()) |
|
36 | ->method('isValid'); |
|
37 | $validator->expects($this->never()) |
|
38 | ->method('getErrors'); |
|
39 | $validator->expects($this->never()) |
|
40 | ->method('check'); |
|
41 | ||
42 | $sut = new Validator($validator, $schema); |
|
43 | $this->assertEquals([], $sut->validateJsonDefinition($json)); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Test Validator::validateJsonDefinition() with non-object JSON |
|
@@ 53-70 (lines=18) @@ | ||
50 | * @expectedException \Graviton\JsonSchemaBundle\Validator\InvalidJsonException |
|
51 | * @expectedExceptionMessage JSON value must be an object |
|
52 | */ |
|
53 | public function testValidateJsonDefinitionNonObject() |
|
54 | { |
|
55 | $schema = new \stdClass(); |
|
56 | $json = '[]'; |
|
57 | ||
58 | $validator = $this->getMockBuilder('JsonSchema\Validator') |
|
59 | ->disableOriginalConstructor() |
|
60 | ->getMock(); |
|
61 | $validator->expects($this->never()) |
|
62 | ->method('isValid'); |
|
63 | $validator->expects($this->never()) |
|
64 | ->method('getErrors'); |
|
65 | $validator->expects($this->never()) |
|
66 | ->method('check'); |
|
67 | ||
68 | $sut = new Validator($validator, $schema); |
|
69 | $this->assertEquals([], $sut->validateJsonDefinition($json)); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * Test Validator::validateJsonDefinition() with errors |