From 6b8626fd76efa0c779c2a3d4944279ba7a4827df Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 16 Nov 2011 09:47:38 +0100 Subject: Update tests --- lib/Travel/Status/DE/VRR.pm | 12 +- lib/Travel/Status/DE/VRR/Result.pm | 4 +- t/20-vrr.t | 33 +- t/in/essen_hb.xml | 1034 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1062 insertions(+), 21 deletions(-) create mode 100644 t/in/essen_hb.xml diff --git a/lib/Travel/Status/DE/VRR.pm b/lib/Travel/Status/DE/VRR.pm index 4e647c2..156e815 100644 --- a/lib/Travel/Status/DE/VRR.pm +++ b/lib/Travel/Status/DE/VRR.pm @@ -110,7 +110,7 @@ sub new { return $self; } -sub new_from_html { +sub new_from_xml { my ( $class, %opt ) = @_; my $self = { xml => $opt{xml}, }; @@ -156,10 +156,11 @@ sub results { $e_time->getAttribute('hour'), $e_time->getAttribute('minute'), ); - my $platform = $e->getAttribute('platform'); - my $line = $e_line->getAttribute('number'); - my $dest = $e_line->getAttribute('direction'); - my $info = undef; + my $platform = $e->getAttribute('platform'); + my $line = $e_line->getAttribute('number'); + my $dest = $e_line->getAttribute('direction'); + my $info = undef; + my $countdown = $e->getAttribute('countdown'); push( @results, @@ -169,6 +170,7 @@ sub results { platform => $platform, line => $line, destination => $dest, + countdown => $countdown, info => $info, ) ); diff --git a/lib/Travel/Status/DE/VRR/Result.pm b/lib/Travel/Status/DE/VRR/Result.pm index 0b2abf0..93df048 100644 --- a/lib/Travel/Status/DE/VRR/Result.pm +++ b/lib/Travel/Status/DE/VRR/Result.pm @@ -9,7 +9,9 @@ use parent 'Class::Accessor'; our $VERSION = '0.02'; Travel::Status::DE::VRR::Result->mk_ro_accessors( - qw(destination time platform line info)); + qw(destination date time platform line info + countdown type) +); sub new { my ( $obj, %conf ) = @_; diff --git a/t/20-vrr.t b/t/20-vrr.t index d1ee22b..2a5ff2c 100644 --- a/t/20-vrr.t +++ b/t/20-vrr.t @@ -2,18 +2,19 @@ use strict; use warnings; use 5.010; +use utf8; use File::Slurp qw(slurp); -use Test::More skip_all => 'outdated'; +use Test::More tests => 96; BEGIN { use_ok('Travel::Status::DE::VRR'); } require_ok('Travel::Status::DE::VRR'); -my $html = slurp('t/in/essen_bp.html'); +my $xml = slurp('t/in/essen_hb.xml'); -my $status = Travel::Status::DE::VRR->new_from_html(xml => $html); +my $status = Travel::Status::DE::VRR->new_from_xml(xml => $xml); isa_ok($status, 'Travel::Status::DE::VRR'); can_ok($status, qw(errstr results)); @@ -22,17 +23,19 @@ my @results = $status->results; for my $result (@results) { isa_ok($result, 'Travel::Status::DE::VRR::Result'); - can_ok($result, qw(destination info line time platform)); + can_ok($result, qw(date destination info line time type platform)); } -is($results[0]->destination, 'Essen Wertstr.', 'first result: destination ok'); -is($results[0]->info, q{}, 'first result: no info'); -is($results[0]->line, '103', 'first result: line ok'); -is($results[0]->time, '20:19', 'first result: time ok'); -is($results[0]->platform, 'Bstg. 1', 'first result: platform ok'); - -is($results[-1]->destination, 'Essen Germaniaplatz', 'last result: destination ok'); -is($results[-1]->info, q{}, 'last result: no info'); -is($results[-1]->line, '101', 'last result: line ok'); -is($results[-1]->time, '21:07', 'last result: time ok'); -is($results[-1]->platform, 'Bstg. 1', 'last result: platform ok'); +is($results[0]->destination, 'Düsseldorf Hbf', 'first result: destination ok'); +is($results[0]->info, undef, 'first result: no info'); +is($results[0]->line, 'ICE 946 Intercity-Express', 'first result: line ok'); +is($results[0]->date, '16.11.2011', 'first result: date ok'); +is($results[0]->time, '09:36', 'first result: time ok'); +is($results[0]->platform, '#1', 'first result: platform ok'); + +is($results[-1]->destination, 'Essen Dellwig Bahnhof', 'last result: destination ok'); +is($results[-1]->info, undef, 'last result: no info'); +is($results[-1]->line, '166', 'last result: line ok'); +is($results[-1]->date, '16.11.2011', 'last result: date ok'); +is($results[-1]->time, '09:54', 'last result: time ok'); +is($results[-1]->platform, '9', 'last result: platform ok'); diff --git a/t/in/essen_hb.xml b/t/in/essen_hb.xml new file mode 100644 index 0000000..cb25c3d --- /dev/null +++ b/t/in/essen_hb.xml @@ -0,0 +1,1034 @@ + + + + + + + + + + + + + + Essen + E + + + Hauptbahnhof + Hbf + + + + + + + + + + + + + + + + + + + + + + + + + + + Zug + S-Bahn + U-Bahn + Stadtbahn + Straßen-/Trambahn + Stadtbus + Regionalbus + Schnellbus + Seil-/Zahnradbahn + Schiff + AST/Rufbus + Sonstige + + + + + + + + + + + + + + + + + + + + + + + + Solingen Hbf - Düsseldorf Hbf - Dortmund Hbf + + 00 + Daten DB AG + + + + + + Dortmund Hbf - Düsseldorf Hbf - Solingen Hbf + + 00 + Daten DB AG + + + + + + Duisburg Hbf / Essen Hbf - Gelsenkirchen Hbf / Recklinghausen Hbf - Dortmund Hbf + + 00 + Daten DB AG + + + + + + Oberhausen Hbf - Hattingen (Ruhr) Mitte + + 00 + Daten DB AG + + + + + + Hattingen (Ruhr) Mitte - Oberhausen Hbf + + 00 + Daten DB AG + + + + + + Essen Hbf - Düsseldorf Hbf - Köln-Nippes + + 00 + Daten DB AG + + + + + + Wuppertal Hbf - Essen Hbf - Haltern am See + + 00 + Daten DB AG + + + + + + Haltern am See - Essen Hbf - Wuppertal Hbf + + 00 + Daten DB AG + + + + + + GE-Buerer Str. - E-Karnap - Altenessen - Essen Hbf - Rüttenscheid - Messe Gruga + + 10 + EVAG U-Bahn + + + + + + Messe Gruga - Rüttenscheid - Essen Hbf - Altenessen - E-Karnap - GE-Buerer Str. + + 10 + EVAG U-Bahn + + + + + + Berliner Platz - Essen Hbf - MH-Rhein-Ruhr-Zentrum - Heißen Kirche + + 10 + EVAG U-Bahn + + + + + + Heißen Kirche - MH-Rhein-Ruhr-Zentrum - Essen Hbf - Berliner Platz + + 10 + EVAG U-Bahn + + + + + + Altenessen - Essen Hbf - Holsterhausen - Margarethenhöhe + + 10 + EVAG U-Bahn + + + + + + Margarethenhöhe - Holsterhausen - Essen Hbf - Altenessen + + 10 + EVAG U-Bahn + + + + + + Borbeck - Bergeborbeck - Essen Hbf - Bredeney + + 11 + EVAG Strab + + + + + + + 11 + EVAG Strab + + + + + + Steele - Essen Hbf - Rathaus Essen - Altendorf - Borbeck - Dellwig + + 11 + EVAG Strab + + + + + + Frintrop - Altendorf - Essen Hbf - Bergerhausen - Rellinghausen + + 11 + EVAG Strab + + + + + + Rellinghausen - Bergerhausen - Essen Hbf - Altendorf - Frintrop + + 11 + EVAG Strab + + + + + + Altenessen - Essen Hbf - Rüttenscheid - Helenenstr. - Bergeborbeck + + 11 + EVAG Strab + + + + + + Bergeborbeck - Helenenstr. - Rüttenscheid - Essen Hbf - Altenessen + + 11 + EVAG Strab + + + + + + GE-Hauptbahnhof - Essen Katernberg - Zollverein - Essen Hbf - Bredeney + + 11 + EVAG Strab + + + + + + Bredeney - Essen Hbf - Zollverein - Essen Katernberg - GE-Hauptbahnhof + + 11 + EVAG Strab + + + + + + Mülheim Flughafen - Essen Haarzopf - Essen Hbf - Stadtwald - Heisingen + + 12 + EVAG Bus + + + + + + Heisingen - Stadtwald - Essen Hbf - Essen Haarzopf - Mülheim Flughafen + + 12 + EVAG Bus + + + + + + Leithe - Kray - Essen Hbf - Heisingen + + 12 + EVAG Bus + + + + + + Heisingen - Essen Hbf - Kray - Leithe + + 12 + EVAG Bus + + + + + + Beisen - E-Hbf - Bergerhausen + + 12 + EVAG Bus + + + + + + Bergerhausen - E-Hbf - Beisen + + 12 + EVAG Bus + + + + + + GE-Rotths. - E-Hbf - Kupferdreh + + 12 + EVAG Bus + + + + + + Kupferdreh - E-Hbf - GE-Rotths. + + 12 + EVAG Bus + + + + + + Dellwig - Essen Hbf - Steele - E-Burgaltendorf - HAT-Niederwenigern + + 12 + EVAG Bus + + + + + + HAT-Niederwenigern - E-Burgaltendorf - Steele - Essen Hbf - Dellwig + + 12 + EVAG Bus + + + + + + Essen Hbf - Versorgungsamt + + 12 + EVAG Bus + + + + + + Vogelheim - Bergeborbeck - Essen Hbf - Essen West + + 12 + EVAG Bus + + + + + + Essen West - Essen Hbf - Bergeborbeck - Vogelheim + + 12 + EVAG Bus + + + + + + Essen Hbf - Altenessen - Essen Karnap - Gelsenkirchen + + 12 + EVAG Bus + + + + + + Essen Hbf - Katernberg + + 12 + EVAG Bus + + + + + + Essen Hbf - Schonnebeck - Kray - Leithe + + 12 + EVAG Bus + + + + + + Essen Hbf - Frillendorf - Steele - Überruhr - Burgaltendorf + + 12 + EVAG Bus + + + + + + Essen Hbf - Huttrop - Steele - Hörsterfeld + + 12 + EVAG Bus + + + + + + Essen Hbf - Rellinghausen - Überruhr - Kupferdreh + + 12 + EVAG Bus + + + + + + Essen Hbf - Stadtwald - Heisingen + + 12 + EVAG Bus + + + + + + Essen Hbf - Bredeney - Essen Werden - Velbert + + 12 + EVAG Bus + + + + + + Essen Hbf - Holsterhausen - Margarethenhöhe - Haarzopf + + 12 + EVAG Bus + + + + + + Essen Hbf - Frohnhausen - Haarzopf + + 12 + EVAG Bus + + + + + + Essen Hbf - Altendorf - Essen Frintrop - Oberhausen + + 12 + EVAG Bus + + + + + + Essen Hbf - Altendorf - Bergeborbeck - Dellwig - Borbeck + + 12 + EVAG Bus + + + + + + Essen Hbf - Rüttenscheid - Kettwig + + 12 + EVAG Bus + + + + + + Essen Hbf - Bergeborbeck - Essen Dellwig - Bottrop + + 12 + EVAG Bus + + + + + + Essen Hbf - Velbert - Heiligenhaus Rathaus + + 88 + Busverkehr Rheinland + + + + + + + 12 + EVAG Bus + + + + + + Essen Hbf - Überruhr - Burgaltendorf + + 12 + EVAG Bus + + + + + + Essen Hbf - BOT-Hbf - ZOB Berliner Platz - Kirchhellen - Movie Park /ZOB Dorsten + + 40 + Vestische + + + + + + + + + + + + + + + Bordrestaurant + + + + + lineType + HIGHSPEEDTRAIN + + + lineType + LONG_DISTANCE_TRAINS + + + lineType + SUPPLEMENT + + + + + + + + + + + weiter als Linie SB 66 nach Wuppertal Hbf + + + + + + + + + + + + + + + + + + + + Ab (H) Heißen Kirche, Umstieg in den SEV Ri. Mülheim Hbf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + Ab (H) Heißen Kirche, Umstieg in den SEV Ri. Mülheim Hbf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fahrradmitnahme begrenzt möglich + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3