Tests to ensure that the double-encoding bug fix works.
[catagits/XML-Feed.git] / t / 18-double2.t
CommitLineData
b0d119a2 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", "rss20-double.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 like($rss_content->body,
cb30c634 38 qr{\Q<a href="http://search.cpan.org/perldoc?Dancer">Dancer</a>},
b0d119a2 39 'Contains HTML tags');
40
41 unlike($rss->as_xml, qr{&amp;lt;}, 'No double encoding');
42
43 my $atom = $rss->convert('Atom');
44
45 # TEST
46 isa_ok($atom, 'XML::Feed::Format::Atom');
47
48 my $atom_entry = ($atom->entries)[0];
49
50 # TEST
51 isa_ok($atom_entry, 'XML::Feed::Entry::Format::Atom');
52
53 my $atom_content = $atom_entry->content;
54
55 # TEST
56 isa_ok($atom_content, 'XML::Feed::Content');
57
58 # TEST
59 is($atom_content->type, 'text/html', 'Correct content type');
60
61 # TEST
62 like($atom_content->body, qr(<|&lt;), 'Contains HTML tags');
63
64 # TEST
65 like($atom_content->body,
cb30c634 66 qr{\Q<a href="http://search.cpan.org/perldoc?Dancer">Dancer</a>},
b0d119a2 67 'Contains HTML tags');
68
69 unlike($atom->as_xml, qr{&amp;lt;}, 'No double encoding');
70}
71