# t/parsefeed-atom-link2.t # # Test LJ::ParseFeed detection of alternate/rel links in atom. # # 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 => 8; BEGIN { $LJ::_T_CONFIG = 1; require "$ENV{LJHOME}/cgi-bin/ljlib.pl"; } use LJ::ParseFeed; # These tests are of the correct identification of an "alternate" link. # We assume here that an HTML alternate link is preferred over text/plain, # despite the fact that preferring the latter is technically allowed. # This is taken verbatim from James Snell's set of test cases: # # Here's a giant, obnoxious hunk of XML! my $contents = qq{ tag:snellspace.com,2006:/atom/conformance/linktest/ Atom Link Tests 2005-01-18T15:10:00Z James Snell tag:snellspace.com,2006:/atom/conformance/linktest/1 Just a single Alternate Link 2005-01-18T15:00:01Z The aggregator should pick the second link as the alternate tag:snellspace.com,2006:/atom/conformance/linktest/2 Two alternate links 2005-01-18T15:00:02Z The aggregator should pick either the second or third link below as the alternate tag:snellspace.com,2006:/atom/conformance/linktest/3 One of each core link rel type 2005-01-18T15:00:03Z The aggregator should pick the first link as the alternate tag:snellspace.com,2006:/atom/conformance/linktest/4 One of each core link rel type + An additional alternate link 2005-01-18T15:00:04Z The aggregator should pick either the first or last links as the alternate. First link is likely better. tag:snellspace.com,2006:/atom/conformance/linktest/5 Entry with a link relation registered by an extension 2005-01-18T15:00:05Z The aggregator should ignore the license link without throwing any errors. The first link should be picked as the alternate. tag:snellspace.com,2006:/atom/conformance/linktest/6 Entry with a link relation identified by URI 2005-01-18T15:00:06Z The aggregator should ignore the second link without throwing any errors. The first link should be picked as the alternate. tag:snellspace.com,2006:/atom/conformance/linktest/7 Entry with a link relation registered by an extension 2005-01-18T15:00:05Z The aggregator should ignore the license link without throwing any errors. The second link should be picked as the alternate. tag:snellspace.com,2006:/atom/conformance/linktest/8 Entry with a link relation identified by URI 2005-01-18T15:00:06Z The aggregator should ignore the first link without throwing any errors. The second link should be picked as the alternate. }; my ( $feed, $error ) = LJ::ParseFeed::parse_feed($contents); foreach my $item ( @{ $feed->{items} } ) { is( $item->{link}, "http://www.snellspace.com/public/linktests/alternate", $item->{subject} ); }