Mercurial > pub > Impl
diff _test/Test/Web/View.pm @ 186:6c0fee769b0c
IMPL::Web::View::TTControl tests, fixes
author | cin |
---|---|
date | Fri, 30 Mar 2012 16:40:34 +0400 |
parents | ae8072f2f2a3 |
children | 029c9610528c |
line wrap: on
line diff
--- a/_test/Test/Web/View.pm Thu Mar 29 18:22:15 2012 +0400 +++ b/_test/Test/Web/View.pm Fri Mar 30 16:40:34 2012 +0400 @@ -82,4 +82,52 @@ }; +test TTControlTests => sub { + my ($this) = @_; + + my $loader = TTLoader->new( + { + INCLUDE_PATH => [ + $this->templatesDir + ], + INTERPOLATE => 1, + POST_CHOMP => 1, + ENCODING => 'utf8' + }, + ext => '.tt', + initializer => 'global.tt' + ); + + my $doc = $loader->document('simple'); + + assert(defined $doc); + + my $factory = $doc->require('My/Org/Panel'); + + assert(defined $factory); + + assert($factory == $doc->require('My/Org/Panel'), "Control should be loaded only once"); + + my $ctl = $factory->new('information', { visualClass => 'simple' } ); + + assert(defined $ctl); + + + assert($ctl->nodeName eq 'information', "Created control should have a name", "Got: ".$ctl->nodeName, "Expected: information"); + + assert($ctl->nodeProperty('visualClass') eq 'simple'); + + assert($ctl->controlObject == $ctl); + + assert($factory->instances == 1); + + assert($doc->context->stash->get('My.Org.Panel') == $factory); + + my $text = $ctl->Render(); + my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8'); + + assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected"); + +}; + 1; \ No newline at end of file