diff options
Diffstat (limited to 't/basic.t')
-rw-r--r-- | t/basic.t | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -7,6 +7,8 @@ use Apache::TestRequest qw/GET_BODY/; BEGIN { plan tests => 7; } +# Prepare environment + my $head; # expected page header my $foot; # expected page footer my @body; # sections of page body @@ -25,7 +27,7 @@ close $h; close $f; # Helper for replacing file contents -sub set { +sub overwrite { my $file = shift; open my $fh, '>', $file or die "Could not open > $file: $!"; print $fh join('', @_); @@ -34,56 +36,54 @@ sub set { # Run tests -set 't/htdocs/.htaccess', <<CONF; -Inject " " -CONF - -@body = ("This is a test page.\n"); -set 't/htdocs/test.html', @body; -set 't/htdocs/ ', 'whatever'; -ok GET_BODY('/test.html'), ${body[0]}, # should not include 'whatever' - 'single-space argument should fail'; - -set 't/htdocs/.htaccess', <<CONF; +overwrite 't/htdocs/.htaccess', <<CONF; Inject head.html foot.html CONF @body = ("<title>Test</title>\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<head>-less head'; @body = ("<head>...</head>\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<head>-ful head'; -set 't/htdocs/subdir/.htaccess', <<CONF; +overwrite 't/htdocs/subdir/.htaccess', <<CONF; Inject head.html CONF @body = ("This is a test page.\n"); -set 't/htdocs/subdir/test.html', @body; +overwrite 't/htdocs/subdir/test.html', @body; ok GET_BODY('/subdir/test.html'), "$head${body[0]}", 'different injection in subdirectory'; @body = ("<html>\n", "This is a test page.\n", "</html>\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot${body[2]}", '<html>-wrapped document'; @body = ("<!doctype html>\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype>'; @body = ("\n<!doctype html>\n", "This is a test page.\n"); -set 't/htdocs/test.html', @body; +overwrite 't/htdocs/test.html', @body; ok GET_BODY('/test.html'), "${body[0]}$head${body[1]}$foot", '<!doctype> with leading newline'; +overwrite 't/htdocs/.htaccess', <<CONF; +Inject - head.html +CONF + +@body = ("This is a test page.\n"); +overwrite 't/htdocs/test.html', @body; +ok GET_BODY('/test.html'), "${body[0]}$head", + 'only footer'; + unlink 't/htdocs/.htaccess'; unlink 't/htdocs/test.html'; unlink 't/htdocs/subdir/.htaccess'; unlink 't/htdocs/subdir/test.html'; -unlink 't/htdocs/ '; |