JsonValidatorTest::testInvalidJson()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the hogosha-monitor package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Hogosha\Monitor\Validator;
17
18
/**
19
 * @author Guillaume Cavana <[email protected]>
20
 */
21
class JsonValidatorTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * testCheckFalse.
25
     *
26
     * @expectedException Hogosha\Monitor\Exception\ValidatorException
27
     * @expectedExceptionMessage PropertyAccessor requires a graph of objects or arrays to operate on, but it found type "string" while trying to traverse path "name.toto" at property "toto".
28
     */
29
    public function testException()
30
    {
31
        $htmlValidator = new JsonValidator();
32
        $htmlValidator->check('{"name": "Chuck Norris"}', 'name.toto');
33
    }
34
35
    /**
36
     * testCheckFalse.
37
     *
38
     * @expectedException Hogosha\Monitor\Exception\ValidatorException
39
     * @expectedExceptionMessage This json is not valid
40
     */
41
    public function testInvalidJson()
42
    {
43
        $htmlValidator = new JsonValidator();
44
        $htmlValidator->check('{"name": "Chuck Norris"', 'name.toto');
45
    }
46
}
47