@@ -56,6 +56,7 @@ class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Repor
56
56
class_alias ('SebastianBergmann\CodeCoverage\Report\Clover ' , 'PHP_CodeCoverage_Report_Clover ' );
57
57
class_alias ('SebastianBergmann\CodeCoverage\Report\Crap4j ' , 'PHP_CodeCoverage_Report_Crap4j ' );
58
58
class_alias ('SebastianBergmann\CodeCoverage\Report\Html\Facade ' , 'PHP_CodeCoverage_Report_HTML ' );
59
+ class_alias ('SebastianBergmann\CodeCoverage\Report\Xml\Facade ' , 'PHP_CodeCoverage_Report_PHPUnit ' );
59
60
class_alias ('SebastianBergmann\CodeCoverage\Exception ' , 'PHP_CodeCoverage_Exception ' );
60
61
}
61
62
@@ -162,6 +163,37 @@ function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
162
163
return $ path . '.crap4j.xml ' ;
163
164
}
164
165
166
+ function __c3_build_phpunit_report (PHP_CodeCoverage $ codeCoverage , $ path )
167
+ {
168
+ $ writer = new PHP_CodeCoverage_Report_PHPUnit ();
169
+ $ writer ->process ($ codeCoverage , $ path . 'phpunit ' );
170
+
171
+ if (file_exists ($ path . '.tar ' )) {
172
+ unlink ($ path . '.tar ' );
173
+ }
174
+
175
+ $ phar = new PharData ($ path . '.tar ' );
176
+ $ phar ->setSignatureAlgorithm (Phar::SHA1 );
177
+ $ files = $ phar ->buildFromDirectory ($ path . 'phpunit ' );
178
+ array_map ('unlink ' , $ files );
179
+
180
+ if (in_array ('GZ ' , Phar::getSupportedCompression ())) {
181
+ if (file_exists ($ path . '.tar.gz ' )) {
182
+ unlink ($ path . '.tar.gz ' );
183
+ }
184
+
185
+ $ phar ->compress (\Phar::GZ );
186
+
187
+ // close the file so that we can rename it
188
+ unset($ phar );
189
+
190
+ unlink ($ path . '.tar ' );
191
+ rename ($ path . '.tar.gz ' , $ path . '.tar ' );
192
+ }
193
+
194
+ return $ path . '.tar ' ;
195
+ }
196
+
165
197
function __c3_send_file ($ filename )
166
198
{
167
199
if (!headers_sent ()) {
@@ -285,6 +317,13 @@ function __c3_clear()
285
317
__c3_error ($ e ->getMessage ());
286
318
}
287
319
return __c3_exit ();
320
+ case 'phpunit ' :
321
+ try {
322
+ __c3_send_file (__c3_build_phpunit_report ($ codeCoverage , $ path ));
323
+ } catch (Exception $ e ) {
324
+ __c3_error ($ e ->getMessage ());
325
+ }
326
+ return __c3_exit ();
288
327
}
289
328
290
329
} else {
0 commit comments