File: 2.0-permalink.t

package info (click to toggle)
libxml-rss-perl 1.65-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 904 kB
  • sloc: perl: 7,189; xml: 379; makefile: 12
file content (39 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;

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
is ($item_with_guid_missing->{"permaLink"},
    "http://community.livejournal.com/lj_dev/713810.html",
    "guid's isPermaLink is missing (implicitly true), so the item permalink property should be set to the value of the guid tag"
);

# 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"
);