comparison _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
comparison
equal deleted inserted replaced
185:ae8072f2f2a3 186:6c0fee769b0c
80 80
81 assert($text eq $expected, "Bad Render() output","Got: $text", "Expected: $expected"); 81 assert($text eq $expected, "Bad Render() output","Got: $text", "Expected: $expected");
82 82
83 }; 83 };
84 84
85 test TTControlTests => sub {
86 my ($this) = @_;
87
88 my $loader = TTLoader->new(
89 {
90 INCLUDE_PATH => [
91 $this->templatesDir
92 ],
93 INTERPOLATE => 1,
94 POST_CHOMP => 1,
95 ENCODING => 'utf8'
96 },
97 ext => '.tt',
98 initializer => 'global.tt'
99 );
100
101 my $doc = $loader->document('simple');
102
103 assert(defined $doc);
104
105 my $factory = $doc->require('My/Org/Panel');
106
107 assert(defined $factory);
108
109 assert($factory == $doc->require('My/Org/Panel'), "Control should be loaded only once");
110
111 my $ctl = $factory->new('information', { visualClass => 'simple' } );
112
113 assert(defined $ctl);
114
115
116 assert($ctl->nodeName eq 'information', "Created control should have a name", "Got: ".$ctl->nodeName, "Expected: information");
117
118 assert($ctl->nodeProperty('visualClass') eq 'simple');
119
120 assert($ctl->controlObject == $ctl);
121
122 assert($factory->instances == 1);
123
124 assert($doc->context->stash->get('My.Org.Panel') == $factory);
125
126 my $text = $ctl->Render();
127 my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8');
128
129 assert($text eq $expected, '$ctl->Render(): Bad output', "Got: $text", "Expected: $expected");
130
131 };
132
85 1; 133 1;