summaryrefslogtreecommitdiff
path: root/t/20-db.t
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-07-07 12:21:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-07-07 12:21:16 +0200
commit9fa4c10cc294f0817f64dbbbdb833abb777bcaa1 (patch)
treee0fa8f4603ae49f4db1d38cf7317ca408f85bca2 /t/20-db.t
parentd068eab8be3750ddf64ba2fa09918402821073a4 (diff)
Add tests
Diffstat (limited to 't/20-db.t')
-rw-r--r--t/20-db.t36
1 files changed, 35 insertions, 1 deletions
diff --git a/t/20-db.t b/t/20-db.t
index 5e70a70..cb84952 100644
--- a/t/20-db.t
+++ b/t/20-db.t
@@ -3,9 +3,43 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 2;
+use File::Slurp qw(slurp);
+use Test::More tests => 89;
BEGIN {
use_ok('Travel::Status::DE::DeutscheBahn');
}
require_ok('Travel::Status::DE::DeutscheBahn');
+
+my $html = slurp('t/in/essen.html');
+
+my $status = Travel::Status::DE::DeutscheBahn->new_from_html(html => $html);
+
+isa_ok($status, 'Travel::Status::DE::DeutscheBahn');
+can_ok($status, qw(results));
+
+my @departures = $status->results;
+
+for my $departure (@departures) {
+ isa_ok($departure, 'Travel::Status::DE::DeutscheBahn::Result');
+ can_ok($departure, qw(route_end destination origin info platform route
+ route_raw time train));
+}
+
+is($departures[0]->time, '19:21', 'first result: time ok');
+is($departures[0]->train, 'RE 10228', 'first result: train ok');
+is($departures[0]->destination, 'Duisburg Hbf', 'first result: destination ok');
+is($departures[0]->platform, '2', 'first result: platform ok');
+
+is($departures[-1]->time, '20:18', 'last result: time ok');
+is($departures[-1]->train, 'S 6', 'last result: train ok');
+is($departures[-1]->platform, '12', 'last result: platform ok');
+
+is($departures[8]->time, '19:31', '9th result: time ok');
+is($departures[8]->train, 'NWB75366', '9th result: train ok');
+is($departures[8]->info, 'k.A.', '9th result: info ok');
+
+is_deeply([$departures[8]->route],
+ ['Essen-Borbeck', 'Bottrop Hbf', 'Gladbeck West', 'Gladbeck-Zweckel',
+ 'Feldhausen', 'Dorsten', 'Hervest-Dorsten', 'Deuten', 'Rhade',
+ 'Marbeck-Heiden', 'Borken(Westf)'], '9th result: route ok');