Better diagnostics
Simon Wistow [Wed, 17 Dec 2008 23:48:44 +0000 (23:48 +0000)]
t/12-multi-categories.t [new file with mode: 0644]

diff --git a/t/12-multi-categories.t b/t/12-multi-categories.t
new file mode 100644 (file)
index 0000000..41c27b1
--- /dev/null
@@ -0,0 +1,42 @@
+#!perl -w
+
+use strict;
+use strict;
+use Test::More tests => 8 * 3;
+use XML::Feed;
+
+foreach my $test (["atom"], ["rss", "subjects"], ["rss"]) {
+
+    my $type  = $test->[0];
+    my $other = ('Atom' ne $type)? "RSS" : "RSS";
+    my $field = $test->[1] || "categories";
+    my $sing  = ("categories" eq $field)? "category" : "subject";
+
+    ok(my $feed = XML::Feed->parse("t/samples/${type}-multiple-${field}.xml"), "Parsed $type file with multiple $field");
+    my ($entry) = $feed->entries;
+
+    is_deeply(
+        [$entry->category()],
+        ["foo", "bar", "quux", "simon's tags"],        
+    "Got all $field");
+
+    my $xml = $feed->as_xml;
+    ok($feed = XML::Feed->parse(\$xml), "Reparsed $type from string");
+    is_deeply(
+        [$entry->category()],
+        ["foo", "bar", "quux", "simon's tags"],        
+    "Got all $field again");
+
+    ok($entry->category("quirka fleeg"), "Added a $sing");
+    is_deeply(
+        [$entry->category()],
+        ["foo", "bar", "quux", "simon's tags", "quirka fleeg"],        
+    "Got new $sing");
+
+    ok(my $new = $entry->convert($other), "Converted entry to $other");
+    is_deeply(
+        [$new->category()],
+        ["foo", "bar", "quux", "simon's tags", "quirka fleeg"],        
+    "Got converted $field");
+
+}