183
|
1 package Test::Web::View;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use parent qw(IMPL::Test::Unit);
|
|
6 __PACKAGE__->PassThroughArgs;
|
|
7
|
|
8 use IMPL::Test qw(assert test);
|
|
9 use IMPL::Web::View::TTLoader();
|
|
10
|
|
11 use constant {
|
|
12 TTLoader => typeof IMPL::Web::View::TTLoader
|
|
13 };
|
|
14
|
|
15 test TemplateLoaderTests => sub {
|
|
16 my ($this) = @_;
|
|
17
|
|
18 my $loader = TTLoader->new(
|
|
19 {
|
|
20 INCLUDE_PATH => [
|
184
|
21 $this->GetResourceDir('Resources','TTView')
|
183
|
22 ]
|
|
23 },
|
184
|
24 ext => '.tt',
|
|
25 initializer => 'global.tt'
|
183
|
26 );
|
|
27
|
184
|
28 # test the loader to be able to find a desired resource
|
|
29 assert( defined($loader->template('simple') ) );
|
|
30
|
|
31 # loader should be initialized on demand
|
|
32 assert( not $loader->isInitialized );
|
183
|
33
|
184
|
34 # loader should be able to load a document
|
|
35 my $doc = $loader->document('simple');
|
|
36 assert(defined $doc);
|
|
37
|
|
38 assert( $loader->isInitialized );
|
|
39 assert( $loader->context->stash->get('user') eq 'test_user');
|
|
40
|
|
41 # document should inherit loader's context
|
|
42 assert( $doc->context->stash->get('user') eq 'test_user');
|
183
|
43 };
|
|
44
|
|
45 1; |