# t/parsefeed-authors.t
#
# Test LJ::ParseFeed with various author tags.
#
# 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 => 11;
BEGIN { $LJ::_T_CONFIG = 1; require "$ENV{LJHOME}/cgi-bin/ljlib.pl"; }
use LJ::ParseFeed;
my $feed_rss = q {
Title
http://examplecomm.dream.fu/
Title - Dreamwidth StudiosThu, 03 Feb 2011 17:00:43 GMTLiveJournal / Dreamwidth Studiosexamplecommcommunityhttp://www.dream.fu/userpic/1/2Title
http://examplecomm.dream.fu/
100100http://examplecomm.dream.fu/12345.htmlThu, 03 Feb 2011 17:00:43 GMTyo
http://examplecomm.dream.fu/12345.html
yohttp://examplecomm.dream.fu/12345.htmlexample-dc-creatorhttp://examplecomm.dream.fu/123.html>Wed, 24 Nov 2010 06:52:33 GMTyo
http://examplecomm.dream.fu/123.html
yohttp://examplecomm.dream.fu/123.htmlexample-lj-posterpublic0http://examplecomm.dream.fu/456.html>Wed, 24 Jun 2010 06:52:33 GMTyo
http://examplecomm.dream.fu/456.html
yohttp://examplecomm.dream.fu/456.htmlexample-dw-posterpublic0http://examplecomm.dream.fu/789.htmlMon, 07 Feb 2011 12:00:00 GMTyo
http://examplecomm.dream.fu/789.html
yoFirst AuthorSecond Author};
my $feed_atom = q {
Feed titleexample:atom:feed2011-01-23T17:38:49-08:00example-feed-authorItem 112011-01-23T13:58:08-08:002011-01-23T13:58:08-08:00example-atom-authorfooItem 222011-01-23T13:59:55-08:002011-01-23T13:59:55-08:00barItem 332011-01-23T17:38:49-08:002011-01-23T17:38:49-08:00bazItem 442011-01-23T18:38:49-08:002011-01-23T18:38:49-08:00quuxItem 552011-01-23T19:38:49-08:002011-01-23T19:38:49-08:00bogus-atom-authorblech};
my ( $parse_rss, $rss_error ) = LJ::ParseFeed::parse_feed( $feed_rss, "rss" );
is( $rss_error, undef, "RSS parse OK" );
SKIP: {
skip "RSS parse failed", 3 if $rss_error;
is( $parse_rss->{items}->[0]->{author}, "example-dc-creator", " tag" );
is( $parse_rss->{items}->[1]->{author}, "example-lj-poster", " tag" );
is( $parse_rss->{items}->[2]->{author}, "example-dw-poster", " tag" );
is(
$parse_rss->{items}->[3]->{author},
"First Author, Second Author",
"multiple tags"
);
}
my ( $parse_atom, $atom_error ) = LJ::ParseFeed::parse_feed( $feed_atom, "atom" );
is( $atom_error, undef, "Atom parse OK" );
SKIP: {
skip "Atom parse failed", 5 if $atom_error;
is( $parse_atom->{items}->[0]->{author}, "example-atom-author", "item tag" );
is( $parse_atom->{items}->[1]->{author}, "example-dw-poster", " tag" );
is( $parse_atom->{items}->[2]->{author}, "example-lj-poster", " tag" );
is( $parse_atom->{items}->[3]->{author}, "example-feed-author", "feed tag" );
is( $parse_atom->{items}->[4]->{author},
"prefer-lj-poster", "both and tags" );
}