@@ -2768,8 +2768,12 @@ function junit_save_xml() {
2768
2768
global $ JUNIT ;
2769
2769
if (!junit_enabled ()) return ;
2770
2770
2771
- $ xml = '< ' . '? ' . 'xml version="1.0" encoding="UTF-8" ' . '? ' . '> ' . PHP_EOL .
2772
- '<testsuites> ' . PHP_EOL ;
2771
+ $ xml = '< ' . '? ' . 'xml version="1.0" encoding="UTF-8" ' . '? ' . '> ' . PHP_EOL ;
2772
+ $ xml .= sprintf (
2773
+ '<testsuites name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s"> ' . PHP_EOL ,
2774
+ $ JUNIT ['name ' ], $ JUNIT ['test_total ' ], $ JUNIT ['test_fail ' ], $ JUNIT ['test_error ' ], $ JUNIT ['test_skip ' ],
2775
+ $ JUNIT ['execution_time ' ]
2776
+ );
2773
2777
$ xml .= junit_get_suite_xml ();
2774
2778
$ xml .= '</testsuites> ' ;
2775
2779
fwrite ($ JUNIT ['fp ' ], $ xml );
@@ -2778,26 +2782,23 @@ function junit_save_xml() {
2778
2782
function junit_get_suite_xml ($ suite_name = '' ) {
2779
2783
global $ JUNIT ;
2780
2784
2781
- $ suite = $ suite_name ? $ JUNIT ['suites ' ][$ suite_name ] : $ JUNIT ;
2782
-
2783
- $ result = sprintf (
2784
- '<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s"> ' . PHP_EOL ,
2785
- $ suite ['name ' ], $ suite ['test_total ' ], $ suite ['test_fail ' ], $ suite ['test_error ' ], $ suite ['test_skip ' ],
2786
- $ suite ['execution_time ' ]
2787
- );
2785
+ $ result = "" ;
2788
2786
2789
- foreach ($ suite ['suites ' ] as $ sub_suite ) {
2790
- $ result .= junit_get_suite_xml ($ sub_suite ['name ' ]);
2791
- }
2787
+ foreach ($ JUNIT ['suites ' ] as $ suite_name => $ suite ) {
2788
+ $ result .= sprintf (
2789
+ '<testsuite name="%s" tests="%s" failures="%d" errors="%d" skip="%d" time="%s"> ' . PHP_EOL ,
2790
+ $ suite ['name ' ], $ suite ['test_total ' ], $ suite ['test_fail ' ], $ suite ['test_error ' ], $ suite ['test_skip ' ],
2791
+ $ suite ['execution_time ' ]
2792
+ );
2792
2793
2793
- // Output files only in subsuites
2794
- if (! empty ( $ suite_name ) ) {
2795
- foreach ( $ suite ['files ' ] as $ file) {
2796
- $ result .= $ JUNIT [ ' files ' ][ $ file ][ ' xml ' ];
2794
+ if (! empty ( $ suite_name )) {
2795
+ foreach ( $ suite [ ' files ' ] as $ file ) {
2796
+ $ result .= $ JUNIT ['files ' ][ $ file][ ' xml ' ];
2797
+ }
2797
2798
}
2798
- }
2799
2799
2800
- $ result .= '</testsuite> ' . PHP_EOL ;
2800
+ $ result .= '</testsuite> ' . PHP_EOL ;
2801
+ }
2801
2802
2802
2803
return $ result ;
2803
2804
}
0 commit comments