| 1 |
#!/usr/bin/env perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use 5.010; |
| 5 |
|
| 6 |
use utf8; |
| 7 |
|
| 8 |
use File::Slurp qw(slurp); |
| 9 |
use Test::More tests => 82; |
| 10 |
|
| 11 |
BEGIN { |
| 12 |
use_ok('Travel::Routing::DE::EFA'); |
| 13 |
} |
| 14 |
require_ok('Travel::Routing::DE::EFA'); |
| 15 |
|
| 16 |
my $xml = slurp('t/in/e_alf_d_hbf.xml'); |
| 17 |
|
| 18 |
my $routing = Travel::Routing::DE::EFA->new_from_xml( efa_url => 'http://efa.vrr.de/vrr/XSLT_TRIP_REQUEST2', xml => $xml ); |
| 19 |
|
| 20 |
isa_ok( $routing, 'Travel::Routing::DE::EFA' ); |
| 21 |
can_ok( $routing, 'routes' ); |
| 22 |
|
| 23 |
for my $r ( $routing->routes ) { |
| 24 |
isa_ok( $r, 'Travel::Routing::DE::EFA::Route' ); |
| 25 |
can_ok( $r, |
| 26 |
qw(duration parts ticket_type fare_adult fare_child vehicle_time) ); |
| 27 |
|
| 28 |
for my $c ( $r->parts ) { |
| 29 |
isa_ok( $c, 'Travel::Routing::DE::EFA::Route::Part' ); |
| 30 |
can_ok( |
| 31 |
$c, qw( |
| 32 |
arrival_stop arrival_platform arrival_stop_and_platform |
| 33 |
arrival_date arrival_sdate arrival_time arrival_stime |
| 34 |
departure_stop departure_platform departure_stop_and_platform |
| 35 |
departure_date departure_sdate departure_time departure_stime |
| 36 |
delay extra train_line train_destination |
| 37 |
) |
| 38 |
); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
my $r0 = ( $routing->routes )[0]; |
| 43 |
|
| 44 |
is( $r0->duration, '00:45', 'r0: duration' ); |
| 45 |
is( $r0->vehicle_time, 35, 'r0: vehicle_time' ); |
| 46 |
is( $r0->ticket_type, 'B', 'r0: ticket_type' ); |
| 47 |
is( $r0->fare_adult, '4.70', 'r0: fare_adult' ); |
| 48 |
is( $r0->fare_child, '1.40', 'r0: fare_child' ); |
| 49 |
|
| 50 |
my ( $c0, $c1 ) = $r0->parts; |
| 51 |
|
| 52 |
is( $c0->delay, 0, 'r0,0: delay' ); |
| 53 |
is_deeply( [ $c0->extra ], [], 'r0,0: extra' ); |
| 54 |
is_deeply( [ $c0->departure_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486C.pdf'], 'r0,0: departure_routemaps'); |
| 55 |
is_deeply( [ $c0->departure_stationmaps ], [], 'r0,0: departure_stationmaps'); |
| 56 |
is_deeply( [ $c0->arrival_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486D.pdf'], 'r0,0: arrival_routemaps'); |
| 57 |
is_deeply( [ $c0->arrival_stationmaps ], ['http://efa.vrr.de/download/envmaps/vrr/09289_e_hbf_1.htm'], 'r0,0: arrival_stationmaps'); |
| 58 |
is( $c0->train_line, 'Straßenbahn 107', 'r0,0: line' ); |
| 59 |
is( $c0->train_destination, 'Essen Hanielstr. Schleife', 'r0,0: dest' ); |
| 60 |
is( $c0->departure_stop, 'Essen Alfredusbad', 'r0,0: dstop' ); |
| 61 |
is( $c0->departure_platform, 'Bstg. 1', 'r0,0: dplatf' ); |
| 62 |
is( |
| 63 |
$c0->departure_stop_and_platform, |
| 64 |
'Essen Alfredusbad: Bstg. 1', |
| 65 |
'r0,0: dsp' |
| 66 |
); |
| 67 |
is( $c0->departure_date, '27.11.2011', 'r0,0: drdate' ); |
| 68 |
is( $c0->departure_sdate, '27.11.2011', 'r0,0: dsdate' ); |
| 69 |
is( $c0->departure_time, '13:55', 'r0,0: drtime' ); |
| 70 |
is( $c0->departure_stime, '13:55', 'r0,0: dstime' ); |
| 71 |
is( $c0->arrival_stop, 'Essen Hauptbahnhof', 'r0,0: astop' ); |
| 72 |
is( $c0->arrival_platform, 'Bstg. 1', 'r0,0: aplatf' ); |
| 73 |
is( $c0->arrival_stop_and_platform, 'Essen Hauptbahnhof: Bstg. 1', |
| 74 |
'r0,0: asp' ); |
| 75 |
is( $c0->arrival_date, '27.11.2011', 'r0,0: ardate' ); |
| 76 |
is( $c0->arrival_sdate, '27.11.2011', 'r0,0: asdate' ); |
| 77 |
is( $c0->arrival_time, '14:02', 'r0,0: artime' ); |
| 78 |
is( $c0->arrival_stime, '14:02', 'r0,0: astime' ); |
| 79 |
|
| 80 |
is_deeply( ($c0->via)[0], |
| 81 |
['27.11.2011', '13:56', 'Essen Florastr.', 'Bstg. 1', undef], |
| 82 |
'r0,0: via[0]'); |
| 83 |
|
| 84 |
is( $c1->delay, 3, 'r0,1: delay' ); |
| 85 |
is_deeply( |
| 86 |
[ $c1->extra ], |
| 87 |
[ 'Fahrradmitnahme begrenzt möglich' ], |
| 88 |
'r0,1: extra' |
| 89 |
); |
| 90 |
is_deeply( [ $c1->departure_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486D.pdf'], 'r0,0: departure_routemaps'); |
| 91 |
is_deeply( [ $c1->departure_stationmaps ], ['http://efa.vrr.de/download/envmaps/vrr/09289_e_hbf_1.htm'], 'r0,0: departure_stationmaps'); |
| 92 |
is_deeply( [ $c1->arrival_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486E.pdf'], 'r0,0: arrival_routemaps'); |
| 93 |
is_deeply( [ $c1->arrival_stationmaps ], ['http://efa.vrr.de/download/envmaps/vrr/18235_d_hbf_1.htm'], 'r0,0: arrival_stationmaps'); |
| 94 |
is( $c1->train_line, 'R-Bahn RE1', 'r0,1: line' ); |
| 95 |
is( $c1->train_destination, 'Aachen, Hbf', 'r0,1: dest' ); |
| 96 |
is( $c1->departure_stop, 'Essen Hauptbahnhof', 'r0,1: dstop' ); |
| 97 |
is( $c1->departure_platform, 'Gleis 2', 'r0,1: dplatf' ); |
| 98 |
is( |
| 99 |
$c1->departure_stop_and_platform, |
| 100 |
'Essen Hauptbahnhof: Gleis 2', |
| 101 |
'r0,1: dsp' |
| 102 |
); |
| 103 |
is( $c1->departure_date, '27.11.2011', 'r0,1: drdate' ); |
| 104 |
is( $c1->departure_sdate, '27.11.2011', 'r0,1: dsdate' ); |
| 105 |
is( $c1->departure_time, '14:12', 'r0,1: drtime' ); |
| 106 |
is( $c1->departure_stime, '14:09', 'r0,1: dstime' ); |
| 107 |
is( $c1->arrival_stop, 'Düsseldorf Hbf', 'r0,1: astop' ); |
| 108 |
is( $c1->arrival_platform, 'Gleis 16', 'r0,1: aplatf' ); |
| 109 |
is( |
| 110 |
$c1->arrival_stop_and_platform, |
| 111 |
'Düsseldorf Hbf: Gleis 16', |
| 112 |
'r0,1: asp' |
| 113 |
); |
| 114 |
is( $c1->arrival_date, '27.11.2011', 'r0,1: ardate' ); |
| 115 |
is( $c1->arrival_sdate, '27.11.2011', 'r0,1: asdate' ); |
| 116 |
is( $c1->arrival_time, '14:40', 'r0,1: artime' ); |
| 117 |
is( $c1->arrival_stime, '14:37', 'r0,1: astime' ); |