# t/22-date.t
{ # date()
my $obj = ISP::Object->new();
my $ret = $obj->date();
isa_ok( $ret, 'DateTime', "calling date() with no params, return" );
}
{ # date() get param
my $obj = ISP::Object->new();
my $ret = $obj->date({ get => 'month' });
ok( $ret =~ m{ \A \d{4}-\d{2} \z }xms, "called with get=>month works out ok" );
}
####
{ # add_trace() trivial
_reset();
my $ret = $error->add_trace();
is ( $ret, 0, "add_trace() returns success (0) when successful" );
}
{ # add_trace() type
_reset();
$error->add_trace();
my $type = reftype $error->stack();
is ( $type, 'ARRAY', "Error's stack trace is an array ref upon success" );
}
####
# in the package
sub new {
my $class = shift;
# suck in a config, bless and populate $self
return $self;
}
sub one_call_only {
return bless {}, shift;
}
sub attach {
my $thing = shift;
my $self = ( ref $thing )
? $thing
: $thing->one_call_only();
# do attach() stuff with $self, and...:
return $self->{ sub_details };
}
####
sub attach {
my $self = shift;
my $params = shift;
if ( $params->{ filename } && -e $params->{ filename } ) {
my $filename = $params->{ filename };
my $mime_type = mimetype( $filename );
push @{ $self->{ attachments } },
{ Path => $filename, Type => $mime_type };
}
return $self->{ attachments }; # aoh
}