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

*TTView refactoring
author cin
date Tue, 19 Feb 2013 03:05:10 +0400
parents d357b5d85d25
children 3a9cfea098dd
line wrap: on
line diff
--- a/_test/Test/Web/View.pm	Mon Feb 18 14:46:06 2013 +0400
+++ b/_test/Test/Web/View.pm	Tue Feb 19 03:05:10 2013 +0400
@@ -99,6 +99,7 @@
     my $doc = $loader->document('simple');
     
     assert(defined $doc);
+    
     $doc->title('test document');
     
     assert($doc->name eq 'document');
@@ -179,11 +180,12 @@
     
     assert($doc->layout eq 'default');
     
-    assert($doc->templateVars('dojo.require')->[0]);
-    
     my $text = $doc->Render();
     my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' );
-    #assert($text eq $expected, '$doc->Render(): Bad output', "Got:      $text", "Expected: $expected"); 
+    my ($text_raw,$expected_raw) = ($text, $expected);
+    $text_raw =~ s/\s+//g;
+    $expected_raw =~ s/\s+//g;
+    assert($text_raw eq $expected_raw, '$doc->Render(): Bad output', "Got:      $text", "Expected: $expected"); 
 };
 
 test TestDocumentsIsolation => sub {
@@ -214,9 +216,19 @@
     
     my $text = $doc->Render();
     
-    my $doc2 = $loader->document('simple');
+    my $doc2 = $loader->document('complex');
     
     assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
+    
+    # This document has a layout ehich will replace 'dojo' global variable.
+    # The layout contains INIT block which runs first in the context of the
+    # document, then RenderContent is called and then the layout is applied
+    $doc2->Render();
+    
+    assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
+    
+    # TODO: to be able to rendered multiple times, Render shouldn't affect the context of the document
+    #assertarray($doc2->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
 };
 
 test TestMemoryLeaks => sub {