Commit 49bca5b7 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Remove 'time' option from WWW::Efa

parent b9c18d67
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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

+3 −10
Original line number Diff line number Diff line
@@ -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',
);

+12 −2
Original line number Diff line number Diff line
@@ -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')
	);
}