aboutsummaryrefslogtreecommitdiff
path: root/t/basic.t
diff options
context:
space:
mode:
Diffstat (limited to 't/basic.t')
-rw-r--r--t/basic.t65
1 files changed, 40 insertions, 25 deletions
diff --git a/t/basic.t b/t/basic.t
index 4833d68..c82f6e2 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -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';