From c2fca8e178d294c188629f70be2cc63b7585410b Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 7 Dec 2009 12:23:03 -0600 Subject: [PATCH] some additional definition testing --- t/Definition.t | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/t/Definition.t b/t/Definition.t index d16ebe981..b70c85bd2 100644 --- a/t/Definition.t +++ b/t/Definition.t @@ -20,8 +20,22 @@ my $called_getProperties; package WGT::Class; use WebGUI::Definition; - property 'property1' => (); + attribute 'attribute1' => 'attribute1 value'; + property 'property1' => ( + arbitrary_key => 'arbitrary_value', + ); + # attributes create methods + ::can_ok +__PACKAGE__, 'attribute1'; + + # propeties create methods + ::can_ok +__PACKAGE__, 'property1'; + + # role applied + ::can_ok +__PACKAGE__, 'update'; + + # can retreive property metadata + ::is +__PACKAGE__->getProperty('property1')->form->{'arbitrary_key'}, 'arbitrary_value'; } { @@ -31,7 +45,24 @@ my $called_getProperties; attribute table => 'asset'; property 'property1' => (); + my $written; + sub write { + $written++; + } + ::is +__PACKAGE__->meta->get_attribute('property1')->table, 'asset'; + + ::can_ok +__PACKAGE__, 'update'; + + my $object = __PACKAGE__->new; + $object->set({property1 => 'property value'}); + + ::is $object->property1, 'property value'; + + # write called + $object->update; + ::is $written, 1; + }