#!/usr/bin/perl
|
|
|
|
=pod
|
|
|
|
=head1 NAME
|
|
|
|
test.pl - a set of basic tests for display
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
Given a working installation and configuration file:
|
|
|
|
./test.pl
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This section to-come.
|
|
|
|
=head1 MISSING TESTS
|
|
|
|
These items aren't tested at all, at the moment. A number of them aren't
|
|
particularly trivial to test.
|
|
|
|
sub get_diff
|
|
sub get_latest_diff_date
|
|
sub write_page
|
|
sub add_to_page
|
|
sub log_page_edit
|
|
sub parse_cookies
|
|
sub write_cookies_to_browser
|
|
sub setup
|
|
sub parse_parameters
|
|
sub write_diff
|
|
sub merge_diff
|
|
|
|
=head1 SEE ALSO
|
|
|
|
validate.pl in the WalaWiki distribution.
|
|
|
|
=cut
|
|
|
|
use strict;
|
|
use warnings;
|
|
use lib 'lib';
|
|
#use Test::HTML::W3C 'show_detail';
|
|
use Test::Simple tests => 10;
|
|
|
|
use Wala qw(%WalaConf %DISPLAY_CONF);
|
|
|
|
# TESTS
|
|
|
|
section ('configuration');
|
|
|
|
ok (Wala::eval_file("p1k3.conf.pl"), "eval_file on p1k3.conf.pl");
|
|
ok (defined %WalaConf, 'External configuration hash defined.');
|
|
|
|
section ('individual subroutine tests');
|
|
|
|
# This will turn off stuff that breaks testing.
|
|
$WalaConf{TestMode} = 1;
|
|
|
|
ok (Wala::get_username eq $WalaConf{'DefaultUserName'},
|
|
"get_username returns default.");
|
|
|
|
ok (Wala::get_mtime('Wala.pm') =~ m/\d+/,
|
|
'get_mtime returns digits.');
|
|
|
|
ok (Wala::mygmtime(0) eq 'Thu, 01-Jan-1970 00:00:00 GMT',
|
|
'mygmtime(0) returns epoch');
|
|
|
|
# Hack. Depends on ./log
|
|
LOGFILE: {
|
|
local $WalaConf{RootDir} = "./";
|
|
ok (Wala::recent_changes(1) =~ m/\d+ \w+ \w+.*$/,
|
|
'recent_changes(1) returns an appropriate logfile line.');
|
|
}
|
|
|
|
ok (Wala::spamcheck("http://spamcheckfunction.com", "TEST", "TEST") == 1,
|
|
'spamcheck trips on a URL');
|
|
|
|
section ('starting link code testing');
|
|
|
|
ok (
|
|
Wala::make_links_of_wiki_words('TestWord')
|
|
=~ m/<a href="$WalaConf{ScriptName}\?.*?TestWord"/,
|
|
'Return link for TestWord'
|
|
);
|
|
|
|
ok (
|
|
Wala::get_bracketed_link("[http://p1k3.com/ p1k3]")
|
|
eq "<a href=\"http://p1k3.com/\" class=\"external\">p1k3</a>",
|
|
'Return bracketed link'
|
|
);
|
|
|
|
# this isn't doing what I'd like it to.
|
|
ok (
|
|
Wala::pagelinks('PageLink [other page link]'),
|
|
'Pagelinks sub finds ' . Wala::pagelinks('PageLink [other page link]') . ' links'
|
|
);
|
|
|
|
|
|
# END OF TESTS
|
|
|
|
|
|
# Utility routines.
|
|
|
|
sub hash_print {
|
|
my %hash = @_;
|
|
my $string;
|
|
for my $key (keys %hash) {
|
|
$string .= "\n$key: $hash{$key}";
|
|
}
|
|
|
|
return $string;
|
|
}
|
|
|
|
sub pause {
|
|
my $time = shift;
|
|
#print " pausing $time seconds\n";
|
|
sleep $time;
|
|
}
|
|
|
|
sub section {
|
|
my $msg = shift;
|
|
print "\n-- $msg --\n\n";
|
|
}
|