use strict;
use Wiki::Toolkit::TestConfig::Utilities;
use Wiki::Toolkit;
use URI::Escape;
# Note - update the count in the skip block to match the number here
# we would put the number in a variable, but that doesn't seem to work
use Test::More tests =>
(3 + 16 * $Wiki::Toolkit::TestConfig::Utilities::num_stores);
use_ok( "Wiki::Toolkit::Feed::Atom" );
eval { my $atom = Wiki::Toolkit::Feed::Atom->new; };
ok( $@, "new croaks if no wiki object supplied" );
eval {
my $atom = Wiki::Toolkit::Feed::Atom->new( wiki => "foo" );
};
ok( $@, "new croaks if something that isn't a wiki object supplied" );
my %stores = Wiki::Toolkit::TestConfig::Utilities->stores;
my ($store_name, $store);
while ( ($store_name, $store) = each %stores ) {
SKIP: {
skip "$store_name storage backend not configured for testing", 16
unless $store;
print "#\n##### TEST CONFIG: Store: $store_name\n#\n";
my $wiki = Wiki::Toolkit->new( store => $store );
my %default_config = (
wiki => $wiki,
site_name => "Wiki::Toolkit Test Site",
make_node_url => sub {
my $id = uri_escape($_[0]);
my $version = $_[1] || '';
$version = uri_escape($version) if $version;
"http://example.com/?id=$id;version=$version";
},
recent_changes_link => "http://example.com/?RecentChanges",
atom_link => "http://example.com/?action=rc;format=atom",
);
my $atom = eval {
Wiki::Toolkit::Feed::Atom->new( %default_config, site_url => "http://example.com/kakeswiki/" );
};
is( $@, "",
"'new' doesn't croak if wiki object and mandatory parameters supplied"
);
isa_ok( $atom, "Wiki::Toolkit::Feed::Atom" );
my $feed = eval { $atom->recent_changes; };
is( $@, "", "->recent_changes doesn't croak" );
# Check the things that are generated by the mandatory arguments.
like( $feed, qr||,
"make_node_url is used" );
# Check stuff that comes from the metadata.
like( $feed, qr|