4 use Test::More tests => 23;
11 $LOG = 'Catalyst::Log';
16 no warnings 'redefine';
17 *Catalyst::Log::_send_to_log = sub {
24 ok my $log = $LOG->new, '... and creating a new log object should succeed';
25 isa_ok $log, $LOG, '... and the object it returns';
27 can_ok $log, 'is_info';
28 ok $log->is_info, '... and the default behavior is to allow info messages';
31 ok $log->info('hello there!'),
32 '... passing it an info message should succeed';
34 can_ok $log, "_flush";
36 ok @MESSAGES, '... and flushing the log should succeed';
37 is scalar @MESSAGES, 1, '... with one log message';
38 like $MESSAGES[0], qr/^\[info\] hello there!$/,
39 '... which should match the format we expect';
43 package Catalyst::Log::Subclass;
44 use base qw/Catalyst::Log/;
48 push @MESSAGES, '---';
53 my $SUBCLASS = 'Catalyst::Log::Subclass';
54 can_ok $SUBCLASS, 'new';
55 ok $log = Catalyst::Log::Subclass->new,
56 '... and the log subclass constructor shoudl return a new object';
57 isa_ok $log, $SUBCLASS, '... and the object it returns';
58 isa_ok $log, $LOG, '... and it also';
61 ok $log->info('hi there!'),
62 '... passing it an info message should succeed';
64 can_ok $log, "_flush";
65 @MESSAGES = (); # clear the message log
67 ok @MESSAGES, '... and flushing the log should succeed';
68 is scalar @MESSAGES, 2, '... with two log messages';
69 is $MESSAGES[0], '---', '... with the first one being our new data';
70 like $MESSAGES[1], qr/^\[info\] hi there!$/,
71 '... which should match the format we expect';