fix MANIFEST.SKIP
[catagits/XML-Feed.git] / t / 14-multi-enclosures.t
CommitLineData
b1aa7a62 1#!perl -w
2
3use strict;
4use Test::More;
5use XML::Feed;
6use XML::Feed::Enclosure;
7
8$XML::Feed::MULTIPLE_ENCLOSURES=1;
9
10my @formats = qw(atom rss20);
11plan tests => scalar(@formats)*38;
12
13foreach my $format (@formats) {
14 ok (my $feed = XML::Feed->parse("t/samples/$format-multi-enclosure.xml"), "Parsed $format");
15 my ($entry) = $feed->entries;
16 ok (my @enclosures = $entry->enclosure, "Got enclosure");
17 ok ($enclosures[0]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
18 is ($enclosures[0]->type, "audio/mpeg", "Got the enclosure mime type");
19 is ($enclosures[0]->length, "2478719", "Got enclosure length");
20 is ($enclosures[0]->url, "http://example.com/sample_podcast.mp3", "Got enclosure url");
21 ok ($enclosures[1]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
22 is ($enclosures[1]->type, "video/mpeg", "Got the enclosure mime type");
23 is ($enclosures[1]->length, "8888", "Got enclosure length");
24 is ($enclosures[1]->url, "http://example.com/sample_movie.mpg", "Got enclosure url");
25
26 ok (my $tmp = XML::Feed::Enclosure->new({ type => "image/jpeg" }), "Created a new enclosure");
27 is ($tmp->type, "image/jpeg", "Got type back");
28 ok ($tmp->url("http://example.com/sample_image.jpg"), "Set url");
29 ok ($tmp->length("1337"), "Set length");
30 ok ($entry->enclosure($tmp), "Set the enclosure");
31
32 ok (@enclosures = $entry->enclosure, "Got enclosure again");
33 ok ($enclosures[-1]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
34 is ($enclosures[-1]->type, "image/jpeg", "Got the enclosure mime type");
35 is ($enclosures[-1]->length, "1337", "Got enclosure length again");
36 is ($enclosures[-1]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
37
38 my $xml = $feed->as_xml;
39 ok ($feed = XML::Feed->parse(\$xml), "Parsed xml again");
40 ok (@enclosures = $entry->enclosure, "Got enclosure again");
41 ok ($enclosures[0]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
42 is ($enclosures[0]->type, "audio/mpeg", "Got the enclosure mime type");
43 is ($enclosures[0]->length, "2478719", "Got enclosure length");
44 is ($enclosures[0]->url, "http://example.com/sample_podcast.mp3", "Got enclosure url");
45 ok ($enclosures[1]->isa("XML::Feed::Enclosure"), "Object isa XML::Feed::Enclosure");
46 is ($enclosures[1]->type, "video/mpeg", "Got the enclosure mime type");
47 is ($enclosures[1]->length, "8888", "Got enclosure length");
48 is ($enclosures[1]->url, "http://example.com/sample_movie.mpg", "Got enclosure url");
49 ok ($enclosures[2]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
50 is ($enclosures[2]->type, "image/jpeg", "Got the enclosure mime type");
51 is ($enclosures[2]->length, "1337", "Got enclosure length again");
52 is ($enclosures[2]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
53 ok ($enclosures[-1]->isa("XML::Feed::Enclosure"), "Object still isa XML::Feed::Enclosure");
54 is ($enclosures[-1]->type, "image/jpeg", "Got the enclosure mime type");
55 is ($enclosures[-1]->length, "1337", "Got enclosure length again");
56 is ($enclosures[-1]->url, "http://example.com/sample_image.jpg", "Got enclosure url again");
57
58
59}