1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Test case |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2007-2010, Mayflower GmbH |
7
|
|
|
* All rights reserved. |
8
|
|
|
* |
9
|
|
|
* Redistribution and use in source and binary forms, with or without |
10
|
|
|
* modification, are permitted provided that the following conditions |
11
|
|
|
* are met: |
12
|
|
|
* |
13
|
|
|
* * Redistributions of source code must retain the above copyright |
14
|
|
|
* notice, this list of conditions and the following disclaimer. |
15
|
|
|
* |
16
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
17
|
|
|
* notice, this list of conditions and the following disclaimer in |
18
|
|
|
* the documentation and/or other materials provided with the |
19
|
|
|
* distribution. |
20
|
|
|
* |
21
|
|
|
* * Neither the name of Mayflower GmbH nor the names of his |
22
|
|
|
* contributors may be used to endorse or promote products derived |
23
|
|
|
* from this software without specific prior written permission. |
24
|
|
|
* |
25
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
26
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
27
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
28
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
29
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
30
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
31
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
32
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
33
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
34
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
35
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
36
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
37
|
|
|
* |
38
|
|
|
* @category PHP_CodeBrowser |
39
|
|
|
* |
40
|
|
|
* @author Simon Kohlmeyer <[email protected] |
41
|
|
|
* |
42
|
|
|
* @copyright 2007-2010 Mayflower GmbH |
43
|
|
|
* |
44
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
45
|
|
|
* |
46
|
|
|
* @version SVN: $Id$ |
47
|
|
|
* |
48
|
|
|
* @link http://www.phpunit.de/ |
49
|
|
|
* |
50
|
|
|
* @since File available since 0.9.0 |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
namespace PHPCodeBrowser\Tests\Plugins; |
54
|
|
|
|
55
|
|
|
use DOMDocument; |
56
|
|
|
use PHPCodeBrowser\File; |
57
|
|
|
use PHPCodeBrowser\Issue; |
58
|
|
|
use PHPCodeBrowser\IssueXML; |
59
|
|
|
use PHPCodeBrowser\Plugins\ErrorCoverage; |
60
|
|
|
use PHPCodeBrowser\Tests\AbstractTestCase; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* ErrorCoverageTest |
64
|
|
|
* |
65
|
|
|
* @category PHP_CodeBrowser |
66
|
|
|
* |
67
|
|
|
* @author Simon Kohlmeyer <[email protected]> |
68
|
|
|
* |
69
|
|
|
* @copyright 2007-2010 Mayflower GmbH |
70
|
|
|
* |
71
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
72
|
|
|
* |
73
|
|
|
* @version Release: @package_version@ |
74
|
|
|
* |
75
|
|
|
* @link http://www.phpunit.de/ |
76
|
|
|
* |
77
|
|
|
* @since Class available since 0.9.0 |
78
|
|
|
*/ |
79
|
|
|
class ErrorCoverageTest extends AbstractTestCase |
80
|
|
|
{ |
81
|
|
|
/** |
82
|
|
|
* The object to test. |
83
|
|
|
* |
84
|
|
|
* @var ErrorCoverage |
85
|
|
|
*/ |
86
|
|
|
protected $errorCoverage; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* The xml string to test the plugin against. |
90
|
|
|
* |
91
|
|
|
* @var string |
92
|
|
|
*/ |
93
|
|
|
protected $testXml = <<<HERE |
94
|
|
|
<?xml version="1.0" encoding="UTF-8"?> |
95
|
|
|
<coverage generated="1279365369"> |
96
|
|
|
<project timestamp="1279365369"> |
97
|
|
|
<file name="/partly/tested"> |
98
|
|
|
<line num="1" type="stmt" count="1"/> |
99
|
|
|
<line num="2" type="stmt" count="1"/> |
100
|
|
|
<line num="3" type="stmt" count="2"/> |
101
|
|
|
<line num="4" type="stmt" count="2"/> |
102
|
|
|
<line num="5" type="stmt" count="1"/> |
103
|
|
|
<line num="10" type="stmt" count="0"/> |
104
|
|
|
<line num="11" type="stmt" count="0"/> |
105
|
|
|
<line num="12" type="stmt" count="0"/> |
106
|
|
|
<line num="13" type="stmt" count="0"/> |
107
|
|
|
<line num="14" type="stmt" count="0"/> |
108
|
|
|
<line num="21" type="stmt" count="2"/> |
109
|
|
|
<line num="22" type="stmt" count="2"/> |
110
|
|
|
</file> |
111
|
|
|
<file name="/totally/tested"> |
112
|
|
|
<line num="212" type="stmt" count="2"/> |
113
|
|
|
<line num="213" type="stmt" count="2"/> |
114
|
|
|
<line num="215" type="stmt" count="2"/> |
115
|
|
|
<line num="216" type="stmt" count="2"/> |
116
|
|
|
</file> |
117
|
|
|
<file name="/not/tested"> |
118
|
|
|
<line num="212" type="stmt" count="0"/> |
119
|
|
|
<line num="213" type="stmt" count="0"/> |
120
|
|
|
<line num="214" type="stmt" count="0"/> |
121
|
|
|
<line num="216" type="stmt" count="0"/> |
122
|
|
|
<line num="219" type="stmt" count="0"/> |
123
|
|
|
<line num="220" type="stmt" count="0"/> |
124
|
|
|
<line num="221" type="stmt" count="0"/> |
125
|
|
|
<line num="224" type="stmt" count="0"/> |
126
|
|
|
<line num="225" type="stmt" count="0"/> |
127
|
|
|
</file> |
128
|
|
|
</project> |
129
|
|
|
</coverage> |
130
|
|
|
HERE; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* (non-PHPDoc) |
134
|
|
|
* |
135
|
|
|
* @see tests/cbAbstractTests#setUp() |
136
|
|
|
*/ |
137
|
|
|
protected function setUp(): void |
138
|
|
|
{ |
139
|
|
|
parent::setUp(); |
140
|
|
|
$issueXML = new IssueXML(); |
141
|
|
|
$xml = new DOMDocument('1.0', 'UTF-8'); |
142
|
|
|
$xml->loadXML($this->testXml); |
143
|
|
|
$issueXML->addXMLFile($xml); |
144
|
|
|
$this->errorCoverage = new ErrorCoverage($issueXML); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Test getFileList |
149
|
|
|
* |
150
|
|
|
* @return void |
151
|
|
|
*/ |
152
|
|
|
public function testGettingFileList(): void |
153
|
|
|
{ |
154
|
|
|
$expected = [ |
155
|
|
|
new File( |
156
|
|
|
'/partly/tested', |
157
|
|
|
[ |
158
|
|
|
new Issue( |
159
|
|
|
'/partly/tested', |
160
|
|
|
10, |
161
|
|
|
14, |
162
|
|
|
'Coverage', |
163
|
|
|
'Not covered', |
164
|
|
|
'Notice' |
165
|
|
|
), |
166
|
|
|
] |
167
|
|
|
), |
168
|
|
|
new File( |
169
|
|
|
'/totally/tested', |
170
|
|
|
[] |
171
|
|
|
), |
172
|
|
|
new File( |
173
|
|
|
'/not/tested', |
174
|
|
|
[ |
175
|
|
|
new Issue( |
176
|
|
|
'/not/tested', |
177
|
|
|
212, |
178
|
|
|
225, |
179
|
|
|
'Coverage', |
180
|
|
|
'Not covered', |
181
|
|
|
'Notice' |
182
|
|
|
), |
183
|
|
|
] |
184
|
|
|
), |
185
|
|
|
]; |
186
|
|
|
$actual = $this->errorCoverage->getFileList(); |
187
|
|
|
static::assertEquals($expected, $actual); |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|