Bug 13969: Testing C4::Review
[koha.git] / t / Output.t
old mode 100644 (file)
new mode 100755 (executable)
index 0716004..4474d18
@@ -1,5 +1,30 @@
-BEGIN { $| = 1; print "1..1\n"; }
-END {print "not ok 1\n" unless $loaded;}
-use C4::Accounts;
-$loaded = 1;
-print "ok 1\n";
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use CGI qw ( -utf8 );
+
+BEGIN {
+    use_ok('C4::Output');
+}
+
+my $query = CGI->new();
+my $cookie;
+my $output = 'foobarbaz';
+
+{
+    local *STDOUT;
+    my $stdout;
+    open STDOUT, '>', \$stdout;
+    output_html_with_http_headers $query, $cookie, $output, undef, { force_no_caching => 1 };
+    like($stdout, qr/Cache-control: no-cache, no-store, max-age=0/, 'force_no_caching sets Cache-control as desired');
+    like($stdout, qr/Expires: /, 'force_no_caching sets an Expires header');
+    $stdout = '';
+    close STDOUT;
+    open STDOUT, '>', \$stdout;
+    output_html_with_http_headers $query, $cookie, $output, undef, undef;
+    like($stdout, qr/Cache-control: no-cache[^,]/, 'not using force_no_caching sets Cache-control as desired');
+    unlike($stdout, qr/Expires: /, 'force_no_caching does not set an Expires header');
+}