#! 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 _top_heading {
my $self = shift;
$self->_print("\n",
"
\n",
"", $self->_html($self->{_title1}), " \n",
' ', "\n",
"\n",
"\n",
"\n\n\n");
}
package main;
my $rep = POC::Report::->create(type => "html", stylist => \&my_stylist);
isa_ok($rep, 'POC::Report::Html');
$rep->set_layout(
[
{
name => "check",
title => "Check",
width => 5,
align => "|",
},
{ 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, \&main::my_stylist, "CB: stylist");
is($rep->get_topheading, \&POC::Report::Html::_top_heading, "CB: heading");
$rep->add(
{
check => " ",
acct => "one",
desc => "two",
deb => "three",
crd => "four",
_style => "normal"
}
);
$rep->add(
{
check => " ",
acct => "one",
desc => "two",
deb => "three",
crd => "four",
_style => "normal"
}
);
$rep->add(
{
check => " ",
acct => "one",
desc => "two",
deb => "three",
crd => "four",
_style => "normal"
}
);
$rep->add(
{
check => " ",
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");
sub my_stylist {
my ($rep, $row, $col) = @_;
# Enable raw HTML contents for the 'check' column.
return { raw_html => 1 }
if $col && $col eq "check";
return;
}
__DATA__
Title_One