Mercurial > pub > Impl
comparison _test/Test/Web/View.pm @ 288:3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
author | sergey |
---|---|
date | Tue, 19 Feb 2013 19:58:27 +0400 |
parents | 2d253e6e4a88 |
children | 85572f512abc |
comparison
equal
deleted
inserted
replaced
287:2d253e6e4a88 | 288:3a9cfea098dd |
---|---|
7 use parent qw(IMPL::Test::Unit); | 7 use parent qw(IMPL::Test::Unit); |
8 __PACKAGE__->PassThroughArgs; | 8 __PACKAGE__->PassThroughArgs; |
9 | 9 |
10 use File::Slurp; | 10 use File::Slurp; |
11 use Scalar::Util qw(weaken); | 11 use Scalar::Util qw(weaken); |
12 | 12 use Data::Dumper; |
13 use IMPL::lang; | 13 use IMPL::lang; |
14 use IMPL::Test qw(assert assertarray test GetCallerSourceLine); | 14 use IMPL::Test qw(assert assertarray test GetCallerSourceLine); |
15 use IMPL::Web::View::TTLoader(); | 15 use IMPL::Web::View::TTLoader(); |
16 | 16 |
17 use constant { | 17 use constant { |
110 assert($doc->template->version == 10); # static metadata | 110 assert($doc->template->version == 10); # static metadata |
111 assert($doc->templateVars('notexists') eq ''); #nonexisting template variable | 111 assert($doc->templateVars('notexists') eq ''); #nonexisting template variable |
112 assert($doc->templateVars('user') eq 'test_user'); # global data | 112 assert($doc->templateVars('user') eq 'test_user'); # global data |
113 assert($doc->templateVars('templateVar') eq ''); # defined in CTOR block, should be local | 113 assert($doc->templateVars('templateVar') eq ''); # defined in CTOR block, should be local |
114 assert($doc->templateVars('dynamic') eq 'this is a dynamic value'); | 114 assert($doc->templateVars('dynamic') eq 'this is a dynamic value'); |
115 assert($doc->context->stash->get('user') eq 'test_user' ); # runtime context should be derived from documentContext | |
116 $doc->context->stash->set('user', 'nobody'); | |
117 assert($doc->templateVars('user') eq 'test_user'); # isolated | |
118 $doc->context->stash->set('user', 'test_user'); | |
115 | 119 |
116 my $text = $doc->Render(); | 120 my $text = $doc->Render(); |
117 my $expected = read_file($this->GetResourceFile('Resources','TTView.Output','simple.txt'), binmode => ':utf8'); | 121 my $expected = read_file($this->GetResourceFile('Resources','TTView.Output','simple.txt'), binmode => ':utf8'); |
118 | 122 |
119 assert($text eq $expected, "Bad Render() output","Got: $text", "Expected: $expected"); | 123 assert($text eq $expected, "Bad Render() output","Got: $text", "Expected: $expected"); |
157 my $text = $ctl->Render(); | 161 my $text = $ctl->Render(); |
158 | 162 |
159 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); | 163 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); |
160 assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); | 164 assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); |
161 | 165 |
166 | |
167 my $doc2 = $loader->document('simple'); | |
168 | |
169 assert( $doc2->documentContext->stash->get( ['require',['My/Org/Panel'] ] ) ); | |
170 print Dumper($doc2->context->stash); | |
171 assert( $doc2->context->stash->get( ['require',['My/Org/Panel'] ] ) ); | |
162 | 172 |
163 | 173 |
164 }; | 174 }; |
165 | 175 |
166 test TestDocumentLayout => sub { | 176 test TestDocumentLayout => sub { |
195 | 205 |
196 my $doc = $loader->document('simple'); | 206 my $doc = $loader->document('simple'); |
197 | 207 |
198 assert(ref $loader->context->stash->get([ 'dojo', 0, 'require', 0]) eq 'ARRAY'); | 208 assert(ref $loader->context->stash->get([ 'dojo', 0, 'require', 0]) eq 'ARRAY'); |
199 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]); | 209 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]); |
200 assert($loader->context->stash != $doc->stash); | 210 assert($loader->context->stash != $doc->context->stash); |
211 assert($loader->context->stash != $doc->documentContext->stash); | |
212 assert($doc->context->stash != $doc->documentContext->stash); | |
201 | 213 |
202 assert(defined $doc); | 214 assert(defined $doc); |
203 | 215 |
204 # only root stash variables can be localized, to avoid modifying dojo we | 216 # only root stash variables can be localized, to avoid modifying dojo we |
205 # need to replace it completely | 217 # need to replace it completely |