forked from github/kensanata.oddmuse
More tests regarding local links in static exports
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 31;
|
||||
use Test::More tests => 34;
|
||||
clear_pages();
|
||||
|
||||
add_module('static-copy.pl');
|
||||
@@ -133,7 +133,14 @@ ok(-s "$DataDir/static/Trogs.svgz", "$DataDir/static/Trogs.svgz has nonzero size
|
||||
ok(-s "$DataDir/static/Logo.png", "$DataDir/static/Logo.png has nonzero size");
|
||||
ok(-s "$DataDir/static/HomePage.html", "$DataDir/static/HomePage.html has nonzero size");
|
||||
|
||||
# Make sure spaces are translated to underscores (fixed in image.pl)
|
||||
# check that links between pages work as expected
|
||||
xpath_test(update_page("Test", "Link to HomePage."),
|
||||
'//a[text()="HomePage"][@href="http://localhost/wiki.pl/HomePage"]');
|
||||
test_page(get_page('action=static raw=1 pwd=foo html=1'), 'Test');
|
||||
xpath_test_file("$DataDir/static/Test.html",
|
||||
'//a[text()="HomePage"][@href="HomePage.html"]');
|
||||
|
||||
# make sure spaces are translated to underscores (fixed in image.pl)
|
||||
add_module('image.pl');
|
||||
|
||||
# Now, create real pages. First, we'll use the ordinary image link to
|
||||
|
||||
23
t/test.pl
23
t/test.pl
@@ -158,6 +158,18 @@ sub test_page {
|
||||
}
|
||||
}
|
||||
|
||||
# one file, many tests
|
||||
sub test_file {
|
||||
my ($file, @tests) = @_;
|
||||
if (open(F, '<', $file)) {
|
||||
local $/ = undef;
|
||||
test_page(<F>, @tests);
|
||||
close(F);
|
||||
} else {
|
||||
warn "cannot open $file\n";
|
||||
}
|
||||
}
|
||||
|
||||
# one string, many negative tests
|
||||
sub test_page_negative {
|
||||
my $page = shift;
|
||||
@@ -208,6 +220,17 @@ sub xpath_test {
|
||||
xpath_do(sub { shift > 0; }, "No Matches\n", @_);
|
||||
}
|
||||
|
||||
sub xpath_test_file {
|
||||
my ($file, @tests) = @_;
|
||||
if (open(F, '<', $file)) {
|
||||
local $/ = undef;
|
||||
xpath_test(<F>, @tests);
|
||||
close(F);
|
||||
} else {
|
||||
warn "cannot open $file\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub negative_xpath_test {
|
||||
xpath_do(sub { shift == 0; }, "Unexpected Matches\n", @_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user