Clean up
[catagits/XML-Feed.git] / t / 12-multi-categories-atom.t
CommitLineData
a0cca2a4 1#!perl -w
2
3use strict;
6696f0d6 4use strict;
5use Test::More tests => 8 * 3;
6use XML::Feed;
7
8foreach my $test (["atom"], ["rss"], ["rss", "subjects"]) {
9
10 my $type = $test->[0];
11 my $other = ('Atom' ne $type)? "RSS" : "Atom";
12 my $field = $test->[1] || "categories";
13
14 ok(my $feed = XML::Feed->parse("t/samples/${type}-multiple-${field}.xml"), "Parsed $type file with multiple categories");
15 my ($entry) = $feed->entries;
16
17 is_deeply(
18 [$entry->category()],
19 ["foo", "bar", "quux", "simon's tags"],
20 "Got all categories");
21
22 my $xml = $feed->as_xml;
23 ok($feed = XML::Feed->parse(\$xml), "Reparsed $type from string");
24 is_deeply(
25 [$entry->category()],
26 ["foo", "bar", "quux", "simon's tags"],
27 "Got all categories again");
28
29 ok($entry->category("quirka fleeg"), "Added a category");
30 is_deeply(
31 [$entry->category()],
32 ["foo", "bar", "quux", "simon's tags", "quirka fleeg"],
33 "Got new category");
34
35 ok(my $new = $entry->convert($other), "Converted entry to $other");
36 is_deeply(
37 [$new->category()],
38 ["foo", "bar", "quux", "simon's tags", "quirka fleeg"],
39 "Got converted categories");
40
41}