use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::TestRequest qw/GET_BODY/; plan tests => 5; my $head; # expected page header my $foot; # expected page footer my @body; # sections of page body # 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; # 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 set_conf <Test\n", "This is a test page.\n"); set_body @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-less head'; @body = ("...\n", "This is a test page.\n"); set_body @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-ful head'; @body = ("\n", "This is a test page.\n", "\n"); set_body @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", '-wrapped document'; @body = ("\n", "This is a test page.\n"); set_body @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ''; @body = ("\n\n", "This is a test page.\n"); set_body @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ' with leading newline'; unlink 't/htdocs/.htaccess'; unlink 't/htdocs/test.html';