diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2023-10-02 04:46:56 +0200 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2023-10-02 04:46:56 +0200 |
commit | 24e7f9ec5059a2a054b580146beec62c3237e0ba (patch) | |
tree | c98ca9995aca295ae02744e3725d6c26f71a2e7e /t | |
parent | 4bff29b1361effc7cc564762e51a16f4c51036d1 (diff) |
test: perltidy
Diffstat (limited to 't')
-rw-r--r-- | t/20-vrr.t | 171 |
1 files changed, 66 insertions, 105 deletions
@@ -14,207 +14,168 @@ require_ok('Travel::Routing::DE::VRR'); sub efa_conf { my $ret = { efa_url => 'https://app.vrr.de/vrrstd/XML_TRIP_REQUEST2', - origin => ['Essen', 'HBf'], - destination => ['Koeln', 'HBf'], + origin => [ 'Essen', 'HBf' ], + destination => [ 'Koeln', 'HBf' ], rm_base => 'https://app.vrr.de/vrrstd/', sm_base => 'https://app.vrr.de/download/envmaps/', lwp_options => {}, submit => 0, }; foreach my $p (@_) { - $ret->{$p->[0]} = $p->[1]; + $ret->{ $p->[0] } = $p->[1]; } return $ret; } sub efa_new { - return new_ok( - 'Travel::Routing::DE::VRR' => [%{efa_conf(@_)}] - ); + return new_ok( 'Travel::Routing::DE::VRR' => [ %{ efa_conf(@_) } ] ); } sub is_efa_post { - my ($ck, $cv, @post) = @_; - my $efa = efa_new([$ck, $cv]); + my ( $ck, $cv, @post ) = @_; + my $efa = efa_new( [ $ck, $cv ] ); my $ok = 1; is_deeply( - $efa->{'config'}, efa_conf([$ck, $cv]), + $efa->{'config'}, + efa_conf( [ $ck, $cv ] ), "$ck => $cv: conf ok", ); foreach my $ref (@post) { - my ($key, $value) = @{$ref}; - if (not defined $efa->{'post'}->{"key"} and - not defined $value) { + my ( $key, $value ) = @{$ref}; + if ( not defined $efa->{'post'}->{"key"} + and not defined $value ) + { next; } - if ($efa->{'post'}->{"$key"} ne $value) { + if ( $efa->{'post'}->{"$key"} ne $value ) { $ok = 0; last; } } - ok( - $ok, - "$ck => $cv: POST okay", - ); + ok( $ok, "$ck => $cv: POST okay", ); } sub is_efa_err { - my ($ck, $cv, $exception) = @_; + my ( $ck, $cv, $exception ) = @_; isa_ok( - exception { Travel::Routing::DE::VRR->new(%{efa_conf([$ck, $cv])}) }, + exception { + Travel::Routing::DE::VRR->new( %{ efa_conf( [ $ck, $cv ] ) } ) + }, $exception, "$ck => $cv" ); } -is_efa_post('ignored', 'ignored'); +is_efa_post( 'ignored', 'ignored' ); my $efa; is_efa_post( - 'via', ['MH', 'HBf'], - ['place_via', 'MH'], - ['name_via', 'HBf'], - ['type_via', 'stop'], + 'via', + [ 'MH', 'HBf' ], + [ 'place_via', 'MH' ], + [ 'name_via', 'HBf' ], + [ 'type_via', 'stop' ], ); is_efa_post( - 'origin', ['D', 'Fuerstenwall 232', 'address'], - ['place_origin', 'D'], - ['name_origin', 'Fuerstenwall 232'], - ['type_origin', 'address'], + 'origin', + [ 'D', 'Fuerstenwall 232', 'address' ], + [ 'place_origin', 'D' ], + [ 'name_origin', 'Fuerstenwall 232' ], + [ 'type_origin', 'address' ], ); is_efa_post( 'departure_time', '22:23', - ['itdTripDateTimeDepArr', 'dep'], - ['itdTimeHour', '22'], - ['itdTimeMinute', '23'], + [ 'itdTripDateTimeDepArr', 'dep' ], + [ 'itdTimeHour', '22' ], + [ 'itdTimeMinute', '23' ], ); is_efa_post( 'arrival_time', '16:38', - ['itdTripDateTimeDepArr', 'arr'], - ['itdTimeHour', '16'], - ['itdTimeMinute', '38'], + [ 'itdTripDateTimeDepArr', 'arr' ], + [ 'itdTimeHour', '16' ], + [ 'itdTimeMinute', '38' ], ); is_efa_post( 'date', '2.10.2009', - ['itdDateDay', '2'], - ['itdDateMonth', '10'], - ['itdDateYear', '2009'], + [ 'itdDateDay', '2' ], + [ 'itdDateMonth', '10' ], + [ 'itdDateYear', '2009' ], ); is_efa_post( 'date', '26.12.', - ['itdDateDay', '26'], - ['itdDateMonth', '12'], - ['itdDateYear', (localtime(time))[5] + 1900], + [ 'itdDateDay', '26' ], + [ 'itdDateMonth', '12' ], + [ 'itdDateYear', ( localtime(time) )[5] + 1900 ], ); -is_efa_post( - 'exclude', [qw[zug]], - ['inclMOT_0', undef], -); +is_efa_post( 'exclude', [qw[zug]], [ 'inclMOT_0', undef ], ); is_efa_post( 'exclude', [qw[stadtbus schiff ast]], - ['inclMOT_5', undef], - ['inclMOT_9', undef], - ['inclMOT_10', undef], + [ 'inclMOT_5', undef ], + [ 'inclMOT_9', undef ], + [ 'inclMOT_10', undef ], ); -is_efa_post( - 'select_interchange_by', 'speed', - ['routeType', 'LEASTTIME'], -); +is_efa_post( 'select_interchange_by', 'speed', [ 'routeType', 'LEASTTIME' ], ); -is_efa_post( - 'select_interchange_by', 'waittime', - ['routeType', 'LEASTINTERCHANGE'], +is_efa_post( 'select_interchange_by', 'waittime', + [ 'routeType', 'LEASTINTERCHANGE' ], ); -is_efa_post( - 'select_interchange_by', 'distance', - ['routeType', 'LEASTWALKING'], +is_efa_post( 'select_interchange_by', 'distance', + [ 'routeType', 'LEASTWALKING' ], ); -is_efa_post( - 'train_type', 'local', - ['lineRestriction', 403], -); +is_efa_post( 'train_type', 'local', [ 'lineRestriction', 403 ], ); -is_efa_post( - 'train_type', 'ic', - ['lineRestriction', 401], -); +is_efa_post( 'train_type', 'ic', [ 'lineRestriction', 401 ], ); -is_efa_post( - 'train_type', 'ice', - ['lineRestriction', 400], -); +is_efa_post( 'train_type', 'ice', [ 'lineRestriction', 400 ], ); -is_efa_post( - 'walk_speed', 'normal', - ['changeSpeed', 'normal'], -); +is_efa_post( 'walk_speed', 'normal', [ 'changeSpeed', 'normal' ], ); -is_efa_post( - 'max_interchanges', 5, - ['maxChanges', 5], -); +is_efa_post( 'max_interchanges', 5, [ 'maxChanges', 5 ], ); -is_efa_post( - 'use_near_stops', 1, - ['useProxFootSearch', 1], -); +is_efa_post( 'use_near_stops', 1, [ 'useProxFootSearch', 1 ], ); -is_efa_post( - 'with_bike', 1, - ['bikeTakeAlong', 1], -); +is_efa_post( 'with_bike', 1, [ 'bikeTakeAlong', 1 ], ); -is_efa_err( - 'departure_time', '37:00', +is_efa_err( 'departure_time', '37:00', 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'departure_time', '07', +is_efa_err( 'departure_time', '07', 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'train_type', 'invalid', +is_efa_err( 'train_type', 'invalid', 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'walk_speed', 'invalid', +is_efa_err( 'walk_speed', 'invalid', 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'select_interchange_by', 'invalid', +is_efa_err( 'select_interchange_by', 'invalid', 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'exclude', [qw[sonstige invalid]], +is_efa_err( 'exclude', [qw[sonstige invalid]], 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'date', '42.5.2003', - 'Travel::Routing::DE::EFA::Exception::Setup', -); +is_efa_err( 'date', '42.5.2003', + 'Travel::Routing::DE::EFA::Exception::Setup', ); -is_efa_err( - 'date', '7.', - 'Travel::Routing::DE::EFA::Exception::Setup', -); +is_efa_err( 'date', '7.', 'Travel::Routing::DE::EFA::Exception::Setup', ); |