use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::TestRequest qw/GET_BODY/; BEGIN { plan tests => 9; } # Prepare environment my $head; # expected page header my $foot; # expected page footer my @body; # sections of page body # Helper for replacing file contents sub overwrite { my $file = shift; open my $fh, '>', $file or die "Could not open > $file: $!"; print $fh join('', @_); close $fh; } # Run tests mkdir 't/htdocs/subdir' if ! -d 't/htdocs/subdir'; $head = <Test\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-less head'; @body = ("...\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '-ful head'; @body = ("\n", "This is a test page.\n", "\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", '-wrapped document'; @body = ("\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ''; @body = ("\n\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", ' with leading newline'; @body = ("\n\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", 'comments in '; @body = ("\n", "This is a test page.\n"); overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", 'document with '; overwrite 't/htdocs/subdir/.htaccess', <