@@ -2748,7 +2748,7 @@ function junit_init() {
2748
2748
} else {
2749
2749
$ JUNIT = array (
2750
2750
'fp ' => $ fp ,
2751
- 'name ' => 'php-src ' ,
2751
+ 'name ' => 'PHP ' ,
2752
2752
'test_total ' => 0 ,
2753
2753
'test_pass ' => 0 ,
2754
2754
'test_fail ' => 0 ,
@@ -2768,7 +2768,7 @@ 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 .
2771
+ $ xml = '< ' . ' ? ' . ' xml version="1.0" encoding="UTF-8" ' . ' ? ' . ' > ' . PHP_EOL .
2772
2772
'<testsuites> ' . PHP_EOL ;
2773
2773
$ xml .= junit_get_suite_xml ();
2774
2774
$ xml .= '</testsuites> ' ;
@@ -2833,8 +2833,8 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null, $messag
2833
2833
}, $ escaped_details );
2834
2834
$ escaped_message = htmlspecialchars ($ message , ENT_QUOTES , 'UTF-8 ' );
2835
2835
2836
- $ escaped_test_name = basename ( $ file_name ) . ' - ' . htmlspecialchars ($ test_name , ENT_QUOTES );
2837
- $ JUNIT ['files ' ][$ file_name ]['xml ' ] = "<testcase classname=' $ suite' name=' $ escaped_test_name' time=' $ time'> \n" ;
2836
+ $ escaped_test_name = htmlspecialchars ($ test_name , ENT_QUOTES );
2837
+ $ JUNIT ['files ' ][$ file_name ]['xml ' ] = "<testcase classname=' " . $ suite . " . " . basename ( $ file_name ) . " ' name=' $ escaped_test_name' time=' $ time'> \n" ;
2838
2838
2839
2839
if (is_array ($ type )) {
2840
2840
$ output_type = $ type [0 ] . 'ED ' ;
@@ -2904,7 +2904,33 @@ function junit_get_suitename_for($file_name) {
2904
2904
2905
2905
function junit_path_to_classname ($ file_name ) {
2906
2906
global $ JUNIT ;
2907
- return $ JUNIT ['name ' ] . '. ' . str_replace (DIRECTORY_SEPARATOR , '. ' , $ file_name );
2907
+
2908
+ $ ret = $ JUNIT ['name ' ];
2909
+ $ _tmp = array ();
2910
+
2911
+ // lookup whether we're in the PHP source checkout
2912
+ $ max = 5 ;
2913
+ if (is_file ($ file_name )) {
2914
+ $ dir = dirname (realpath ($ file_name ));
2915
+ } else {
2916
+ $ dir = realpath ($ file_name );
2917
+ }
2918
+ do {
2919
+ array_unshift ($ _tmp , basename ($ dir ));
2920
+ $ chk = $ dir . DIRECTORY_SEPARATOR . "main " . DIRECTORY_SEPARATOR . "php_version.h " ;
2921
+ $ dir = dirname ($ dir );
2922
+ } while (!file_exists ($ chk ) && --$ max > 0 );
2923
+ if (file_exists ($ chk )) {
2924
+ if ($ max ) {
2925
+ array_shift ($ _tmp );
2926
+ }
2927
+ foreach ($ _tmp as $ p ) {
2928
+ $ ret = $ ret . ". " . preg_replace (",[^a-z0-9]+,i " , ". " , $ p );
2929
+ }
2930
+ return $ ret ;
2931
+ }
2932
+
2933
+ return $ JUNIT ['name ' ] . '. ' . str_replace (array (DIRECTORY_SEPARATOR , '- ' ), '. ' , $ file_name );
2908
2934
}
2909
2935
2910
2936
function junit_init_suite ($ suite_name ) {
0 commit comments