comparison _test/Test/Web/View.pm @ 287:2d253e6e4a88

*TTView refactoring
author cin
date Tue, 19 Feb 2013 03:05:10 +0400
parents d357b5d85d25
children 3a9cfea098dd
comparison
equal deleted inserted replaced
286:d357b5d85d25 287:2d253e6e4a88
97 my $loader = $this->CreateLoader(); 97 my $loader = $this->CreateLoader();
98 98
99 my $doc = $loader->document('simple'); 99 my $doc = $loader->document('simple');
100 100
101 assert(defined $doc); 101 assert(defined $doc);
102
102 $doc->title('test document'); 103 $doc->title('test document');
103 104
104 assert($doc->name eq 'document'); 105 assert($doc->name eq 'document');
105 assert($doc->title eq 'test document'); 106 assert($doc->title eq 'test document');
106 107
177 } 178 }
178 ); 179 );
179 180
180 assert($doc->layout eq 'default'); 181 assert($doc->layout eq 'default');
181 182
182 assert($doc->templateVars('dojo.require')->[0]);
183
184 my $text = $doc->Render(); 183 my $text = $doc->Render();
185 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' ); 184 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' );
186 #assert($text eq $expected, '$doc->Render(): Bad output', "Got: $text", "Expected: $expected"); 185 my ($text_raw,$expected_raw) = ($text, $expected);
186 $text_raw =~ s/\s+//g;
187 $expected_raw =~ s/\s+//g;
188 assert($text_raw eq $expected_raw, '$doc->Render(): Bad output', "Got: $text", "Expected: $expected");
187 }; 189 };
188 190
189 test TestDocumentsIsolation => sub { 191 test TestDocumentsIsolation => sub {
190 my $this = shift; 192 my $this = shift;
191 193
212 assertarray($doc->context->stash->get([ 'dojo', 0, 'require', 0]),['dijit/form/TextBox']); 214 assertarray($doc->context->stash->get([ 'dojo', 0, 'require', 0]),['dijit/form/TextBox']);
213 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]); 215 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
214 216
215 my $text = $doc->Render(); 217 my $text = $doc->Render();
216 218
217 my $doc2 = $loader->document('simple'); 219 my $doc2 = $loader->document('complex');
218 220
219 assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]); 221 assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
222
223 # This document has a layout ehich will replace 'dojo' global variable.
224 # The layout contains INIT block which runs first in the context of the
225 # document, then RenderContent is called and then the layout is applied
226 $doc2->Render();
227
228 assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
229
230 # TODO: to be able to rendered multiple times, Render shouldn't affect the context of the document
231 #assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
220 }; 232 };
221 233
222 test TestMemoryLeaks => sub { 234 test TestMemoryLeaks => sub {
223 my ($this) = @_; 235 my ($this) = @_;
224 236