1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 5;
use File::Spec;
use XML::RSS;
my $rss = XML::RSS->new;
$rss->parsefile(File::Spec->catfile('t', 'data', 'rss-permalink.xml') );
my $item_with_guid_true = $rss->{'items'}->[0];
my $item_with_guid_missing = $rss->{'items'}->[1];
my $item_with_guid_false = $rss->{'items'}->[2];
# TEST
is ($item_with_guid_true->{"permaLink"},
"http://community.livejournal.com/lj_dev/714037.html",
"guid's isPermaLink is set to true, so the item permalink property should be set to the value of the guid tag"
);
# TEST
ok ((!$item_with_guid_missing->{"permaLink"}),
"guid's isPermaLink is missing (implicitly false), so the item permalink property should not be set"
);
# TEST
is ($item_with_guid_missing->{"guid"},
"http://community.livejournal.com/lj_dev/713810.html",
"guid's isPermaLink is missing (implicitly false), so item->{guid}" .
" should be equal to the contents of the guid element",
);
# TEST
ok ((!$item_with_guid_false->{"permaLink"}),
"guid's isPermaLink is false, so the permalink should be false"
);
# TEST
is ($item_with_guid_false->{"guid"},
"http://community.livejournal.com/lj_dev/713549.html",
"guid's isPermaLink is false so item->{guid} should be equal to" .
" the contents of the guid element"
);
|