Commit b13120a3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add IRIS constructor tests

parent 0a1dc4ca
Loading
Loading
Loading
Loading

t/30-iris-const.t

0 → 100644
+66 −0
Original line number Diff line number Diff line
#!/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'
);

t/in/station/EBILP

0 → 100644
+2 −0
Original line number Diff line number Diff line
<stations>
</stations>