diff options
Diffstat (limited to 't')
-rw-r--r-- | t/basic.t | 65 | ||||
-rw-r--r-- | t/conf/extra.conf.in | 4 | ||||
-rw-r--r-- | t/conf/extra.last.conf.in | 3 |
3 files changed, 44 insertions, 28 deletions
@@ -7,46 +7,61 @@ use Apache::TestRequest qw/GET_BODY/; plan tests => 5; -# Prepare environment +my $head; # expected page header +my $foot; # expected page footer +my @body; # sections of page body -open my $h, '<', 't/htdocs/head.html' or die; -open my $f, '<', 't/htdocs/foot.html' or die; -my $head = do { local $/; <$h> }; -my $foot = do { local $/; <$f> }; +# Read contents of header and footer + +open my $h, '<', 't/htdocs/head.html' or die "Could not open < head.html: $!"; +open my $f, '<', 't/htdocs/foot.html' or die "Could not open < foot.html: $!"; +$head = do { local $/; <$h> }; +$foot = do { local $/; <$f> }; close $h; close $f; -my @test; -sub prepare { - open my $t, '>', 't/htdocs/test.html' or die; - print $t join('', @_); - close $t; +# Set up helpers + +sub set_conf { + open my $c, '>', 't/htdocs/.htaccess' or die; + print $c shift; + close $c; +} +sub set_body { + open my $b, '>', 't/htdocs/test.html' or die; + print $b join('', @_); + close $b; } # Run tests -@test = ("<title>Test</title>\n", "This is a test page.\n"); -prepare @test; -ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", +set_conf <<CONF; +Inject head.html foot.html +CONF + +@body = ("<title>Test</title>\n", "This is a test page.\n"); +set_body @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<head>-less head'; -@test = ("<head>...</head>\n", "This is a test page.\n"); -prepare @test; -ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", +@body = ("<head>...</head>\n", "This is a test page.\n"); +set_body @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<head>-ful head'; -@test = ("<html>\n", "This is a test page.\n", "</html>\n"); -prepare @test; -ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot${test[2]}", +@body = ("<html>\n", "This is a test page.\n", "</html>\n"); +set_body @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", '<html>-wrapped document'; -@test = ("<!doctype html>\n", "This is a test page.\n"); -prepare @test; -ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", +@body = ("<!doctype html>\n", "This is a test page.\n"); +set_body @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype>'; -@test = ("\n<!doctype html>\n", "This is a test page.\n"); -prepare @test; -ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", +@body = ("\n<!doctype html>\n", "This is a test page.\n"); +set_body @body; +ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype> with leading newline'; +unlink 't/htdocs/.htaccess'; unlink 't/htdocs/test.html'; diff --git a/t/conf/extra.conf.in b/t/conf/extra.conf.in index fe9de1d..1a9ce52 100644 --- a/t/conf/extra.conf.in +++ b/t/conf/extra.conf.in @@ -1 +1,5 @@ PerlSwitches -I@ServerRoot@/../lib +<Directory /> + Options FollowSymLinks + AllowOverride All +</Directory> diff --git a/t/conf/extra.last.conf.in b/t/conf/extra.last.conf.in index 0156023..b708606 100644 --- a/t/conf/extra.last.conf.in +++ b/t/conf/extra.last.conf.in @@ -1,4 +1 @@ PerlLoadModule Apache::Inject -<FilesMatch ".*\.html"> - Inject head.html foot.html -</FilesMatch> |