June 27, 2005 Phalanx from the Trenches

We Can Do Better!

  %template_args = (
      path => ['templates/'],
      filename => 'simple.tmpl',
      cache => 1,
      cache_debug => 1,
  );
  $capture = IO::Capture::Stderr->new();
  isa_ok($capture, 'IO::Capture::Stderr');
  $capture->start;
  $template = HTML::Template->new( %template_args);
  $capture->stop;
  $cache_load = $capture->read;
  like($cache_load,
    qr/### HTML::Template Cache Debug ### CACHE LOAD/,
    "cache_debug CACHE LOAD message printed");
  @temp = split(/\s+/, $cache_load);
  $cache_keys[0] = $temp[-1];
  $template->param(ADJECTIVE => sub { return 'v' . '1e' . '2r' . '3y'; });
  $output =  $template->output;
  $capture->start;
  $template = HTML::Template->new( %template_args);
  $capture->stop;
  $cache_hit = $capture->read;
  like($cache_hit,
    qr/### HTML::Template Cache Debug ### CACHE HIT/,
    "cache_debug CACHE HIT message printed"); 
  @temp = split(/\s+/, $cache_hit);
  $cache_keys[1] = $temp[-1];
  ok($output =~ /v1e2r3y/, "basic test of caching");
  is($cache_keys[0], $cache_keys[1], "cache keys match as expected");



Home Last TOC Copyright © 2005 James E Keenan and Marc Prewitt Prev Next