1#============================================================= -*-perl-*-
2#
3# t/log/reporter.t
4#
5# Test the Badger::Reporter module, a new base class for Badger::Log,
6# Badger::Test::Manager, and maybe a few other things.
7#
8# Copyright (C) 2005-2008 Andy Wardley.  All Rights Reserved.
9#
10# This is free software; you can redistribute it and/or modify it
11# under the same terms as Perl itself.
12#
13#========================================================================
14
15use strict;
16use warnings;
17use lib qw( ./lib ../lib ../../lib );
18use Badger::Test
19    skip  => 'Still in development',
20    tests => 40,
21    debug => 'Badger::Reporter',
22    args  => \@ARGV;
23
24use Badger::Reporter;
25use constant REPORTER => 'Badger::Reporter';
26
27pass( 'Loaded ' . REPORTER );
28
29my $reporter = REPORTER->new(
30    events => [
31        { name    => 'foo',
32          colour  => 'green',
33          message => 'FOO: %s',
34          summary => '%s foo events',
35          verbose => 0,
36        },
37        'bar'
38    ],
39);
40
41$reporter->foo('the foo happened');
42$reporter->foo('the foo happened again');
43
44$reporter->bar('the bar happened');
45$reporter->bar('the bar happened again');
46
47print $reporter->summary;
48
49
50#-----------------------------------------------------------------------
51# subclass
52#-----------------------------------------------------------------------
53
54package My::Reporter;
55
56use base 'Badger::Reporter';
57
58our $EVENTS = [
59    {
60        name    => 'wiz',
61        colour  => 'green',
62        message => 'WIZ: %s',
63        summary => '%s wizzy wiz events',
64        verbose => 1,
65    },
66    {
67        name    => 'waz',
68        colour  => 'red',
69        message => 'WAZ: %s',
70        summary => '%s wazzy waz events',
71        verbose => 1,
72    },
73];
74
75our $MESSAGES = {
76    missing => 'You forget to bring the %s',
77};
78
79package main;
80
81print "\n\n";
82
83my $reporter = My::Reporter->new( verbose => 1 );
84
85$reporter->wiz('number one');
86$reporter->waz('number two');
87$reporter->wiz('buckle');
88$reporter->waz('my shoe');
89$reporter->wiz_msg( missing => 'wizzyment' );
90$reporter->waz_msg( missing => 'wazzyment' );