definition method for ShipDriver, with tests
This commit is contained in:
parent
40b432da40
commit
a89c507ed6
3 changed files with 122 additions and 11 deletions
|
|
@ -4,6 +4,8 @@ use strict;
|
||||||
|
|
||||||
use Class::InsideOut qw{ :std };
|
use Class::InsideOut qw{ :std };
|
||||||
use Carp qw(croak);
|
use Carp qw(croak);
|
||||||
|
use Tie::IxHash;
|
||||||
|
use WebGUI::International;
|
||||||
|
|
||||||
=head1 NAME
|
=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<new>.
|
||||||
|
|
||||||
|
=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 ( )
|
=head2 label ( )
|
||||||
|
|
||||||
Accessor for the label property. This is the name assigned to this
|
Accessor for the label property. This is the name assigned to this
|
||||||
|
|
|
||||||
31
lib/WebGUI/i18n/English/ShipDriver.pm
Normal file
31
lib/WebGUI/i18n/English/ShipDriver.pm
Normal file
|
|
@ -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;
|
||||||
|
|
@ -42,25 +42,67 @@ SKIP: {
|
||||||
|
|
||||||
skip 'Unable to load module WebGUI::Shop::ShipDriver', $tests unless $loaded;
|
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
|
# new
|
||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
my $driver = WebGUI::Shop::ShipDriver->new($session);
|
#my $driver = WebGUI::Shop::ShipDriver->create($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');
|
|
||||||
|
|
||||||
#######################################################################
|
|
||||||
#
|
#
|
||||||
# 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');
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue