#! perl use strict; use warnings; use Test::More tests => 4; package POC::Report; use base qw(Data::Report); package POC::Report::Html; use base qw(Data::Report::Plugin::Html); sub start { my $self = shift; $self->_argcheck(3); $self->{_title1} = shift; $self->{_title2} = shift; $self->{_title3} = shift; $self->SUPER::start; } sub _std_heading { my $self = shift; $self->_print("\n", "\n", "", $self->_html($self->{_title1}), "\n", '', "\n", "\n", "\n", "

", $self->_html($self->{_title1}), "

\n", "

", $self->_html($self->{_title2}), "
\n", $self->_html($self->{_title3}), "

\n"); $self->SUPER::_std_heading; } sub _std_stylist { my ($rep, $row, $col) = @_; return { line_after => 1 } if $row eq "total" && !$col; return; } sub finish { my $self = shift; $self->_argcheck(0); $self->SUPER::finish; $self->_print("\n\n"); } package main; my $rep = POC::Report::->create(type => "html"); isa_ok($rep, 'POC::Report::Html'); $rep->set_layout ([ { name => "acct", title => "Acct", width => 6 }, { name => "desc", title => "Report", width => 40, align => "|" }, { name => "deb", title => "Debet", width => 10, align => "<" }, { name => "crd", title => "Credit", width => 10, align => ">" }, ]); my $out = ""; $rep->set_output(\$out); $rep->start(qw(Title_One Title_Two Title_Three_Left&Right)); is($rep->get_stylist, \&POC::Report::Html::_std_stylist, "CB: stylist"); is($rep->get_heading, \&POC::Report::Html::_std_heading, "CB: heading"); $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "normal" }); $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "normal" }); $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "normal" }); $rep->add({ acct => "one", desc => "two", deb => "three", crd => "four", _style => "total" }); $rep->finish; $rep->close; my $ref; { undef $/; $ref = ; } $ref =~ s/[\r\n]/\n/g; is($out, $ref, "contents"); __DATA__ Title_One

Title_One

Title_Two
Title_Three_Left&Right

Acct Report Debet Credit
one two three four
one two three four
one two three four
one two three four