File: 108_http_headers.t

package info (click to toggle)
openguides 0.84-1.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,628 kB
  • sloc: perl: 4,812; sh: 56; javascript: 56; makefile: 19
file content (59 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download | duplicates (9)
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
53
54
55
56
57
58
59
use strict;
use Cwd;
use OpenGuides;
use OpenGuides::Template;
use OpenGuides::Test;
use Test::More tests => 5;

my $config = OpenGuides::Test->make_basic_config;
$config->template_path( cwd . "/t/templates" );

my $guide = OpenGuides->new( config => $config );
my $wiki = $guide->wiki;

eval {
    OpenGuides::Template->output( wiki     => $wiki,
                                  config   => $config,
                                  template => "15_test.tt" );
};
is( $@, "", "is happy doing output" );

my $output = OpenGuides::Template->output(
    wiki     => $wiki,
    config   => $config,
    template => "15_test.tt"
);
like( $output, qr/^Content-Type: text\/html/,
      "Content-Type header included and defaults to text/html" );

# Now supply a http charset
$config->http_charset( "UTF-8" );

$output = OpenGuides::Template->output(
    wiki     => $wiki,
    config   => $config,
    template => "15_test.tt"
);
like( $output, qr/^Content-Type: text\/html; charset=UTF-8/,
      "Content-Type header included charset" );

# Suppy charset and content type
$output = OpenGuides::Template->output(
    wiki     => $wiki,
    config   => $config,
    content_type => "text/xml",
    template => "15_test.tt"
);
like( $output, qr/^Content-Type: text\/xml; charset=UTF-8/,
      "Content-Type header included charset" );

# Content type but no charset
$config->http_charset( "" );
$output = OpenGuides::Template->output(
    wiki     => $wiki,
    config   => $config,
    content_type => "text/xml",
    template => "15_test.tt"
);
like( $output, qr/^Content-Type: text\/xml/,
      "Content-Type header didn't include charset" );