1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#============================================================= -*-perl-*-
#
# t/rss.t
#
# Test the XML::RSS plugin.
#
# Written by Andy Wardley <abw@kfs.org>
#
# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id: rss.t,v 2.4 2003/04/11 12:26:03 darren Exp $
#
#========================================================================
use strict;
use lib qw( lib ../lib );
use Template;
use Template::Test;
use Cwd qw( abs_path );
$^W = 1;
# I hate having to do this
my $shut_up_warnings = $XML::RSS::VERSION;
eval "use XML::RSS";
skip_all('XML::RSS v 0.9 or later not installed')
if $@ || ($] == 5.006 && $XML::RSS::VERSION < 0.9);
# account for script being run in distribution root or 't' directory
my $file = abs_path( -d 't' ? 't/test/xml' : 'test/xml' );
$file .= '/example.rdf';
local *RSS;
open RSS, $file or die "Can't open $file: $!";
my $data = join "" => <RSS>;
close RSS;
test_expect(\*DATA, undef, { 'newsfile' => $file, 'newsdata' => $data });
__END__
-- test --
[% USE news = XML.RSS(newsfile) -%]
[% FOREACH item = news.items -%]
* [% item.title %]
[% item.link %]
[% END %]
-- expect --
* I Read the News Today
http://oh.boy.com/
* I am the Walrus
http://goo.goo.ga.joob.org/
-- test --
[% USE news = XML.RSS(newsfile) -%]
[% news.channel.title %]
[% news.channel.link %]
-- expect --
Template Toolkit XML::RSS Plugin
http://template-toolkit.org/plugins/XML/RSS
-- test --
[% USE news = XML.RSS(newsfile) -%]
[% news.image.title %]
[% news.image.url %]
-- expect --
Test Image
http://www.myorg.org/images/test.png
-- test --
[% USE news = XML.RSS(newsdata) -%]
[% FOREACH item = news.items -%]
* [% item.title %]
[% item.link %]
[% END %]
-- expect --
* I Read the News Today
http://oh.boy.com/
* I am the Walrus
http://goo.goo.ga.joob.org/
-- test --
[% USE news = XML.RSS(newsdata) -%]
[% news.channel.title %]
[% news.channel.link %]
-- expect --
Template Toolkit XML::RSS Plugin
http://template-toolkit.org/plugins/XML/RSS
-- test --
[% USE news = XML.RSS(newsdata) -%]
[% news.image.title %]
[% news.image.url %]
-- expect --
Test Image
http://www.myorg.org/images/test.png
|