From 19b784cd952572c6f63d705df84fd9f56ca43bff Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 10 Dec 2009 18:54:18 -0800 Subject: [PATCH] Fix get_property_list. Add tests. --- lib/WebGUI/Definition/Meta/Class.pm | 6 +++--- t/Definition.t | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Definition/Meta/Class.pm b/lib/WebGUI/Definition/Meta/Class.pm index f0aeaf078..8ea4460ac 100644 --- a/lib/WebGUI/Definition/Meta/Class.pm +++ b/lib/WebGUI/Definition/Meta/Class.pm @@ -48,7 +48,7 @@ These methods are available from this class: =head2 get_property_list ( ) -Returns the name of all properties, in the order they were created in the Definition. +Returns an array reference of the names of all properties, in the order they were created in the Definition. =cut @@ -57,8 +57,8 @@ sub get_property_list { my @properties = map { $_->name } sort { $a->insertion_order <=> $b->insertion_order } - grep { $_->meta->isa('WebGUI::Definition::Meta::Property') } - $self->meta->get_all_attributes; + grep { $_->isa('WebGUI::Definition::Meta::Property') } + $self->get_all_attributes; return \@properties; } diff --git a/t/Definition.t b/t/Definition.t index 8c5817a4d..c6df91b60 100644 --- a/t/Definition.t +++ b/t/Definition.t @@ -11,8 +11,10 @@ use strict; use warnings; no warnings qw(uninitialized); +use Data::Dumper; use Test::More 'no_plan'; #tests => 1; +use Test::Deep; #use Test::Exception; my $called_getProperties; @@ -33,9 +35,12 @@ my $called_getProperties; # role applied ::can_ok +__PACKAGE__, 'update'; + ::can_ok +__PACKAGE__, 'get'; + ::can_ok +__PACKAGE__, 'set'; # can retreive property metadata ::is +__PACKAGE__->getProperty('property1')->form->{'arbitrary_key'}, 'arbitrary_value', 'arbitrary keys mapped into the form attribute'; + } { @@ -43,6 +48,7 @@ my $called_getProperties; use WebGUI::Definition::Asset; attribute tableName => 'asset'; + property 'property2' => (); property 'property1' => (); my $written; @@ -56,13 +62,21 @@ my $called_getProperties; my $object = __PACKAGE__->new; $object->set({property1 => 'property value'}); + ::is $object->property1, 'property value', 'checking set, hashref form'; - ::is $object->property1, 'property value', 'checking set'; + $object->set('property1', 'newer property value'); + ::is $object->property1, 'newer property value', '... hash form'; # write called $object->update; ::is $written, 1, 'update calls write'; + ::cmp_deeply( + $object->meta->get_property_list, + [qw/property2 property1/], + 'get_property_list returns properties in insertion order' + ); + }