Completed
Push — develop ( d9306e...870f5e )
by Jaap
05:58
created

Version2Test::testItShouldUseDefinedVisibility()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Configuration\Factory;
14
15
use PHPUnit\Framework\TestCase;
16
17
/**
18
 * Test case for Version2
19
 *
20
 * @coversDefaultClass \phpDocumentor\Configuration\Factory\Version2
21
 */
22
final class Version2Test extends TestCase
23
{
24
    /**
25
     * @covers ::convert
26
     * @covers ::<private>
27
     */
28
    public function testItConvertsPhpdoc2XmlToAnArray()
29
    {
30
        $xml = new \SimpleXMLElement(__DIR__ . '/../../../data/phpdoc.tpl.xml', 0, true);
31
32
        $version2 = new Version2();
33
        $array = $version2->convert($xml);
34
35
        $this->assertEquals(Version2ExpectedArray::getDefaultArray(), $array);
36
    }
37
38
    /**
39
     * @covers ::<private>
40
     * @expectedException \Exception
41
     * @expectedExceptionMessage Root element name should be phpdocumentor, foo found
42
     */
43
    public function testItOnlyAcceptsAllowedXmlStructure()
44
    {
45
        $xml = <<<XML
46
<?xml version="1.0" encoding="UTF-8" ?>
47
<foo>
48
</foo>
49
XML;
50
51
        $xml = new \SimpleXMLElement($xml);
52
53
        $version2 = new Version2();
54
        $version2->convert($xml);
55
    }
56
57
    /**
58
     * @covers ::supports
59
     */
60
    public function testItMatchesWhenVersionIsEmpty()
61
    {
62
        $xml = new \SimpleXMLElement(__DIR__ . '/../../../data/phpdoc.tpl.xml', 0, true);
63
64
        $version2 = new Version2();
65
        $bool = $version2->supports($xml);
66
67
        $this->assertTrue($bool);
68
    }
69
70
    /**
71
     * @covers ::convert
72
     * @covers ::<private>
73
     */
74
    public function testItRevertsToDefaultsIfValuesAreNotInTheConfigurationFile()
75
    {
76
        $xml = new \SimpleXMLElement(
77
            __DIR__ . '/../../../data/phpDocumentor2XMLWithoutExtensions.xml',
78
            0,
79
            true
80
        );
81
82
        $version2 = new Version2();
83
        $array = $version2->convert($xml);
84
85
        $this->assertEquals(Version2ExpectedArray::getDefaultArray(), $array);
86
    }
87
88
    /**
89
     * @covers ::convert
90
     * @covers ::<private>
91
     */
92
    public function testItAcceptsMultipleIgnorePathsInThePhpdoc2Xml()
93
    {
94
        $xml = new \SimpleXMLElement(
95
            __DIR__ . '/../../../data/phpDocumentor2XMLWithMultipleIgnorePaths.xml',
96
            0,
97
            true
98
        );
99
100
        $version2 = new Version2();
101
        $array = $version2->convert($xml);
102
103
        $this->assertEquals(Version2ExpectedArray::getArrayWithMultipleIgnorePaths(), $array);
104
    }
105
106
    /**
107
     * @covers ::convert
108
     * @covers ::<private>
109
     */
110
    public function testItShouldUseTargetDirectoryFromTransformerForOutput()
111
    {
112
        $xml = new \SimpleXMLElement(
113
            __DIR__ . '/../../../data/phpDocumentor2XMLWithTarget.xml',
114
            0,
115
            true
116
        );
117
118
        $version2 = new Version2();
119
        $array = $version2->convert($xml);
120
121
        $this->assertEquals(Version2ExpectedArray::getCustomTargetConfig(), $array);
122
    }
123
124
    /**
125
     * @covers ::convert
126
     * @covers ::<private>
127
     */
128
    public function testItShouldUseDefinedVisibility()
129
    {
130
        $xml = new \SimpleXMLElement(
131
            __DIR__ . '/../../../data/phpDocumentor2XMLWithVisibility.xml',
132
            0,
133
            true
134
        );
135
136
        $version2 = new Version2();
137
        $array = $version2->convert($xml);
138
139
        $this->assertEquals(Version2ExpectedArray::getDefinedVisibility(), $array);
140
    }
141
}
142