XmlFileTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Fwk\Xml;
4
5
/**
6
 * Test class for XmlFile.
7
 * Generated by PHPUnit on 2012-07-25 at 22:30:05.
8
 */
9
class XmlFileTest extends \PHPUnit_Framework_TestCase {
10
11
    /**
12
     * @var XmlFile
13
     */
14
    protected $object;
15
16
    /**
17
     * Sets up the fixture, for example, opens a network connection.
18
     * This method is called before a test is executed.
19
     */
20
    protected function setUp() {
21
        $this->object = new XmlFile(__DIR__.'/not-exist.xml');
22
    }
23
24
    /**
25
     */
26
    public function testExists() {
27
        $this->assertFalse($this->object->exists());
28
    }
29
    
30
    public function testOpenException() {
31
        $this->setExpectedException('\Fwk\Xml\Exceptions\FileNotFoundException');
32
        $this->object->open();
33
    }
34
    
35
    public function testIsDirectoryException() {
36
        $this->setExpectedException('\InvalidArgumentException');
37
        $this->object = new XmlFile(__DIR__);
38
    }
39
    
40
    public function testGet()
41
    {
42
        $this->object = new XmlFile(__DIR__ .'/test.xml');
43
        $this->assertInstanceOf('\SimpleXMLElement', $this->object->__get('test'));
44
    }
45
    
46
    public function testBogusXml() {
47
        $this->object = new XmlFile(__DIR__ .'/test-bogus.xml');
48
        $this->setExpectedException('\Fwk\Xml\Exceptions\XmlErrorException');
49
        $this->object->open();
50
    }
51
}
52