comparison _test/Test/Web/View.pm @ 184:7525ea9a071a

IMPL::Web::View::TTLoader tests
author sergey
date Thu, 29 Mar 2012 01:54:20 +0400
parents 2184fa28b49e
children ae8072f2f2a3
comparison
equal deleted inserted replaced
183:2184fa28b49e 184:7525ea9a071a
16 my ($this) = @_; 16 my ($this) = @_;
17 17
18 my $loader = TTLoader->new( 18 my $loader = TTLoader->new(
19 { 19 {
20 INCLUDE_PATH => [ 20 INCLUDE_PATH => [
21 $this->GetResourceDir('Resources') 21 $this->GetResourceDir('Resources','TTView')
22 ] 22 ]
23 }, 23 },
24 ext => '.tt' 24 ext => '.tt',
25 initializer => 'global.tt'
25 ); 26 );
26 27
27 assert( defined(my $tt = $loader->template('simple') ) ); 28 # test the loader to be able to find a desired resource
29 assert( defined($loader->template('simple') ) );
28 30
29 $tt; 31 # loader should be initialized on demand
32 assert( not $loader->isInitialized );
33
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');
30 }; 43 };
31 44
32 1; 45 1;