Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 71 lines (64 sloc) 2.278 kb
b2d22f9 Tatsuhiko Miyagawa added tests
authored
1 use strict;
2 use Test::More;
3
4 BEGIN {
5 unless (eval { require XML::XPath }) {
6 plan skip_all => 'XML::XPath required for this test';
7 }
8 }
9
10 plan tests => 4;
11 BEGIN {
12 ## hardcore, because XML::Atom doesn't make it easy to change it at
13 ## runtime
14 require XML::Atom;
15 if (XML::Atom->LIBXML) {
16 no strict 'refs';
17 diag "XPath Override in place";
18 *{XML::Atom::LIBXML} = sub() {0};
19 }
20 }
21
22 use XML::Parser;
23 use XML::Atom::Entry;
24 use FindBin;
25 my $filepath = "$FindBin::Bin/samples/entry-ns.xml";
26
27 my $xml = <<"EOX";
28 <?xml version="1.0" encoding="utf-8"?>
29 <!DOCTYPE entry [
30 <!ENTITY ref SYSTEM "file://$filepath">
31 ]>
32 <entry xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
33 <title>Guest Author</title>
34 <link rel="alternate" type="text/html" href="http://ben.stupidfool.org/typepad/2003/07/guest_author.html" />
35 <link rel="service.edit" title="Edit" type="application/x.atom+xml" href="http://www.example.com/atom/entry_id=75207" />
36 <id>tag:typepad.com:post:75207</id>
37 <issued>2003-07-21T02:47:34-07:00</issued>
38 <modified>2003-08-22T18:36:57-07:00</modified>
39 <created>2003-07-21T02:47:34-07:00</created>
40 <summary>No, Ben isn&apos;t updating. It&apos;s me testing out guest author functionality....</summary>
41 <author>
42 <name>Mena</name>
43 <url>http://mena.typepad.com/</url>
44 </author>
45 <dc:subject>Food</dc:subject>
46 <dc:subject>Cats</dc:subject>
47 <content type="text/html" xml:lang="en-us">&ref;
48 <div xmlns="http://www.w3.org/1999/xhtml"><p>No, Ben isn't updating. It's me testing out guest author functionality.</p></div>
49 </content>
50 </entry>
51 EOX
52
53 ## Sane default
54 {
55 my $entry = XML::Atom::Entry->new(Stream => \$xml);
56 is $entry->title, "Guest Author", "got title";
57 my $content = $entry->content->body;
58 unlike $content, qr/This is what you get when you do unit testing/,
59 "ignored entity";
60 }
61
62 ## custom parser
63 {
64 my $parser = XML::Parser->new(); # no option
65 my $entry = XML::Atom::Entry->new(Stream => \$xml, Parser => $parser);
66 is $entry->title, "Guest Author", "got title";
67 my $content = $entry->content->body;
68 like $content, qr/This is what you get when you do unit testing/,
69 "resolved entity";
70 }
Something went wrong with that request. Please try again.