-# $Id$
-
use strict;
-use Test::More tests => 66;
+use Test::More;
use XML::Feed;
use XML::Feed::Entry;
use XML::Feed::Content;
for my $format (qw( Atom RSS )) {
my $feed = XML::Feed->new($format);
- isa_ok($feed, 'XML::Feed::' . $format);
+ isa_ok($feed, 'XML::Feed::Format::' . $format);
like($feed->format, qr/^$format/, 'Format is correct');
$feed->title('My Feed');
is($feed->title, 'My Feed', 'feed title is correct');
ok($feed->as_xml, 'as_xml returns something');
my $entry = XML::Feed::Entry->new($format);
- isa_ok($entry, 'XML::Feed::Entry::' . $format);
+ isa_ok($entry, 'XML::Feed::Entry::Format::' . $format);
$entry->title('Foo Bar');
is($entry->title, 'Foo Bar', 'entry title is correct');
$entry->link('http://www.example.com/foo/bar.html');
my @e = $feed->entries;
is(scalar @e, 1, 'One post in the feed');
is($e[0]->title, 'Foo Bar', 'Correct post');
+ is($e[0]->content->body, 'This is the content (again).', 'content is still correct');
+
+ if ($format eq 'Atom') {
+ like $feed->as_xml, qr/This is the content/;
+ }
+ if ($format eq 'RSS') {
+ like $feed->as_xml, qr{xmlns:dcterms="http://purl.org/dc/terms/"};
+ }
+
+ $feed->self_link("http://tor.tld/my-feed.rss");
+
+ if ($format eq "RSS")
+ {
+ like ($feed->as_xml(), qr{\Q<atom:link href="http://tor.tld/my-feed.rss" rel="self" type="application/rss+xml"/>\E},
+ "Feed contains the atom:link");
+ }
+ elsif ($format eq "Atom")
+ {
+ like ($feed->as_xml(), qr{\Q<link rel="self" href="http://tor.tld/my-feed.rss" type="application/atom+xml"/>\E},
+ "Feed contains the atom:link");
+
+ my %rfc5005 = (
+ first_link => "http://tor.tld/my-feed.xml?page=1",
+ next_link => "http://tor.tld/my-feed.xml?page=4",
+ previous_link => "http://tor.tld/my-feed.xml?page=2",
+ last_link => "http://tor.tld/my-feed.xml?page=99",
+ current_link => "http://tor.tld/archive/2.xml",
+ prev_archive_link => "http://tor.tld/archive/1.xml",
+ next_archive_link => "http://tor.tld/archive/3.xml",
+ );
+
+ while ( my($name,$url) = each(%rfc5005) ) {
+ $feed->$name($url);
+ $name =~ s/_link$//;
+ $name =~ s/_/-/g;
+ like ($feed->as_xml(), qr{\Q<link rel="$name" href="$url" type="application/atom+xml"/>\E},
+ "Feed contains an RFC 5005 rel=\"$name\" link");
+ }
+ }
+
}
+
+done_testing;