From 15570afe4b375ddc60b04fc93c4e354beafae3fb Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Tue, 18 Mar 2014 10:32:22 +0100 Subject: [PATCH] More tests regarding local links in static exports --- t/static-copy.t | 11 +++++++++-- t/test.pl | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/t/static-copy.t b/t/static-copy.t index 836750c2..9a77a804 100644 --- a/t/static-copy.t +++ b/t/static-copy.t @@ -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 diff --git a/t/test.pl b/t/test.pl index 2143406d..a5c342aa 100755 --- a/t/test.pl +++ b/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(, @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(, @tests); + close(F); + } else { + warn "cannot open $file\n"; + } +} + sub negative_xpath_test { xpath_do(sub { shift == 0; }, "Unexpected Matches\n", @_); }