4 use Test::More tests => 24;
5 use Test::NoWarnings; # Adds an extra test.
12 $LOG = 'Catalyst::Log';
17 no warnings 'redefine';
18 *Catalyst::Log::_send_to_log = sub {
25 ok my $log = $LOG->new, '... and creating a new log object should succeed';
26 isa_ok $log, $LOG, '... and the object it returns';
28 can_ok $log, 'is_info';
29 ok $log->is_info, '... and the default behavior is to allow info messages';
32 ok $log->info('hello there!'),
33 '... passing it an info message should succeed';
35 can_ok $log, "_flush";
37 ok @MESSAGES, '... and flushing the log should succeed';
38 is scalar @MESSAGES, 1, '... with one log message';
39 like $MESSAGES[0], qr/^\[info\] hello there!$/,
40 '... which should match the format we expect';
44 package Catalyst::Log::Subclass;
45 use base qw/Catalyst::Log/;
49 push @MESSAGES, '---';
54 my $SUBCLASS = 'Catalyst::Log::Subclass';
55 can_ok $SUBCLASS, 'new';
56 ok $log = Catalyst::Log::Subclass->new,
57 '... and the log subclass constructor shoudl return a new object';
58 isa_ok $log, $SUBCLASS, '... and the object it returns';
59 isa_ok $log, $LOG, '... and it also';
62 ok $log->info('hi there!'),
63 '... passing it an info message should succeed';
65 can_ok $log, "_flush";
66 @MESSAGES = (); # clear the message log
68 ok @MESSAGES, '... and flushing the log should succeed';
69 is scalar @MESSAGES, 2, '... with two log messages';
70 is $MESSAGES[0], '---', '... with the first one being our new data';
71 like $MESSAGES[1], qr/^\[info\] hi there!$/,
72 '... which should match the format we expect';