Mercurial > pub > Impl
diff _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 |
line wrap: on
line diff
--- a/_test/Test/Web/View.pm Mon Dec 09 17:35:34 2013 +0400 +++ b/_test/Test/Web/View.pm Tue Dec 10 03:02:01 2013 +0400 @@ -15,10 +15,10 @@ FormMeta => 'IMPL::Web::View::Metadata::FormMeta', ObjectMeta => 'IMPL::Web::View::Metadata::ObjectMeta', Schema => 'IMPL::DOM::Schema', - Builder => 'IMPL::DOM::Navigator::Builder', Document => 'IMPL::DOM::Document', XMLReader => 'IMPL::DOM::XMLReader', - MProfiler => '-IMPL::Profiler::Memory' + MProfiler => '-IMPL::Profiler::Memory', + PersonModel => '-Test::Web::View::Model::Person' }, base => [ 'IMPL::Test::Unit' => '@_' @@ -108,8 +108,49 @@ test TestObjectMetadata => sub { my ($this) = @_; + my $meta = ObjectMeta->new( + PersonModel->new( + name => 'alex', + age => 29, + address => [ + { city => 'city 17', street => 'doomed' }, + { city => 'gropher', street => 'caveroad' } + ] + ) + ); + assert($meta->modelType eq PersonModel); + + my $prop = $meta->GetProperty('name'); + assert($prop); + assert($prop->model eq 'alex'); + + $prop = $meta->GetProperty('address'); + + assert($prop->isMultiple); + assert($prop->name eq 'address'); + assert($prop->modelType eq 'ARRAY'); + + my $items = $prop->GetItems(); + assert(@$items == 2); + assertarray( + [map $_->GetProperty('city')->model, @$items], + ['city 17', 'gropher'] + ); }; +package Test::Web::View::Model::Person; +use IMPL::Const qw(:prop); +use IMPL::declare { + base => [ + 'IMPL::Object' => undef, + 'IMPL::Object::Autofill' => '@_' + ], + props => [ + name => PROP_RW, + age => PROP_RW, + address => PROP_RW | PROP_LIST + ] +}; 1; \ No newline at end of file