diff --git a/lib/WWW/Efa.pm b/lib/WWW/Efa.pm index 0716d5e99d33df90da54aa10a92325d2012ce477..0aa2f46ba5b2219fb45d89e9ddeed0c4667abae9 100644 --- a/lib/WWW/Efa.pm +++ b/lib/WWW/Efa.pm @@ -53,7 +53,7 @@ sub post_time { my ($post, $conf) = @_; my $time; - if ($conf->{'depart'} || $conf->{'time'}) { + if ($conf->{'depart'}) { $post->{'itdTripDateTimeDepArr'} = 'dep'; $time = $conf->{'depart'} || $conf->{'time'}; } @@ -64,7 +64,8 @@ sub post_time { if ($time !~ / ^ [0-2]? \d : [0-5]? \d $ /x) { die WWW::Efa::Error::Setup->new( - 'time', $time, 'Must match HH:MM' + ($conf->{'depart'} ? 'depart' : 'arrive'), + $time, 'Must match HH:MM' ); } @{$post}{'itdTimeHour', 'itdTimeMinute'} = split(/:/, $time); @@ -179,7 +180,7 @@ sub create_post { if ($conf->{'via'}) { post_place($post, 'via', @{$conf->{'via'}}); } - if ($conf->{'arrive'} || $conf->{'depart'} || $conf->{'time'}) { + if ($conf->{'arrive'} || $conf->{'depart'}) { post_time($post, $conf); } if ($conf->{'date'}) { @@ -343,7 +344,7 @@ contain. See B<from> for arguments. Sets the journey end time -=item B<depart>|B<time> => I<HH:MM> +=item B<depart> => I<HH:MM> Sets the journey start time diff --git a/t/50-www-efa.t b/t/50-www-efa.t index bae1e94f2f78a33df560512d59c2ef2bd0b61b86..8e56624838189d40bf3a036a8e8b80e40b10b568 100644 --- a/t/50-www-efa.t +++ b/t/50-www-efa.t @@ -3,7 +3,7 @@ use strict; use warnings; use 5.010; -use Test::More tests => 135; +use Test::More tests => 131; BEGIN { use_ok('WWW::Efa'); @@ -115,13 +115,6 @@ is_efa_post( ['type_origin', 'address'], ); -is_efa_post( - 'time', '22:23', - ['itdTripDateTimeDepArr', 'dep'], - ['itdTimeHour', '22'], - ['itdTimeMinute', '23'], -); - is_efa_post( 'depart', '22:23', ['itdTripDateTimeDepArr', 'dep'], @@ -137,12 +130,12 @@ is_efa_post( ); is_efa_err( - 'time', '37:00', + 'depart', '37:00', 'Must match HH:MM', ); is_efa_err( - 'time', '07', + 'depart', '07', 'Must match HH:MM', ); diff --git a/t/60-bin-efa.t b/t/60-bin-efa.t index 2b60233ad1c5b958f7e69692bbe2e8b5497262fd..0ae0b1fcf3d0a12007d86f9098068198dfb8a7e5 100644 --- a/t/60-bin-efa.t +++ b/t/60-bin-efa.t @@ -94,13 +94,23 @@ for my $opt (qw/-w --walk-speed/) { ); } -for my $opt (qw/-t --time --depart -a --arrive/) { +for my $opt (qw/-t --time --depart/) { $cmd = Test::Command->new(cmd => "$efa $opt 35:12 $testarg"); $cmd->exit_isnt_num(0); $cmd->stdout_is_eq($EMPTY); $cmd->stderr_is_eq( - mk_err('time', '35:12', 'Must match HH:MM') + mk_err('depart', '35:12', 'Must match HH:MM') + ); +} + +for my $opt (qw/-a --arrive/) { + $cmd = Test::Command->new(cmd => "$efa $opt 35:12 $testarg"); + + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq($EMPTY); + $cmd->stderr_is_eq( + mk_err('arrive', '35:12', 'Must match HH:MM') ); }