Commit 6b8626fd authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Update tests

parent d668c568
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ sub new {
	return $self;
}

sub new_from_html {
sub new_from_xml {
	my ( $class, %opt ) = @_;

	my $self = { xml => $opt{xml}, };
@@ -160,6 +160,7 @@ sub results {
		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,
			)
		);
+3 −1
Original line number Diff line number Diff line
@@ -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 ) = @_;
+18 −15
Original line number Diff line number Diff line
@@ -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');

t/in/essen_hb.xml

0 → 100644
+1034 −0

File added.

Preview size limit exceeded, changes collapsed.