File: dot_notation.t

package info (click to toggle)
libhtml-template-pluggable-perl 0.17%2B~cs0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 276 kB
  • sloc: perl: 401; makefile: 17
file content (39 lines) | stat: -rw-r--r-- 1,232 bytes parent folder | download | duplicates (5)
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
use strict;
use Test::More tests => 8;
use Test::MockObject;
use strict;

use_ok('HTML::Template::Pluggable');
use_ok('HTML::Template::Plugin::Dot');
use_ok('Test::MockObject');

my $mock = Test::MockObject->new();
$mock->mock( 'some', sub { $mock } );
$mock->mock( 'method', sub { "chained methods work" } );

my ($output, $template, $result);

# test a simple template
my $t = HTML::Template::Pluggable->new( scalarref => 
    \ qq{ <tmpl_var wants.to_be.literal>
          <tmpl_var desires.to_be.hashref>
          <tmpl_var should_be.some.method> <tmpl_var should_be.some.method>
		  <tmpl_if desires.to_be>tmpl_ifs work</tmpl_if>
          \n},
                                   debug => 0
                                  );

$t->param('wants.to_be.literal', "Literals tokens with dots work");
$t->param('desires', { to_be => { hashref => "nested hashrefs work" } });
$t->param('should_be',$mock);

$output =  $t->output;

like($output ,qr/Literals tokens with dots work/);
like($output ,qr/nested hashrefs work/);
like($output ,qr/chained methods work/);
like($output ,qr/chained methods work.*chained methods work/, "using a dot var more than once works" );
like($output ,qr/tmpl_ifs work/);

# vi: filetype=perl
__END__