diff _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
line wrap: on
line diff
--- a/_test/Test/Web/View.pm	Tue Feb 19 03:05:10 2013 +0400
+++ b/_test/Test/Web/View.pm	Tue Feb 19 19:58:27 2013 +0400
@@ -9,7 +9,7 @@
 
 use File::Slurp;
 use Scalar::Util qw(weaken);
-
+use Data::Dumper;
 use IMPL::lang;
 use IMPL::Test qw(assert assertarray test GetCallerSourceLine);
 use IMPL::Web::View::TTLoader();
@@ -112,6 +112,10 @@
     assert($doc->templateVars('user') eq 'test_user'); # global data
     assert($doc->templateVars('templateVar') eq ''); # defined in CTOR block, should be local
     assert($doc->templateVars('dynamic') eq 'this is a dynamic value');
+    assert($doc->context->stash->get('user') eq 'test_user' ); # runtime context should be derived from documentContext
+    $doc->context->stash->set('user', 'nobody');
+    assert($doc->templateVars('user') eq 'test_user'); # isolated
+    $doc->context->stash->set('user', 'test_user');
     
     my $text = $doc->Render();
     my $expected = read_file($this->GetResourceFile('Resources','TTView.Output','simple.txt'), binmode => ':utf8');
@@ -160,6 +164,12 @@
     assert($text eq $expected, '$ctl->Render(): Bad output', "Got:      $text", "Expected: $expected");
     
     
+    my $doc2 = $loader->document('simple');
+    
+    assert( $doc2->documentContext->stash->get( ['require',['My/Org/Panel'] ] ) );
+    print Dumper($doc2->context->stash);
+    assert( $doc2->context->stash->get( ['require',['My/Org/Panel'] ] ) );
+    
     
 };
 
@@ -197,7 +207,9 @@
     
     assert(ref $loader->context->stash->get([ 'dojo', 0, 'require', 0]) eq 'ARRAY');
     assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
-    assert($loader->context->stash != $doc->stash);
+    assert($loader->context->stash != $doc->context->stash);
+    assert($loader->context->stash != $doc->documentContext->stash);
+    assert($doc->context->stash != $doc->documentContext->stash);
     
     assert(defined $doc);