fix a bug where getOptions returns all shipping drivers, regardless of their enabled status
This commit is contained in:
parent
3aefdb6ce5
commit
90c82daaeb
3 changed files with 30 additions and 3 deletions
|
|
@ -27,6 +27,7 @@
|
||||||
- fixed: edit operation sql error, Thingy (Yung Han Khoe)
|
- fixed: edit operation sql error, Thingy (Yung Han Khoe)
|
||||||
- fixed: Thingy: default thing property hidden (Yung Han Khoe)
|
- fixed: Thingy: default thing property hidden (Yung Han Khoe)
|
||||||
- fixed: Ad Space Description Text Keeps Repopulating
|
- fixed: Ad Space Description Text Keeps Repopulating
|
||||||
|
- fixed: Disabled Shipping methods still available
|
||||||
|
|
||||||
7.5.20
|
7.5.20
|
||||||
- fixed: DataForm acknowledgement screen shows incorrect value for Date/Time fields
|
- fixed: DataForm acknowledgement screen shows incorrect value for Date/Time fields
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ sub getOptions {
|
||||||
my $session = $cart->session;
|
my $session = $cart->session;
|
||||||
my %options = ();
|
my %options = ();
|
||||||
foreach my $shipper (@{$self->getShippers()}) {
|
foreach my $shipper (@{$self->getShippers()}) {
|
||||||
|
next unless $shipper->get('enabled');
|
||||||
$options{$shipper->getId} = {
|
$options{$shipper->getId} = {
|
||||||
label => $shipper->get("label"),
|
label => $shipper->get("label"),
|
||||||
price => $shipper->calculate($cart),
|
price => $shipper->calculate($cart),
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ use HTML::Form;
|
||||||
|
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Shop::Cart;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
|
|
@ -31,7 +32,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 20;
|
my $tests = 22;
|
||||||
plan tests => 1 + $tests;
|
plan tests => 1 + $tests;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
@ -155,10 +156,10 @@ isa_ok($driver, 'WebGUI::Shop::ShipDriver::FlatRate', 'added a new, configured F
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
my $shippers;
|
my $shippers;
|
||||||
$driver2 = $ship->addShipper('WebGUI::Shop::ShipDriver::FlatRate', { enabled=>1, label=>q{Tommy's cut-rate shipping}});
|
$driver2 = $ship->addShipper('WebGUI::Shop::ShipDriver::FlatRate', { enabled=>0, label=>q{Tommy's cut-rate shipping}});
|
||||||
|
|
||||||
$shippers = $ship->getShippers();
|
$shippers = $ship->getShippers();
|
||||||
is(scalar @{$shippers}, 3, 'getShippers: got both shippers');
|
is(scalar @{$shippers}, 3, 'getShippers: got both shippers, even though one is not enabled');
|
||||||
|
|
||||||
my @shipperNames = map { $_->get("label") } @{ $shippers };
|
my @shipperNames = map { $_->get("label") } @{ $shippers };
|
||||||
cmp_bag(
|
cmp_bag(
|
||||||
|
|
@ -173,6 +174,8 @@ cmp_bag(
|
||||||
#
|
#
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
my $defaultDriver = WebGUI::Shop::ShipDriver->new($session, 'defaultfreeshipping000');
|
||||||
|
|
||||||
eval { $shippers = $ship->getOptions(); };
|
eval { $shippers = $ship->getOptions(); };
|
||||||
$e = Exception::Class->caught();
|
$e = Exception::Class->caught();
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidParam', 'getOptions takes exception to not giving it a cart');
|
isa_ok($e, 'WebGUI::Error::InvalidParam', 'getOptions takes exception to not giving it a cart');
|
||||||
|
|
@ -184,6 +187,28 @@ cmp_deeply(
|
||||||
'getOptions takes exception to not giving it a cart',
|
'getOptions takes exception to not giving it a cart',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $cart = WebGUI::Shop::Cart->create($session);
|
||||||
|
eval { $shippers = $ship->getOptions($cart) };
|
||||||
|
$e = Exception::Class->caught();
|
||||||
|
ok(!$e, 'No exception thrown for getOptions with a cart argument');
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$shippers,
|
||||||
|
{
|
||||||
|
$defaultDriver->getId => {
|
||||||
|
label => $defaultDriver->get('label'),
|
||||||
|
price => ignore(),
|
||||||
|
},
|
||||||
|
$driver->getId => {
|
||||||
|
label => $driver->get('label'),
|
||||||
|
price => ignore(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'getOptions returns the two enabled shipping drivers'
|
||||||
|
);
|
||||||
|
|
||||||
|
$cart->delete;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue