File: 05-blind-cache.t

package info (click to toggle)
libhtml-template-perl 2.97-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 740 kB
  • sloc: perl: 2,572; makefile: 8
file content (55 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;
use File::Copy;
use File::Temp;
use File::Spec::Functions qw(curdir catfile);
use Test::More tests => 4;

use_ok('HTML::Template');

# use a temp file for the one that changes
my $tmp = File::Temp->new(UNLINK => 1, SUFFIX => '.tmpl');

ok(copy(catfile(curdir, 'templates', 'simple.tmpl'), $tmp), "copied simple.tmpl to temp file");

my ($output, $template);
# test cache - non automated, requires turning on debug watching STDERR!
$template = HTML::Template->new(
    filename    => $tmp,
    blind_cache => 1,
    debug       => 0,
    cache_debug => 0,
);
$template->param(ADJECTIVE => sub { return 'v' . '1e' . '2r' . '3y'; });
$output = $template->output;

sleep 1;

# overwrite our temp file with a different template
ok(copy(catfile(curdir, 'templates', 'simplemod.tmpl'), $tmp), "poured new content into template to test blind_cache");

$template = HTML::Template->new(
    filename    => $tmp,
    blind_cache => 1,
    debug       => 0,
    cache_debug => 0,
);
ok($output =~ /v1e2r3y/, "output unchanged as expected");

=head1 NAME

t/05-blind-cache.t

=head1 OBJECTIVE

Test the previously untested C<blind_cache> option to constructor 
C<HTML::Template::new()>.

    $template = HTML::Template->new(
        path => ['templates/'],
        filename => 'simple.tmpl',
        blind_cache => 1,
    );

=cut