<<

NAME

t::lib::Mocks::Logger - A library to mock Koha::Logger for testing

API

Methods

new

    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.

debug_is

    $logger->debug_is($expected);

Method for testing a message was written to the 'debug' log level.

error_is

    $logger->error_is($expected);

Method for testing a message was written to the 'error' log level.

fatal_is

    $logger->fatal_is($expected);

Method for testing a message was written to the 'fatal' log level.

info_is

    $logger->info_is($expected);

Method for testing a message was written to the 'info' log level.

trace_is

    $logger->trace_is($expected);

Method for testing a message was written to the 'trace' log level.

warn_is

    $logger->warn_is($expected);

Method for testing a message was written to the 'warn' log level.

debug_like

    $logger->debug_like($expected);

Method for testing a message matching a regex was written to the 'debug' log level.

error_like

    $logger->error_like($expected);

Method for testing a message matching a regex was written to the 'error' log level.

fatal_like

    $logger->fatal_like($expected);

Method for testing a message matching a regex was written to the 'fatal' log level.

info_like

    $logger->info_like($expected);

Method for testing a message matching a regex was written to the 'info' log level.

trace_like

    $logger->trace_like($expected);

Method for testing a message matching a regex was written to the 'trace' log level.

warn_like

    $logger->warn_like($expected);

Method for testing a message matching a regex was written to the 'warn' log level.

count

    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.

clear

    $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 methods

generic_is

Internal method to be used to build log level-specific exact string test methods.

generic_like

Internal method to be used to build log level-specific regex string test methods.

levels

Internal method that returns a list of valid log levels.

<<