summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-01-17 15:57:27 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-01-17 15:57:27 +0100
commitb13120a37263f1a8719a8748c53ee219f8ccfa71 (patch)
treecdac55c2fea2daf3e7b3d2e851e7c1daea01a677
parent0a1dc4ca722dc6713081c9de9b0c76c67438973d (diff)
add IRIS constructor tests
-rw-r--r--t/30-iris-const.t66
-rw-r--r--t/in/station/EBILP2
2 files changed, 68 insertions, 0 deletions
diff --git a/t/30-iris-const.t b/t/30-iris-const.t
new file mode 100644
index 0000000..e82b59c
--- /dev/null
+++ b/t/30-iris-const.t
@@ -0,0 +1,66 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.014;
+
+use DateTime;
+use Test::More tests => 4;
+use Test::Fatal;
+
+use Travel::Status::DE::IRIS;
+
+my $status = Travel::Status::DE::IRIS->new(
+ iris_base => 'file:t/in',
+ station => 'EE',
+ datetime => DateTime->new(
+ year => 2014,
+ month => 1,
+ day => 3,
+ hour => 20,
+ minute => 1,
+ time_zone => 'Europe/Berlin'
+ )
+);
+
+is( $status->errstr, undef, 'constructor with data for everything' );
+
+$status = Travel::Status::DE::IRIS->new(
+ iris_base => 'file:t/in',
+ station => 'EE',
+ datetime => DateTime->new(
+ year => 2014,
+ month => 1,
+ day => 3,
+ hour => 19,
+ minute => 1,
+ time_zone => 'Europe/Berlin'
+ )
+);
+
+ok( defined $status->errstr, 'constructor with missing data has errstr' );
+
+$status = Travel::Status::DE::IRIS->new(
+ iris_base => 'file:t/in',
+ station => 'EBILP',
+ datetime => DateTime->new(
+ year => 2014,
+ month => 1,
+ day => 3,
+ hour => 20,
+ minute => 1,
+ time_zone => 'Europe/Berlin'
+ )
+);
+
+like(
+ $status->errstr,
+ qr{no associated timetable},
+ 'constructor with bad station has errstr'
+);
+
+ok(
+ exception {
+ $status = Travel::Status::DE::IRIS->new( iris_base => 'file:t/in' );
+ },
+ 'station parameter is mandatory -> code dies if missing'
+);
diff --git a/t/in/station/EBILP b/t/in/station/EBILP
new file mode 100644
index 0000000..5ebc19e
--- /dev/null
+++ b/t/in/station/EBILP
@@ -0,0 +1,2 @@
+<stations>
+</stations>