Added tests for mailToEpoch.
Removed the default setting for mailToEpoch that would have assigned the epoch to the mail field and automatically caused the method to fail, returning undef.
This commit is contained in:
parent
1a615f8ad8
commit
4cc810faf3
2 changed files with 14 additions and 2 deletions
|
|
@ -723,7 +723,7 @@ A date formatted according to RFC2822/822.
|
|||
|
||||
sub mailToEpoch {
|
||||
my $self = shift;
|
||||
my $date = shift || time();
|
||||
my $date = shift;
|
||||
my $parser = DateTime::Format::Mail->new->loose;
|
||||
my $dt = eval {$parser->parse_datetime($date)};
|
||||
if ($@) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 40; # increment this value for each test you create
|
||||
use Test::More tests => 43; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -105,6 +105,18 @@ $dude->profileField('timeZone', 'Australia/Perth');
|
|||
$session->user({user => $dude});
|
||||
is ($session->datetime->getTimeZone(), 'Australia/Perth', 'getTimeZone: valid time zones are allowed');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# mailToEpoch
|
||||
#
|
||||
####################################################
|
||||
|
||||
my $wgBdayMail = 'Thu, 16 Aug 2001 08:00:00 -0500';
|
||||
is ($session->datetime->mailToEpoch($wgBdayMail), $wgbday, 'mailToEpoch');
|
||||
|
||||
is ($session->datetime->mailToEpoch(750), undef, 'mailToEpoch returns undef on failure to parse');
|
||||
like($WebGUI::Test::logger_warns, qr{750 is not a valid date for email}, "DateTime logs a warning on failure to parse");
|
||||
|
||||
END {
|
||||
foreach my $account ($buster, $dude) {
|
||||
(defined $account and ref $account eq 'WebGUI::User') and $account->delete;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue