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