13
13
class PHPUnit extends AbstractEnricher implements
14
14
EndEnricherInterface, ClassEnricherInterface, TraitEnricherInterface, TokenFileEnricherInterface {
15
15
16
- const XMLNS = 'http://schema.phpunit.de/coverage/1.0 ' ;
16
+ const XMLNS_HTTP = 'http://schema.phpunit.de/coverage/1.0 ' ;
17
+ const XMLNS_HTTPS = 'https://schema.phpunit.de/coverage/1.0 ' ;
17
18
18
19
/**
19
20
* @var Fileinfo
20
21
*/
21
22
private $ coveragePath ;
22
23
24
+ /**
25
+ * @var string
26
+ */
27
+ private $ namespaceURI ;
28
+
23
29
/**
24
30
* @var FileInfo
25
31
*/
@@ -63,7 +69,7 @@ public function enrichEnd(PHPDoxEndEvent $event) {
63
69
}
64
70
/** @var fDOMElement $classNode */
65
71
$ container = $ this ->getEnrichtmentContainer ($ classNode , 'phpunit ' );
66
- $ resultNode = $ container ->appendElementNS (self :: XMLNS , 'result ' );
72
+ $ resultNode = $ container ->appendElementNS ($ this -> namespaceURI , 'result ' );
67
73
foreach ($ results as $ key => $ value ) {
68
74
$ resultNode ->setAttribute (mb_strtolower ($ key ), $ value );
69
75
}
@@ -125,13 +131,16 @@ private function loadXML($fname) {
125
131
$ dom = new fDOMDocument ();
126
132
$ dom ->load ($ fname );
127
133
128
- if ($ dom ->documentElement ->namespaceURI != self ::XMLNS ) {
134
+ $ this ->namespaceURI = $ dom ->documentElement ->namespaceURI ;
135
+
136
+ if (!in_array ($ this ->namespaceURI , [self ::XMLNS_HTTP , self ::XMLNS_HTTPS ])) {
129
137
throw new EnricherException (
130
138
'Wrong namspace - not a PHPUnit code coverage file ' ,
131
139
EnricherException::LoadError
132
140
);
133
141
}
134
- $ dom ->registerNamespace ('pu ' , self ::XMLNS );
142
+
143
+ $ dom ->registerNamespace ('pu ' , $ this ->namespaceURI );
135
144
136
145
return $ dom ;
137
146
} catch (fDOMException $ e ) {
@@ -156,7 +165,7 @@ private function processUnit(fDOMDocument $unit, fDOMDocument $coverage) {
156
165
// This class seems to be newer than the last phpunit run
157
166
return ;
158
167
}
159
- $ coverageTarget = $ enrichment ->appendElementNS (self :: XMLNS , 'coverage ' );
168
+ $ coverageTarget = $ enrichment ->appendElementNS ($ this -> namespaceURI , 'coverage ' );
160
169
foreach (array ('executable ' ,'executed ' , 'crap ' ) as $ attr ) {
161
170
$ coverageTarget ->appendChild (
162
171
$ coverageTarget ->ownerDocument ->importNode ($ classNode ->getAttributeNode ($ attr ))
@@ -181,7 +190,7 @@ private function processUnit(fDOMDocument $unit, fDOMDocument $coverage) {
181
190
$ end = $ method ->getAttribute ('end ' );
182
191
183
192
$ enrichment = $ this ->getEnrichtmentContainer ($ method , 'phpunit ' );
184
- $ coverageTarget = $ enrichment ->appendElementNS (self :: XMLNS , 'coverage ' );
193
+ $ coverageTarget = $ enrichment ->appendElementNS ($ this -> namespaceURI , 'coverage ' );
185
194
186
195
/** @var fDOMElement $coverageMethod */
187
196
$ coverageMethod = $ coverage ->queryOne (
0 commit comments