File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,6 +170,17 @@ function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
170170 return $ path . '.crap4j.xml ' ;
171171 }
172172
173+ function __c3_build_cobertura_report (PHP_CodeCoverage $ codeCoverage , $ path )
174+ {
175+ if (!class_exists (\SebastianBergmann \CodeCoverage \Report \Cobertura::class)) {
176+ throw new Exception ("Cobertura report requires php-code-coverage >= 9.2 " );
177+ }
178+ $ writer = new \SebastianBergmann \CodeCoverage \Report \Cobertura ();
179+ $ writer ->process ($ codeCoverage , $ path . '.cobertura.xml ' );
180+
181+ return $ path . '.cobertura.xml ' ;
182+ }
183+
173184 function __c3_build_phpunit_report (PHP_CodeCoverage $ codeCoverage , $ path )
174185 {
175186 $ writer = new PHP_CodeCoverage_Report_XML (\PHPUnit_Runner_Version::id ());
@@ -339,6 +350,13 @@ function __c3_clear()
339350 __c3_error ($ e ->getMessage ());
340351 }
341352 return __c3_exit ();
353+ case 'cobertura ' :
354+ try {
355+ __c3_send_file (__c3_build_cobertura_report ($ codeCoverage , $ path ));
356+ } catch (Exception $ e ) {
357+ __c3_error ($ e ->getMessage ());
358+ }
359+ return __c3_exit ();
342360 }
343361} else {
344362 list ($ codeCoverage , ) = __c3_factory (null );
You can’t perform that action at this time.
0 commit comments