Bug 9302: Use patron-title.inc
[koha.git] / t / Output.t
blob279ce0620020ea453b19729eb7b77ecf65b60e91
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More tests => 6;
7 use Test::Warn;
8 use CGI qw ( -utf8 );
10 BEGIN {
11 use_ok('C4::Output');
14 my $query = CGI->new();
15 my $cookie;
16 my $output = 'foobarbaz';
19 local *STDOUT;
20 my $stdout;
21 open STDOUT, '>', \$stdout;
22 output_html_with_http_headers $query, $cookie, $output, undef, { force_no_caching => 1 };
23 like($stdout, qr/Cache-control: no-cache, no-store, max-age=0/, 'force_no_caching sets Cache-control as desired');
24 like($stdout, qr/Expires: /, 'force_no_caching sets an Expires header');
25 $stdout = '';
26 close STDOUT;
27 open STDOUT, '>', \$stdout;
28 output_html_with_http_headers $query, $cookie, $output, undef, undef;
29 like($stdout, qr/Cache-control: no-cache[^,]/, 'not using force_no_caching sets Cache-control as desired');
30 unlike($stdout, qr/Expires: /, 'force_no_caching does not set an Expires header');
33 subtest 'parametrized_url' => sub {
34 plan tests => 2;
36 my $url = 'https://somesite.com/search?q={TITLE}&author={AUTHOR}{SUFFIX}';
37 my $subs = { TITLE => '_title_', AUTHOR => undef, ISBN => '123456789' };
38 my $res;
39 warning_is { $res = C4::Output::parametrized_url( $url, $subs ) }
40 q{}, 'No warning expected on undefined author';
41 is( $res, 'https://somesite.com/search?q=_title_&author=',
42 'Title replaced, author empty and SUFFIX removed' );