NAME

_Auxiliary - Miscellaneous subroutines used in HTML::Template test suite

DESCRIPTION

GENERAL

The subroutines contained herein are used at various places in the HTML::Template test suite. Each is exported on demand only; there are no export tags permitting export of groups of these subroutines. In certain cases they exist only to eliminate duplicated code. In other cases they serve as wrappers around small functionalities drawn from other modules such as HTML::Template itself or IO::Capture::Stderr.

_setup_array_fh

($fh, $template_string, $template_array_ref) = 
    _setup_array_fh('/path/to/some/file');

Reads the file specified by the argument and returns a list consisting of a filehandle, a string and a reference to an array, each of which are used to create dummy templates for testing in the cases where HTML::Template gets its source material from a filehandle, string or array, respectively. Currently used in t/07-constructor-1.t.

capture_template

$capture = IO::Capture::Stderr->new();

$template_args_ref = {
    path => ['templates/'],
    filename => 'simple.tmpl',
    cache => 1,
    cache_debug => 1,
};

($template, $cache_load_or_hit) 
    = capture_template($capture, $template_args_ref);

Used in conjunction with IO::Capture::Stderr to prepare for test which analyze data emitted by HTML::Template to standard error when certain debugging options are activated. Takes a list of two arguments: an IO::Capture::Stderr object and a reference to a hash holding the options to be passed to HTML::Template::new(). Returns a list of two arguments: an HTML::Template object and the (first) string printed to STDERR. The template can then be further used like any such HTML::Template, while the string may be tested in comparison with the expected debugging message. Currently used in t/14-cache-debug.t.

get_cache_key

($template, $cache_load_or hit) = 
    capture_template($capture, $template_args_ref);
$cache_keys[0] = get_cache_key($cache_load_or_hit); 

Used to extract information from debugging messages for further testing. Takes a single argument of a string which is the STDERR message captured by IO::Capture::Stderr inside capture_template() above. Returns the last Perl 'word' in that string. Why the last word? Because that's where the cache key or cache file name currently appears in the error messages for those features in HTML::Template. Currently used in t/14-cache-debug.t.