File: 07-double-file-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 (64 lines) | stat: -rw-r--r-- 1,610 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
56
57
58
59
60
61
62
63
64
use strict;
use warnings;
use Test::More (tests => 3);
use Data::Dumper;
use File::Temp;

use_ok('HTML::Template');

my $tmp_dir = File::Temp->newdir();

my ($template, $output);

# test file cache - non automated, requires turning on debug watching STDERR!
$template = HTML::Template->new(
    path              => ['templates/'],
    filename          => 'simple.tmpl',
    double_file_cache => 1,
    file_cache_dir    => $tmp_dir,
);
$template->param(ADJECTIVE => sub { "3y"; });
$output = $template->output;

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

ok($output =~ /3y/, "double_file_cache option provides expected output");

$template = HTML::Template->new(
    path     => ['templates/'],
    filename => 'simple.tmpl',
    cache    => 1,
);
$template->param(ADJECTIVE => sub { return 't' . 'i' . '1m' . '2e' . '3l' . '4y'; });
$output = $template->output;

$template = HTML::Template->new(
    path              => ['templates/'],
    filename          => 'simple.tmpl',
    double_file_cache => 1,
    file_cache_dir    => $tmp_dir,
);
ok($output =~ /ti1m2e3l4y/, "double_file_cache option provides expected output");

=head1 NAME

t/07-double-file-cache.t

=head1 OBJECTIVE

Test the previous untested C<double_file_cache> option to 
C<HTML::Template::new()>.

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

=cut