Fix get_property_list. Add tests.
This commit is contained in:
parent
b8781044f3
commit
19b784cd95
2 changed files with 18 additions and 4 deletions
|
|
@ -48,7 +48,7 @@ These methods are available from this class:
|
||||||
|
|
||||||
=head2 get_property_list ( )
|
=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
|
=cut
|
||||||
|
|
||||||
|
|
@ -57,8 +57,8 @@ sub get_property_list {
|
||||||
my @properties =
|
my @properties =
|
||||||
map { $_->name }
|
map { $_->name }
|
||||||
sort { $a->insertion_order <=> $b->insertion_order }
|
sort { $a->insertion_order <=> $b->insertion_order }
|
||||||
grep { $_->meta->isa('WebGUI::Definition::Meta::Property') }
|
grep { $_->isa('WebGUI::Definition::Meta::Property') }
|
||||||
$self->meta->get_all_attributes;
|
$self->get_all_attributes;
|
||||||
return \@properties;
|
return \@properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
no warnings qw(uninitialized);
|
no warnings qw(uninitialized);
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
use Test::More 'no_plan'; #tests => 1;
|
use Test::More 'no_plan'; #tests => 1;
|
||||||
|
use Test::Deep;
|
||||||
#use Test::Exception;
|
#use Test::Exception;
|
||||||
|
|
||||||
my $called_getProperties;
|
my $called_getProperties;
|
||||||
|
|
@ -33,9 +35,12 @@ my $called_getProperties;
|
||||||
|
|
||||||
# role applied
|
# role applied
|
||||||
::can_ok +__PACKAGE__, 'update';
|
::can_ok +__PACKAGE__, 'update';
|
||||||
|
::can_ok +__PACKAGE__, 'get';
|
||||||
|
::can_ok +__PACKAGE__, 'set';
|
||||||
|
|
||||||
# can retreive property metadata
|
# can retreive property metadata
|
||||||
::is +__PACKAGE__->getProperty('property1')->form->{'arbitrary_key'}, 'arbitrary_value', 'arbitrary keys mapped into the form attribute';
|
::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;
|
use WebGUI::Definition::Asset;
|
||||||
|
|
||||||
attribute tableName => 'asset';
|
attribute tableName => 'asset';
|
||||||
|
property 'property2' => ();
|
||||||
property 'property1' => ();
|
property 'property1' => ();
|
||||||
|
|
||||||
my $written;
|
my $written;
|
||||||
|
|
@ -56,13 +62,21 @@ my $called_getProperties;
|
||||||
|
|
||||||
my $object = __PACKAGE__->new;
|
my $object = __PACKAGE__->new;
|
||||||
$object->set({property1 => 'property value'});
|
$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
|
# write called
|
||||||
$object->update;
|
$object->update;
|
||||||
::is $written, 1, 'update calls write';
|
::is $written, 1, 'update calls write';
|
||||||
|
|
||||||
|
::cmp_deeply(
|
||||||
|
$object->meta->get_property_list,
|
||||||
|
[qw/property2 property1/],
|
||||||
|
'get_property_list returns properties in insertion order'
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue