View | Details | Raw Unified | Return to bug 30803
Collapse All | Expand All

(-)a/t/Output.t (-3 / +24 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::NoWarnings;
20
use Test::NoWarnings;
21
use Test::More tests => 9;
21
use Test::More tests => 10;
22
use Test::Warn;
22
use Test::Warn;
23
use Test::MockModule;
23
use Test::MockModule;
24
24
Lines 30-36 use C4::Auth qw( get_template_and_user ); Link Here
30
use t::lib::Mocks;
30
use t::lib::Mocks;
31
31
32
BEGIN {
32
BEGIN {
33
    use_ok( 'C4::Output', qw( output_html_with_http_headers output_and_exit_if_error parametrized_url ) );
33
    use_ok( 'C4::Output', qw( output_html_with_http_headers output_and_exit_if_error output_error parametrized_url ) );
34
}
34
}
35
35
36
our $output_module = Test::MockModule->new('C4::Output');
36
our $output_module = Test::MockModule->new('C4::Output');
Lines 137-139 subtest 'output_and_exit_if_error() tests' => sub { Link Here
137
    # Next call triggers test in the mocked sub
137
    # Next call triggers test in the mocked sub
138
    output_and_exit_if_error( $query, $cookie, $template, { check => 'csrf_token' } );
138
    output_and_exit_if_error( $query, $cookie, $template, { check => 'csrf_token' } );
139
};
139
};
140
- 
140
141
subtest 'output_error' => sub {
142
    plan tests => 2;
143
144
    local *STDOUT;
145
    my $stdout;
146
147
    my $query = CGI->new();
148
    my $cookie;
149
    my $output = 'foobarbaz';
150
151
    open STDOUT, '>', \$stdout;
152
    output_error( $query, "404" );
153
    like( $stdout, qr{Error 404}, '404 returned' );
154
    close STDOUT;
155
156
    open STDOUT, '>', \$stdout;
157
    output_error( $query, "403" );
158
    like( $stdout, qr{Error 403}, '403 returned' );
159
    close STDOUT;
160
161
};

Return to bug 30803