root/trunk/t/50_http_response_codes.t

Revision 1054, 1.0 kB (checked in by dom, 19 months ago)

Add support in output routine for specifying HTTP status code (see #102)

Line 
1use strict;
2use Cwd;
3use OpenGuides;
4use OpenGuides::Template;
5use OpenGuides::Test;
6use Test::More tests => 3;
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);
26
27unlike( $output, qr/^Status:/,
28      "HTTP status not printed when not explicitly specified ");
29
30# Now supply a http status
31
32$output = OpenGuides::Template->output(
33    wiki     => $wiki,
34    config   => $config,
35    template => "15_test.tt",
36    http_status => '404'
37);
38like( $output, qr/^Status: 404/,
39      "Correct HTTP status printed when specified" );
Note: See TracBrowser for help on using the browser.