Lines 1-5
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
use Test::More tests => 10; |
2 |
use Test::More tests => 11; |
|
|
3 |
use Test::NoWarnings; |
3 |
use Test::Warn; |
4 |
use Test::Warn; |
4 |
|
5 |
|
5 |
# Module under test |
6 |
# Module under test |
Lines 132-147
subtest 'Method chaining tests' => sub {
Link Here
|
132 |
isa_ok( $result, 't::lib::Mocks::Logger', 'Method chaining returns the logger object' ); |
133 |
isa_ok( $result, 't::lib::Mocks::Logger', 'Method chaining returns the logger object' ); |
133 |
}; |
134 |
}; |
134 |
|
135 |
|
135 |
# Test diag method (output capture is complex, just verify it runs) |
|
|
136 |
subtest 'Diag method test' => sub { |
136 |
subtest 'Diag method test' => sub { |
137 |
plan tests => 1; |
137 |
plan tests => 1; |
138 |
|
138 |
|
139 |
$logger->clear(); |
139 |
$logger->clear(); |
140 |
$mocked_logger->debug('Debug message'); |
140 |
$mocked_logger->debug('Debug message'); |
141 |
|
141 |
|
142 |
# Just make sure it doesn't throw an exception |
142 |
# Capture Test::Builder diag output |
143 |
eval { $logger->diag(); }; |
143 |
my $diag_output = ''; |
144 |
is( $@, '', 'diag() method executed without errors' ); |
144 |
open my $fake_fh, '>', \$diag_output or die "Can't open: $!"; |
|
|
145 |
|
146 |
my $tb = Test::More->builder; |
147 |
my $original_fh = $tb->failure_output; |
148 |
$tb->failure_output($fake_fh); # Redirect diag output |
149 |
|
150 |
$logger->diag(); |
151 |
|
152 |
$tb->failure_output($original_fh); |
153 |
|
154 |
like( $diag_output, qr/debug:\n#\s*"Debug message"/xms, 'Captured diag output' ); |
145 |
}; |
155 |
}; |
146 |
|
156 |
|
147 |
# Test handling of empty log buffers |
157 |
# Test handling of empty log buffers |
148 |
- |
|
|