1use strict;
2use warnings;
3
4use Test::More tests => 14;
5
6use XML::Feed;
7use File::Spec;
8
9
10{
11    my $rss = XML::Feed->parse(
12        File::Spec->catfile(File::Spec->curdir(),
13            "t", "samples", "rss10-double2.xml"
14        )
15    );
16
17    # TEST
18    isa_ok($rss, 'XML::Feed::Format::RSS');
19    my $rss_entry = ($rss->entries)[0];
20
21    # TEST
22    isa_ok($rss_entry, 'XML::Feed::Entry::Format::RSS');
23
24
25    my $rss_content = $rss_entry->content;
26
27    # TEST
28    isa_ok($rss_content, 'XML::Feed::Content');
29
30    # TEST
31    is($rss_content->type, 'text/html', 'Correct content type');
32
33    # TEST
34    like($rss_content->body, qr(<|&lt;), 'Contains HTML tags');
35
36    # TEST
37    isnt(index($rss_content->body,
38               '<img src="http://s.ph-cdn.com/newman/gfx/news/2011/3-neuroscienti.jpg" width="300" class="articleImage" />'),
39         -1,
40         'Contains HTML tags');
41
42    unlike($rss->as_xml, qr{&amp;lt;}, 'No double encoding');
43
44    my $atom = $rss->convert('Atom');
45
46    # TEST
47    isa_ok($atom, 'XML::Feed::Format::Atom');
48
49    my $atom_entry = ($atom->entries)[0];
50
51    # TEST
52    isa_ok($atom_entry, 'XML::Feed::Entry::Format::Atom');
53
54    my $atom_content = $atom_entry->content;
55
56    # TEST
57    isa_ok($atom_content, 'XML::Feed::Content');
58
59    # TEST
60    is($atom_content->type, 'text/html', 'Correct content type');
61
62    # TEST
63    like($atom_content->body, qr(<|&lt;), 'Contains HTML tags');
64
65    # TEST
66    isnt(index($atom_content->body,
67               '<img src="http://s.ph-cdn.com/newman/gfx/news/2011/3-neuroscienti.jpg" width="300" class="articleImage" />'),
68         -1,
69         'Contains HTML tags');
70
71    unlike($atom->as_xml, qr{&amp;lt;}, 'No double encoding');
72}
73
74