# -*-perl-*- use strict; use Test::More 'no_plan'; use lib "$ENV{LJHOME}/cgi-bin"; require "parsefeed.pl"; require 'ljlib.pl'; # 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}); }