2014-12-03 00:02:45 +01:00
|
|
|
#!perl -w
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2014-12-03 22:50:45 +01:00
|
|
|
use POSIX qw( strftime );
|
2014-12-03 00:02:45 +01:00
|
|
|
|
|
|
|
sub register_tests {
|
|
|
|
my ( $self ) = @_;
|
|
|
|
$self->register_test('test_content_log_file');
|
2014-12-03 00:08:07 +01:00
|
|
|
$self->register_test('test_content_log_enabled');
|
2014-12-03 00:13:00 +01:00
|
|
|
$self->register_test('test_exclude');
|
2014-12-03 00:02:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub test_content_log_file {
|
|
|
|
my ( $self ) = @_;
|
2014-12-03 22:50:45 +01:00
|
|
|
is( $self->content_log_file,
|
|
|
|
strftime('mail/%Y%m%d', localtime(time)),
|
|
|
|
'content_log_file() returns the right default value' );
|
2015-02-12 23:19:44 +01:00
|
|
|
$self->mock_config( content_log_file => '/path/to/%Y%m%d%H%M' );
|
2014-12-03 22:50:45 +01:00
|
|
|
is( $self->content_log_file,
|
|
|
|
strftime('/path/to/%Y%m%d%H%M', localtime(time)),
|
|
|
|
'content_log_file config changes content_log_file() output' );
|
2015-02-12 23:19:44 +01:00
|
|
|
$self->unmock_config;
|
2014-12-03 00:02:45 +01:00
|
|
|
}
|
|
|
|
|
2014-12-03 00:08:07 +01:00
|
|
|
sub test_content_log_enabled {
|
|
|
|
my ( $self ) = @_;
|
|
|
|
ok( ! $self->content_log_enabled, 'content_log_enabled() returns false' );
|
2014-12-03 16:57:27 +01:00
|
|
|
my @test_data = (
|
|
|
|
{
|
|
|
|
config => 'true',
|
|
|
|
expected => 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => undef,
|
|
|
|
expected => 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => '1',
|
|
|
|
expected => 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => 'yes',
|
|
|
|
expected => 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => 'yes ',
|
|
|
|
expected => 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => '0',
|
|
|
|
expected => 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => 'false',
|
|
|
|
expected => 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => 'no',
|
|
|
|
expected => 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
config => 'asdf ',
|
|
|
|
expected => 0,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
for ( @test_data ) {
|
|
|
|
my $descr = "content_log_enabled="
|
|
|
|
. ( defined $_->{config } ? "'$_->{config }'" : 'undef' )
|
|
|
|
. ( $_->{expected} ? ' enables' : ' disables' )
|
|
|
|
. ' content logging';
|
2015-02-12 23:19:44 +01:00
|
|
|
$self->mock_config( content_log_enabled => $_->{config } );
|
2014-12-03 16:57:27 +01:00
|
|
|
is( $self->content_log_enabled, $_->{expected}, $descr );
|
|
|
|
}
|
2015-02-12 23:19:44 +01:00
|
|
|
$self->unmock_config;
|
2014-12-03 16:57:27 +01:00
|
|
|
}
|
|
|
|
|
2014-12-03 00:13:00 +01:00
|
|
|
sub test_exclude {
|
|
|
|
my ( $self ) = @_;
|
|
|
|
ok( ! $self->exclude, 'exclude() default method returns false' );
|
|
|
|
}
|
|
|
|
|