Commit | Line | Data |
5383a560 |
1 | # $Id: $ |
2 | |
3 | use strict; |
e3b96b9c |
4 | use Test::More; |
5383a560 |
5 | use XML::Feed; |
e3b96b9c |
6 | use XML::RSS; |
5383a560 |
7 | |
e3b96b9c |
8 | if ($XML::RSS::VERSION <= 1.36) { |
9 | plan skip_all => "Version of XML::RSS is too old to do xml:base"; |
10 | } else { |
11 | plan tests => 13; |
12 | } |
5383a560 |
13 | |
14 | my $feed = XML::Feed->parse('t/samples/base_rss.xml'); |
e3b96b9c |
15 | |
5383a560 |
16 | my ($entry) = $feed->entries; |
17 | my $content = $entry->content; |
7c89ffff |
18 | is($feed->base, "http://example.org/", "Got feed base"); |
19 | is($entry->base, "http://example.org/archives/", "Got entry base"); |
20 | is($content->base, "http://example.org/archives/000001.html", "Got content base"); |
21 | |
22 | my $xml = $feed->as_xml; |
23 | my $new; |
24 | ok($new = XML::Feed->parse(\$xml), "Parsed old feed"); |
25 | my ($new_entry) = $new->entries; |
26 | my $new_content = $entry->content; |
27 | is($new->base, "http://example.org/", "Got feed base"); |
28 | is($new_entry->base, "http://example.org/archives/", "Got entry base"); |
29 | is($new_content->base, "http://example.org/archives/000001.html", "Got content base"); |
30 | |
31 | |
32 | ok($feed->base("http://foo.com/"), "Set feed base"); |
33 | ok($entry->base("http://foo.com/archives/"), "Set entry base"); |
34 | ok($content->base("http://foo.com/archives/000001.html"), "Set content base"); |
35 | |
36 | is($feed->base, "http://foo.com/", "Got feed base"); |
37 | is($entry->base, "http://foo.com/archives/", "Got entry base"); |
38 | is($content->base, "http://foo.com/archives/000001.html", "Got content base"); |
39 | |
40 | |