|
|
- #!/usr/bin/perl
-
- =pod
-
- =head1 NAME
-
- validate.pl - W3C validate markup from Wala.pm
-
- =head1 SYNOPSIS
-
- Given a working installation and configuration file:
-
- ./validate.pl
-
- =head1 DESCRIPTION
-
- These tests are aimed at a working installation with several files in place,
- and require Test::HTML::W3C as well as Test::Simple. For the time being, I'm
- using "valid W3C HTML" as a proxy for "not broken", and a number of larger
- pages as a proxy for their component features. This works surprisingly well for
- much of what the module does.
-
- What these tests don't validate in any way is the handling of user input,
- writing of pages, change logging, or edit conflict resolution. I'll do
- something about this, eventually. There are also be some issues around
- testing with different configurations.
-
- Nothing here should be destructive.
-
- =head1 SEE ALSO
-
- test.pl in Wala Wiki distribution, Test::HTML::W3C.
-
- =cut
-
- use strict;
- use warnings;
- use lib 'lib';
- use Test::HTML::W3C 'show_detail';
- use Test::Simple tests => 13;
-
- use Wala qw(%DISPLAY_CONF);
-
- # TESTS
-
- section ('configuration');
-
- our (%WalaConf, %DISPLAY_CONF);
- ok (do 'p1k3.conf.pl', "do conf.pl");
- ok (defined %WalaConf, 'External configuration hash defined.');
- ok (my $w = Wala->new(%WalaConf), 'got Wala object.');
-
- # This will turn off stuff that breaks testing.
- $w->TestMode(1);
-
- section ('starting markup validation');
-
- render('HomePage', 'complete rendered HomePage validates');
- render('PageIndex', 'PageIndex validates' );
- render('M', 'Specific letter index validates' );
- render('RecentChanges', 'RecentChanges validates' );
- render('PageChangeTimes', 'PageChangeTimes validates' );
- render('WalaCode', 'WalaCode validates' );
-
- is_valid_markup (
- $w->get_header('SandBox') . $w->edit_form('SandBox') .
- '</body></html>',
- "Edit form validates"
- ) or diag_html();
-
- pause(1);
-
- is_valid_markup (
- $w->get_header('Preferences') . $w->get_preferences_form('HomePage') .
- '</body></html>',
- "Preferences form validates"
- ) or diag_html();
-
- pause(1);
-
- my $cacheval = $w->UseCache;
-
- USECACHE: {
- $w->UseCache(1);
- render('SandBox', 'SandBox validates with caching explicitly enabled.');
- }
-
- NOCACHE: {
- $w->UseCache(0);
- render('SandBox', 'SandBox validates with caching explicitly disabled.' );
- }
-
- $w->UseCache($cacheval);
-
- # END OF TESTS
-
-
- # Utility routines.
-
- sub pause {
- my $time = shift;
- #print " pausing $time seconds\n";
- sleep $time;
- }
-
- sub section {
- my $msg = shift;
- print "\n-- $msg --\n\n";
- }
-
- sub render {
- my $page = shift;
- my $msg = shift;
- my $markup = $w->get_header($page)
- . $w->print_page($page)
- . $w->get_footer($page);
-
- is_valid_markup (
- $markup,
- $msg
- ) or diag_html();
-
- #print $markup;
-
- pause(1);
-
- }
-
|