diff --git a/lib/WebGUI/Shop/ShipDriver.pm b/lib/WebGUI/Shop/ShipDriver.pm index 38bd9b376..7a89c2482 100644 --- a/lib/WebGUI/Shop/ShipDriver.pm +++ b/lib/WebGUI/Shop/ShipDriver.pm @@ -4,6 +4,8 @@ use strict; use Class::InsideOut qw{ :std }; use Carp qw(croak); +use Tie::IxHash; +use WebGUI::International; =head1 NAME @@ -63,6 +65,42 @@ sub create { #------------------------------------------------------------------- +=head2 definition ( $session ) + +Constructor for new WebGUI::Shop::ShipperDriver objects. Returns a WebGUI::Shop::ShipperDriver object. +To access driver objects that have already been configured, use C. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift || []; + my $i18n = WebGUI::International->new($session, 'ShipDriver'); + tie my %properties, 'Tie::IxHash'; + %properties = ( + name => 'Shipper Driver', + fields => { + label => { + fieldType => 'text', + label => $i18n->get('label'), + hoverHelp => $i18n->get('label help'), + defaultValue => undef, + }, + enabled => { + fieldType => 'yesNo', + label => $i18n->get('enabled'), + hoverHelp => $i18n->get('enabled help'), + defaultValue => 1, + }, + }, + ); + push @{ $definition }, \%properties; + return $definition; +} + +#------------------------------------------------------------------- + =head2 label ( ) Accessor for the label property. This is the name assigned to this diff --git a/lib/WebGUI/i18n/English/ShipDriver.pm b/lib/WebGUI/i18n/English/ShipDriver.pm new file mode 100644 index 000000000..d5aa44be8 --- /dev/null +++ b/lib/WebGUI/i18n/English/ShipDriver.pm @@ -0,0 +1,31 @@ +package WebGUI::i18n::English::ShipDriver; + +use strict; + +our $I18N = { + + 'label' => { + message => q|Label|, + lastUpdated => 1203569535, + context => q|The name of a ShipDriver, supplied by the user.|, + }, + + 'label help' => { + message => q|A name for your Shipping Driver. Choose something clear, easy to understand, and less than 100 characters.|, + lastUpdated => 1203569511, + }, + + 'enabled' => { + message => q|Enabled?|, + lastUpdated => 1203569584, + context => q|Whether something can or cannot be used.|, + }, + + 'enabled help' => { + message => q|Will people using commerce on your site be able to use this Shipping Driver?|, + lastUpdated => 1203569582, + }, + +}; + +1; diff --git a/t/Shop/ShipDriver.t b/t/Shop/ShipDriver.t index 5ce9329f4..18e51e7e9 100644 --- a/t/Shop/ShipDriver.t +++ b/t/Shop/ShipDriver.t @@ -42,25 +42,67 @@ SKIP: { skip 'Unable to load module WebGUI::Shop::ShipDriver', $tests unless $loaded; +####################################################################### +# +# definition +# +####################################################################### + +my $definition = WebGUI::Shop::ShipDriver->definition($session); + +cmp_deeply( + $definition, + [ { + name => 'Shipper Driver', + fields => { + label => { + fieldType => 'text', + label => ignore(), + hoverHelp => ignore(), + defaultValue => undef, + }, + enabled => { + fieldType => 'yesNo', + label => ignore(), + hoverHelp => ignore(), + defaultValue => 1, + } + } + } ], + , + 'Definition returns an array of hashrefs', +); + +$definition = WebGUI::Shop::ShipDriver->definition($session, [ { name => 'Red' }]); + +cmp_deeply( + $definition, + [ + { + name => 'Red', + }, + { + name => 'Shipper Driver', + fields => ignore(), + } + ], + , + 'New data is appended correctly', +); + ####################################################################### # # new # ####################################################################### -my $driver = WebGUI::Shop::ShipDriver->new($session); - -isa_ok($driver, 'WebGUI::Shop::ShipDriver'); - -isa_ok($driver->session, 'WebGUI::Session', 'session method returns a session object'); - -is($session->getId, $driver->session->getId, 'session method returns OUR session object'); - -####################################################################### +#my $driver = WebGUI::Shop::ShipDriver->create($session); # -# definition +#isa_ok($driver, 'WebGUI::Shop::ShipDriver'); # -####################################################################### +#isa_ok($driver->session, 'WebGUI::Session', 'session method returns a session object'); +# +#is($session->getId, $driver->session->getId, 'session method returns OUR session object'); ####################################################################### #