comparison _test/Test/Web/View.pm @ 370:cbf4febf0930

ObjectMeta, Tests, migrating to the new metadata model.
author sergey
date Tue, 10 Dec 2013 03:02:01 +0400
parents 7c784144d2f1
children 5aff94ba842f
comparison
equal deleted inserted replaced
369:7c784144d2f1 370:cbf4febf0930
13 use IMPL::declare { 13 use IMPL::declare {
14 require => { 14 require => {
15 FormMeta => 'IMPL::Web::View::Metadata::FormMeta', 15 FormMeta => 'IMPL::Web::View::Metadata::FormMeta',
16 ObjectMeta => 'IMPL::Web::View::Metadata::ObjectMeta', 16 ObjectMeta => 'IMPL::Web::View::Metadata::ObjectMeta',
17 Schema => 'IMPL::DOM::Schema', 17 Schema => 'IMPL::DOM::Schema',
18 Builder => 'IMPL::DOM::Navigator::Builder',
19 Document => 'IMPL::DOM::Document', 18 Document => 'IMPL::DOM::Document',
20 XMLReader => 'IMPL::DOM::XMLReader', 19 XMLReader => 'IMPL::DOM::XMLReader',
21 MProfiler => '-IMPL::Profiler::Memory' 20 MProfiler => '-IMPL::Profiler::Memory',
21 PersonModel => '-Test::Web::View::Model::Person'
22 }, 22 },
23 base => [ 23 base => [
24 'IMPL::Test::Unit' => '@_' 24 'IMPL::Test::Unit' => '@_'
25 ] 25 ]
26 }; 26 };
106 }); 106 });
107 }; 107 };
108 test TestObjectMetadata => sub { 108 test TestObjectMetadata => sub {
109 my ($this) = @_; 109 my ($this) = @_;
110 110
111 my $meta = ObjectMeta->new(
112 PersonModel->new(
113 name => 'alex',
114 age => 29,
115 address => [
116 { city => 'city 17', street => 'doomed' },
117 { city => 'gropher', street => 'caveroad' }
118 ]
119 )
120 );
111 121
122 assert($meta->modelType eq PersonModel);
123
124 my $prop = $meta->GetProperty('name');
125 assert($prop);
126 assert($prop->model eq 'alex');
127
128 $prop = $meta->GetProperty('address');
129
130 assert($prop->isMultiple);
131 assert($prop->name eq 'address');
132 assert($prop->modelType eq 'ARRAY');
133
134 my $items = $prop->GetItems();
135 assert(@$items == 2);
136 assertarray(
137 [map $_->GetProperty('city')->model, @$items],
138 ['city 17', 'gropher']
139 );
112 }; 140 };
113 141
142 package Test::Web::View::Model::Person;
143 use IMPL::Const qw(:prop);
144 use IMPL::declare {
145 base => [
146 'IMPL::Object' => undef,
147 'IMPL::Object::Autofill' => '@_'
148 ],
149 props => [
150 name => PROP_RW,
151 age => PROP_RW,
152 address => PROP_RW | PROP_LIST
153 ]
154 };
114 155
115 1; 156 1;