Fix buglet to do with odd date terms
[catagits/XML-Feed.git] / t / 07-atom10-create.t
CommitLineData
c4d4c98e 1use strict;
2use Test::More;
3
e8fcbc5b 4plan tests => 17;
c4d4c98e 5
6use XML::Feed;
e8fcbc5b 7use DateTime;
8
9my $now = DateTime->now();
c4d4c98e 10
11my $feed = XML::Feed->new('Atom');
12$feed->title("foo");
13$feed->description("Atom 1.0 feed");
14$feed->link("http://example.org/");
e8fcbc5b 15$feed->id("tag:cpan.org;xml-feed-atom");
16$feed->updated($now);
c4d4c98e 17
18my $entry = XML::Feed::Entry->new('Atom');
19$entry->title("1st Entry");
20$entry->link("http://example.org/");
21$entry->category("blah");
22$entry->content("<p>Hello world.</p>");
e8fcbc5b 23$entry->id("tag:cpan.org;xml-feed-atom-entry");
24$entry->updated($now);
c4d4c98e 25
26$feed->add_entry($entry);
27
28my $xml = $feed->as_xml;
29like $xml, qr!<feed xmlns="http://www.w3.org/2005/Atom"!;
30like $xml, qr!<content .*type="xhtml">!;
31like $xml, qr!<div xmlns="http://www.w3.org/1999/xhtml">!;
32
33# roundtrip
34$feed = XML::Feed->parse(\$xml);
35is $feed->format, 'Atom';
36is $feed->title, "foo";
37is $feed->description, "Atom 1.0 feed";
38is $feed->link, "http://example.org/";
e8fcbc5b 39is $feed->id, "tag:cpan.org;xml-feed-atom";
a91dfb98 40is "".$feed->updated, "".$now;
c4d4c98e 41
42my @entries = $feed->entries;
43is @entries, 1;
44$entry = $entries[0];
45
46is $entry->title, '1st Entry';
47is $entry->link, 'http://example.org/';
48is $entry->category, 'blah';
49is $entry->content->type, 'text/html';
50like $entry->content->body, qr!\s*<p>Hello world.</p>\s*!s;
51
e8fcbc5b 52is $entry->id, "tag:cpan.org;xml-feed-atom-entry";
a91dfb98 53is "".$entry->updated, "".$now;
c4d4c98e 54
55