View | Details | Raw Unified | Return to bug 38299
Collapse All | Expand All

(-)a/t/Koha/Installer/Output.t (-2 / +39 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 4;
20
use Test::More tests => 8;
21
21
22
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
22
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
23
23
Lines 53-55 like( $lines[3], qr/\e\[\d+mTesting info message\e\[0m/, "Info message output Link Here
53
53
54
# Remove the temporary file
54
# Remove the temporary file
55
unlink $temp_file;
55
unlink $temp_file;
56
- 
56
57
# Next, test with no filehandler (letting say send to STDOUT by default)
58
59
# Redirect STDOUT to a variable - we don't actually want to print to the console for testing
60
my $temp_out;
61
open my $oldout, qw{>&}, "STDOUT";
62
close STDOUT;
63
open STDOUT, '>:encoding(utf8)', \$temp_out;
64
65
say_warning( undef, "Testing warning message with no fh" );
66
say_failure( undef, "Testing failure message with no fh" );
67
say_success( undef, "Testing success message with no fh" );
68
say_info( undef, "Testing info message with no fh" );
69
70
# Return STDOUT to previous state
71
close STDOUT;
72
open STDOUT, ">&", $oldout;
73
74
# Split the contents of $temp_out into an array for testing
75
my @nofh_lines = split( "\n", $temp_out );
76
77
# Test the output content
78
like(
79
    $nofh_lines[0], qr/\e\[\d+mTesting warning message with no fh\e\[0m/,
80
    "Warning message with no fh output with ANSI color code"
81
);
82
like(
83
    $nofh_lines[1], qr/\e\[\d+mTesting failure message with no fh\e\[0m/,
84
    "Failure message with no fh output with ANSI color code"
85
);
86
like(
87
    $nofh_lines[2], qr/\e\[\d+mTesting success message with no fh\e\[0m/,
88
    "Success message with no fh output with ANSI color code"
89
);
90
like(
91
    $nofh_lines[3], qr/\e\[\d+mTesting info message with no fh\e\[0m/,
92
    "Info message with no fh output with ANSI color code"
93
);

Return to bug 38299