# 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 Studios Thu, 03 Feb 2011 17:00:43 GMT LiveJournal / Dreamwidth Studios examplecomm community http://www.dream.fu/userpic/1/2 Title http://examplecomm.dream.fu/ 100 100 http://examplecomm.dream.fu/12345.html Thu, 03 Feb 2011 17:00:43 GMT yo http://examplecomm.dream.fu/12345.html yo http://examplecomm.dream.fu/12345.html example-dc-creator http://examplecomm.dream.fu/123.html >Wed, 24 Nov 2010 06:52:33 GMT yo http://examplecomm.dream.fu/123.html yo http://examplecomm.dream.fu/123.html example-lj-poster public 0 http://examplecomm.dream.fu/456.html >Wed, 24 Jun 2010 06:52:33 GMT yo http://examplecomm.dream.fu/456.html yo http://examplecomm.dream.fu/456.html example-dw-poster public 0 http://examplecomm.dream.fu/789.html Mon, 07 Feb 2011 12:00:00 GMT yo http://examplecomm.dream.fu/789.html yo First Author Second Author }; my $feed_atom = q { Feed title example:atom:feed 2011-01-23T17:38:49-08:00 example-feed-author Item 1 1 2011-01-23T13:58:08-08:00 2011-01-23T13:58:08-08:00 example-atom-author foo Item 2 2 2011-01-23T13:59:55-08:00 2011-01-23T13:59:55-08:00 bar Item 3 3 2011-01-23T17:38:49-08:00 2011-01-23T17:38:49-08:00 baz Item 4 4 2011-01-23T18:38:49-08:00 2011-01-23T18:38:49-08:00 quux Item 5 5 2011-01-23T19:38:49-08:00 2011-01-23T19:38:49-08:00 bogus-atom-author blech }; 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" ); }