Bug 14778: Example - Replace DBI::Mock with Test::DBIx::Class - Sitemapper.t
[koha.git] / t / Output.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 5;
7 use CGI qw ( -utf8 );
8
9 BEGIN {
10     use_ok('C4::Output');
11 }
12
13 my $query = CGI->new();
14 my $cookie;
15 my $output = 'foobarbaz';
16
17 {
18     local *STDOUT;
19     my $stdout;
20     open STDOUT, '>', \$stdout;
21     output_html_with_http_headers $query, $cookie, $output, undef, { force_no_caching => 1 };
22     like($stdout, qr/Cache-control: no-cache, no-store, max-age=0/, 'force_no_caching sets Cache-control as desired');
23     like($stdout, qr/Expires: /, 'force_no_caching sets an Expires header');
24     $stdout = '';
25     close STDOUT;
26     open STDOUT, '>', \$stdout;
27     output_html_with_http_headers $query, $cookie, $output, undef, undef;
28     like($stdout, qr/Cache-control: no-cache[^,]/, 'not using force_no_caching sets Cache-control as desired');
29     unlike($stdout, qr/Expires: /, 'force_no_caching does not set an Expires header');
30 }