XmlValidatorTest::testCheckTrue()   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 XmlValidatorTest extends \PHPUnit_Framework_TestCase
22
{
23
    protected $xml;
24
25
    public function setUp()
26
    {
27
        $this->xml = <<<XML
28
<?xml version="1.0"?>
29
<root>
30
    <name>chuck</name>
31
    <lastname>norris</lastname>
32
</root>
33
XML;
34
    }
35
36
    /**
37
     * testCheckTrue.
38
     */
39
    public function testCheckTrue()
40
    {
41
        $xmlValidator = new XmlValidator();
42
        $this->assertNull($xmlValidator->check($this->xml, '//name'));
43
    }
44
45
    /**
46
     * testException.
47
     *
48
     * @expectedException Hogosha\Monitor\Exception\ValidatorException
49
     * @expectedExceptionMessage this node "//nickname" does not exist
50
     */
51
    public function testException()
52
    {
53
        $xmlValidator = new XmlValidator();
54
        $xmlValidator->check($this->xml, '//nickname');
55
    }
56
57
    /**
58
     * testInvalidXml.
59
     *
60
     * @expectedException Hogosha\Monitor\Exception\ValidatorException
61
     * @expectedExceptionMessage This xml is not valid
62
     */
63
    public function testInvalidXml()
64
    {
65
        $xmlValidator = new XmlValidator();
66
        $xmlValidator->check('<xml></xml', '//nickanme');
67
    }
68
}
69