t::lib::Mocks::Logger - A library to mock Koha::Logger for testing
my $logger = t::lib::Mocks::Logger->new();
Mocks the Koha::Logger for testing purposes. The mocked subs (log levels) return the passed string, in case we want to test the debugging string contents.
$logger->debug_is($expected);
Method for testing a message was written to the 'debug' log level.
$logger->error_is($expected);
Method for testing a message was written to the 'error' log level.
$logger->fatal_is($expected);
Method for testing a message was written to the 'fatal' log level.
$logger->info_is($expected);
Method for testing a message was written to the 'info' log level.
$logger->trace_is($expected);
Method for testing a message was written to the 'trace' log level.
$logger->warn_is($expected);
Method for testing a message was written to the 'warn' log level.
$logger->debug_like($expected);
Method for testing a message matching a regex was written to the 'debug' log level.
$logger->error_like($expected);
Method for testing a message matching a regex was written to the 'error' log level.
$logger->fatal_like($expected);
Method for testing a message matching a regex was written to the 'fatal' log level.
$logger->info_like($expected);
Method for testing a message matching a regex was written to the 'info' log level.
$logger->trace_like($expected);
Method for testing a message matching a regex was written to the 'trace' log level.
$logger->warn_like($expected);
Method for testing a message matching a regex was written to the 'warn' log level.
is( $logger->count( [ $level ] ), 0 'No logs!' );
Method for counting the generated messages. An optional $level parameter can be passed to restrict the count to the passed level.
$logger->debug_is( "Something", "Something was sent to 'debug'" ) ->warn_like( qr/^Something$/, "Something was sent to 'warn" ) ->clear( [ $level ] );
A method for resetting the mocked $logger object buffer. Useful to avoid inter-tests pollution.
Internal method to be used to build log level-specific exact string test methods.
Internal method to be used to build log level-specific regex string test methods.
Internal method that returns a list of valid log levels.