source: trunk/t/18_http_headers.t @ 1041

Last change on this file since 1041 was 1041, checked in by kake, 14 years ago

Eradicate Test::MockObject? from test 18

File size: 1.6 KB
Line 
1use strict;
2use Cwd;
3use OpenGuides;
4use OpenGuides::Template;
5use OpenGuides::Test;
6use Test::More tests => 5;
7
8my $config = OpenGuides::Test->make_basic_config;
9$config->template_path( cwd . "/t/templates" );
10
11my $guide = OpenGuides->new( config => $config );
12my $wiki = $guide->wiki;
13
14eval {
15    OpenGuides::Template->output( wiki     => $wiki,
16                                  config   => $config,
17                                  template => "15_test.tt" );
18};
19is( $@, "", "is happy doing output" );
20
21my $output = OpenGuides::Template->output(
22    wiki     => $wiki,
23    config   => $config,
24    template => "15_test.tt"
25);
26like( $output, qr/^Content-Type: text\/html/,
27      "Content-Type header included and defaults to text/html" );
28
29# Now supply a http charset
30$config->http_charset( "UTF-8" );
31
32$output = OpenGuides::Template->output(
33    wiki     => $wiki,
34    config   => $config,
35    template => "15_test.tt"
36);
37like( $output, qr/^Content-Type: text\/html; charset=UTF-8/,
38      "Content-Type header included charset" );
39
40# Suppy charset and content type
41$output = OpenGuides::Template->output(
42    wiki     => $wiki,
43    config   => $config,
44    content_type => "text/xml",
45    template => "15_test.tt"
46);
47like( $output, qr/^Content-Type: text\/xml; charset=UTF-8/,
48      "Content-Type header included charset" );
49
50# Content type but no charset
51$config->http_charset( "" );
52$output = OpenGuides::Template->output(
53    wiki     => $wiki,
54    config   => $config,
55    content_type => "text/xml",
56    template => "15_test.tt"
57);
58like( $output, qr/^Content-Type: text\/xml/,
59      "Content-Type header didn't include charset" );
Note: See TracBrowser for help on using the repository browser.