From 3b31069b1c05fd3c471b09e3c25c224b1e7ee626 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 17 Dec 2009 13:00:54 -0800 Subject: [PATCH] Make fieldType a required parameter of a Definition Asset property. --- lib/WebGUI/Definition/Meta/Property/Asset.pm | 6 ++- t/Definition.t | 47 +++++++++++++++----- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/lib/WebGUI/Definition/Meta/Property/Asset.pm b/lib/WebGUI/Definition/Meta/Property/Asset.pm index b3a6838df..2561f88d0 100644 --- a/lib/WebGUI/Definition/Meta/Property/Asset.pm +++ b/lib/WebGUI/Definition/Meta/Property/Asset.pm @@ -39,11 +39,13 @@ The following methods are added. extends 'WebGUI::Definition::Meta::Property'; has 'tableName' => ( - is => 'ro', + is => 'ro', + required => 1, ); has 'fieldType' => ( - is => 'ro', + is => 'ro', + required => 1, ); has 'noFormPost' => ( diff --git a/t/Definition.t b/t/Definition.t index cfe20470d..0c03413fa 100644 --- a/t/Definition.t +++ b/t/Definition.t @@ -14,7 +14,7 @@ no warnings qw(uninitialized); use Test::More 'no_plan'; #tests => 1; use Test::Deep; -#use Test::Exception; +use Test::Exception; my $called_getProperties; { @@ -57,13 +57,26 @@ my $called_getProperties; } +{ + package WGT::Class::Atset; + use WebGUI::Definition::Asset; + + attribute tableName => 'asset'; + ::dies_ok { property 'property1' => (); } 'must have a fieldType'; + +} + { package WGT::Class::Asset; use WebGUI::Definition::Asset; attribute tableName => 'asset'; - property 'property2' => (); - property 'property1' => (); + property 'property2' => ( + fieldType => 'text', + ); + property 'property1' => ( + fieldType => 'text', + ); my $written; sub write { @@ -129,17 +142,27 @@ my $called_getProperties; use WebGUI::Definition::Asset; attribute tableName => 'asset'; - property 'property1' => (); - property 'property2' => (); - property 'property3' => (); + property 'property1' => ( + fieldType => 'text' + ); + property 'property2' => ( + fieldType => 'text' + ); + property 'property3' => ( + fieldType => 'text' + ); package WGT::Class::Asset::Snippet; use WebGUI::Definition::Asset; extends 'WGT::Class::AlsoAsset'; attribute tableName => 'snippet'; - property 'property10' => (); - property 'property11' => (); + property 'property10' => ( + fieldType => 'text' + ); + property 'property11' => ( + fieldType => 'text' + ); package main; @@ -175,8 +198,12 @@ my $called_getProperties; extends 'WGT::Class::AlsoAsset'; attribute tableName => 'snippet'; - property 'property10' => (); - property 'property1' => (); + property 'property10' => ( + fieldType => 'text', + ); + property 'property1' => ( + fieldType => 'text', + ); package main;