aboutsummaryrefslogtreecommitdiff
path: root/t/basic.t
blob: 4833d6820c4a4d9f9dbcc5d7cc7eb25c51b01445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest qw/GET_BODY/;

plan tests => 5;

# Prepare environment

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> };
close $h; close $f;

my @test;
sub prepare {
	open my $t, '>', 't/htdocs/test.html' or die;
	print $t join('', @_);
	close $t;
}

# 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",
   '<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",
   '<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]}",
   '<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",
   '<!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",
   '<!doctype> with leading newline';

unlink 't/htdocs/test.html';