@@ -26,23 +26,24 @@ public function init(string $use_colors = 'never', array $options = []): int
26
26
if (!file_exists ($ phpunit_xml_file )) {
27
27
$ phpunit_xml_file = './phpunit.xml.dist ' ;
28
28
}
29
- echo self ::CYAN . "\n==> Configuring phpunit-pretty-result-printer \n" . self ::RESET ;
30
- echo "\n " . self ::LWHITE . '[• ] ' . self ::GREEN . " Gathering installation details \n" . self ::RESET ;
29
+ echo self ::CYAN . "\n==> Configuring phpunit-pretty-result-printer \n" . self ::RESET ;
30
+ echo "\n " . self ::LWHITE . '[• ] ' . self ::GREEN . " Gathering installation details \n" . self ::RESET ;
31
31
$ result = $ this ->add_printer_class_to_phpunit_xml ($ phpunit_xml_file );
32
32
if ($ useCollision ) {
33
33
if (is_dir ('vendor/nunomaduro/collision ' )) {
34
34
$ result = $ this ->add_collision_to_phpunit_xml ($ phpunit_xml_file );
35
35
if ($ result === 0 ) {
36
- echo self ::GREEN . " ✔ Collision listener activated \n" . self ::RESET ;
36
+ echo self ::GREEN . " ✔ Collision listener activated \n" . self ::RESET ;
37
37
} else {
38
- echo self ::MAGENTA . " ⇢ Collision already installed \n" . self ::RESET ;
38
+ echo self ::MAGENTA . " ⇢ Collision already installed \n" . self ::RESET ;
39
39
}
40
40
} else {
41
- echo self ::RED . " ✖ Collision package not installed \n" . self ::RESET ;
41
+ echo self ::RED . " ✖ Collision package not installed \n" . self ::RESET ;
42
42
}
43
43
}
44
44
$ this ->copy_default_settings ('phpunit-printer.yml ' );
45
- echo self ::CYAN ."\n==> Configuration Complete \n" .self ::RESET ;
45
+ echo self ::CYAN . "\n==> Configuration Complete \n" . self ::RESET ;
46
+ echo "\n" ;
46
47
47
48
return $ result ;
48
49
}
@@ -54,19 +55,19 @@ private function add_printer_class_to_phpunit_xml(string $file = './phpunit.xml'
54
55
$ data = file_get_contents ($ PHPUNIT_FILE );
55
56
$ result = (int ) strpos ($ data , 'printerClass= ' );
56
57
if ($ result > 0 ) {
57
- echo self ::LWHITE . ' [•• ] ' . self ::LYELLOW . ' Printer class already configured in ' . self ::CYAN . "{$ PHPUNIT_FILE } \n" . self ::RESET ;
58
+ echo self ::LWHITE . ' [•• ] ' . self ::LYELLOW . ' Printer class already configured in ' . self ::CYAN . "{$ PHPUNIT_FILE } \n" . self ::RESET ;
58
59
59
60
return 0 ;
60
61
} else {
61
62
$ xml = simplexml_load_file ($ PHPUNIT_FILE );
62
63
$ xml ->addAttribute ('printerClass ' , 'Codedungeon\PHPUnitPrettyResultPrinter\Printer ' );
63
64
file_put_contents ($ PHPUNIT_FILE , $ xml ->asXML ());
64
- echo self ::LWHITE . ' [•• ] ' . self ::GREEN . ' Printer class successfully added to ' . self ::CYAN . $ PHPUNIT_FILE . self ::GREEN . " file \n" . self ::RESET ;
65
+ echo self ::LWHITE . ' [•• ] ' . self ::GREEN . ' Printer class successfully added to ' . self ::CYAN . $ PHPUNIT_FILE . self ::GREEN . " file \n" . self ::RESET ;
65
66
66
67
return 1 ;
67
68
}
68
69
} else {
69
- echo self ::RED . ' [•• ] Unable to locate valid ' . self ::YELLOW . $ PHPUNIT_FILE . self ::RED . ' file, you will need to set ' . self ::CYAN . 'printerClass ' . self ::RED . "manually \n" . self ::RESET ;
70
+ echo self ::RED . ' [•• ] Unable to locate valid ' . self ::YELLOW . $ PHPUNIT_FILE . self ::RED . ' file, you will need to set ' . self ::CYAN . 'printerClass ' . self ::RED . "manually \n" . self ::RESET ;
70
71
71
72
return -43 ;
72
73
}
@@ -98,18 +99,18 @@ private function add_collision_to_phpunit_xml(string $file = './phpunit.xml'): i
98
99
private function copy_default_settings (string $ file = 'phpunit-printer.yml ' )
99
100
{
100
101
$ CONFIG_FILE = $ file ;
101
- $ packageDefaultSettingFile = dirname (__FILE__ , 2 ). DIRECTORY_SEPARATOR . 'src/ ' . $ CONFIG_FILE ;
102
+ $ packageDefaultSettingFile = dirname (__FILE__ , 2 ) . DIRECTORY_SEPARATOR . 'src/ ' . $ CONFIG_FILE ;
102
103
103
104
$ copySettingFile = $ CONFIG_FILE ;
104
105
if (file_exists ($ packageDefaultSettingFile )) {
105
106
if (!file_exists ($ copySettingFile )) {
106
107
copy ($ packageDefaultSettingFile , $ copySettingFile );
107
- echo self ::LWHITE . ' [•••] ' . self ::GREEN . ' Configuration ' . self ::CYAN . './ ' . $ CONFIG_FILE . self ::GREEN . " copied to project root \n" . self ::RESET ;
108
+ echo self ::LWHITE . ' [•••] ' . self ::GREEN . ' Configuration ' . self ::CYAN . './ ' . $ CONFIG_FILE . self ::GREEN . " copied to project root \n" . self ::RESET ;
108
109
} else {
109
- echo self ::LWHITE . ' [•••] ' . self ::LYELLOW . ' Configuration ' . self ::CYAN . './ ' . $ CONFIG_FILE . self ::LYELLOW . " already exists \n" . self ::RESET ;
110
+ echo self ::LWHITE . ' [•••] ' . self ::LYELLOW . ' Configuration ' . self ::CYAN . './ ' . $ CONFIG_FILE . self ::LYELLOW . " already exists \n" . self ::RESET ;
110
111
}
111
112
} else {
112
- echo self ::LWHITE . ' [••E] ' . self ::RED . " An error occurred preparing configuration file \n" . self ::RESET ;
113
+ echo self ::LWHITE . ' [••E] ' . self ::RED . " An error occurred preparing configuration file \n" . self ::RESET ;
113
114
}
114
115
}
115
116
}
0 commit comments