1 # $Id: 01-parse.t,v 1.2 2004/05/30 09:39:52 btrott Exp $
8 BEGIN { plan tests => 68 }
11 't/samples/atom.xml' => 'Atom',
12 't/samples/rss10.xml' => 'RSS 1.0',
13 't/samples/rss20.xml' => 'RSS 2.0',
16 ## First, test all of the various ways of calling parse.
18 my $file = 't/samples/atom.xml';
19 ok($feed = XML::Feed->parse($file));
20 ok($feed->title, 'First Weblog');
21 open my $fh, $file or die "Can't open $file: $!";
22 ok($feed = XML::Feed->parse($fh));
23 ok($feed->title, 'First Weblog');
25 my $xml = do { local $/; <$fh> };
26 ok($feed = XML::Feed->parse(\$xml));
27 ok($feed->title, 'First Weblog');
28 ok($feed = XML::Feed->parse(URI->new("file:$file")));
29 ok($feed->title, 'First Weblog');
31 ## Then try calling all of the unified API methods.
32 for my $file (sort keys %Feeds) {
33 my $feed = XML::Feed->parse($file) or die XML::Feed->errstr;
35 ok($feed->format, $Feeds{$file});
36 ok($feed->language, 'en-us');
37 ok($feed->title, 'First Weblog');
38 ok($feed->link, 'http://localhost/weblog/');
39 ok($feed->tagline, 'This is a test weblog.');
40 ok($feed->description, 'This is a test weblog.');
41 my $dt = $feed->modified;
42 ok(ref($dt), 'DateTime');
43 $dt->set_time_zone('UTC');
44 ok($dt->iso8601, '2004-05-30T07:39:57');
45 ok($feed->author, 'Melody');
47 my @entries = $feed->entries;
48 ok(scalar @entries, 2);
49 my $entry = $entries[0];
50 ok($entry->title, 'Entry Two');
51 ok($entry->link, 'http://localhost/weblog/2004/05/entry_two.html');
53 ok(ref($dt), 'DateTime');
54 $dt->set_time_zone('UTC');
55 ok($dt->iso8601, '2004-05-30T07:39:25');
56 ok($entry->content =~ /<p>Hello!<\/p>/);
57 ok($entry->summary, 'Hello!...');
58 ok($entry->category, 'Travel');
59 ok($entry->author, 'Melody');