# t/parsefeed-atom-link3.t # # Test LJ::ParseFeed handling of xml:base in atom feeds. # # This code was forked from the LiveJournal project owned and operated # by Live Journal, Inc. The code has been modified and expanded by # Dreamwidth Studios, LLC. These files were originally licensed under # the terms of the license supplied by Live Journal, Inc, which can # currently be found at: # # http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt # # In accordance with the original license, this code and all its # modifications are provided under the GNU General Public License. # A copy of that license can be found in the LICENSE file included as # part of this distribution. use strict; use warnings; use Test::More tests => 12; BEGIN { $LJ::_T_CONFIG = 1; require "$ENV{LJHOME}/cgi-bin/ljlib.pl"; } use LJ::ParseFeed; # These tests check for correct handling of xml:base # This is taken verbatim from Aristotle Pagaltzis's set of test cases: # # Here's a giant, obnoxious hunk of XML! my $contents = qq{ xml:base support tests All alternate links should point to <code>http://example.org/tests/base/result.html</code>; all links in content should point where their label says. tag:plasmasturm.org,2005:Atom-Tests:xml-base 2006-01-17T12:35:16+01:00 1: Alternate link: Absolute URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test1 2006-01-17T12:35:16+01:00 2: Alternate link: Host-relative absolute URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test2 2006-01-17T12:35:15+01:00 3: Alternate link: Relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test3 2006-01-17T12:35:14+01:00 4: Alternate link: Relative URL with parent directory component tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test4 2006-01-17T12:35:13+01:00 5: Content: Absolute URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test5 <a href="http://example.org/tests/base/result.html">http://example.org/tests/base/result.html</a> 2006-01-17T12:35:12+01:00 6: Content: Host-relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test6 <a href="/tests/base/result.html">http://example.org/tests/base/result.html</a> 2006-01-17T12:35:11+01:00 7: Content: Relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test7 <a href="base/result.html">http://example.org/tests/base/result.html</a> 2006-01-17T12:35:10+01:00 8: Content: Relative URL with parent directory component tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test8 <a href="../tests/base/result.html">http://example.org/tests/base/result.html</a> 2006-01-17T12:35:9+01:00 9: Content, <code>&lt;entry></code> has base: Absolute URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test9 <a href="http://example.org/tests/entrybase/result.html">http://example.org/tests/entrybase/result.html</a> 2006-01-17T12:35:8+01:00 10: Content, <code>&lt;entry></code> has base: Host-relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test10 <a href="/tests/entrybase/result.html">http://example.org/tests/entrybase/result.html</a> 2006-01-17T12:35:7+01:00 11: Content, <code>&lt;entry></code> has base: Relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test11 <a href="result.html">http://example.org/tests/entrybase/result.html</a> 2006-01-17T12:35:6+01:00 12: Content, <code>&lt;entry></code> has base: Relative URL with parent directory component tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test12 <a href="../entrybase/result.html">http://example.org/tests/entrybase/result.html</a> 2006-01-17T12:35:5+01:00 13: Content, <code>&lt;content></code> has base: Absolute URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test13 <a href="http://example.org/tests/contentbase/result.html">http://example.org/tests/contentbase/result.html</a> 2006-01-17T12:35:4+01:00 14: Content, <code>&lt;content></code> has base: Host-relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test14 <a href="/tests/contentbase/result.html">http://example.org/tests/contentbase/result.html</a> 2006-01-17T12:35:3+01:00 15: Content, <code>&lt;content></code> has base: Relative URL tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test15 <a href="result.html">http://example.org/tests/contentbase/result.html</a> 2006-01-17T12:35:2+01:00 16: Content, <code>&lt;content></code> has base: Relative URL with parent directory component tag:plasmasturm.org,2005:Atom-Tests:xml-base:Test16 <a href="../contentbase/result.html">http://example.org/tests/contentbase/result.html</a> 2006-01-17T12:35:1+01:00 }; my ( $feed, $error ) = LJ::ParseFeed::parse_feed($contents); foreach my $item ( @{ $feed->{items} } ) { is( $item->{link}, "http://example.org/tests/base/result.html", $item->{subject} ); }