Return a list of shipper to choose from in stead of none if no shipper has be chosen yet.
This commit is contained in:
parent
e222cd97b6
commit
f748aa1b83
3 changed files with 35 additions and 3 deletions
|
|
@ -17,12 +17,14 @@ use FindBin;
|
|||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Scalar::Util qw/refaddr/;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Shop::Cart;
|
||||
use WebGUI::TestException;
|
||||
use JSON 'from_json';
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -33,7 +35,7 @@ my $i18n = WebGUI::International->new($session, "Shop");
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 30; # Increment this number for each test you create
|
||||
plan tests => 34; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -179,5 +181,31 @@ $cart->delete;
|
|||
is($cart->delete, undef, "Can destroy cart.");
|
||||
|
||||
|
||||
# Test (shipping part of) www_ajaxPrices
|
||||
{
|
||||
local *WebGUI::Shop::Ship::getOptions = sub { [ qw{ a b c } ] };
|
||||
|
||||
$cart->update( { shippingAddressId => $address->getId } );
|
||||
|
||||
my $response = from_json $cart->www_ajaxPrices;
|
||||
cmp_deeply(
|
||||
$response->{ shipping },
|
||||
[ qw{ a b c } ],
|
||||
'shipping contains available shipping option when no shipper is passed',
|
||||
);
|
||||
is( $cart->get('shippingAddressId'), $address->getId, 'calling www_ajaxPrices w/o shipperId doesn\'t change the cart shipperId' );
|
||||
|
||||
local *WebGUI::Session::Form::get = sub { return 'OtherShippert' };
|
||||
$response = from_json $cart->www_ajaxPrices;
|
||||
cmp_deeply(
|
||||
$response->{ shipping },
|
||||
[ qw{ a b c } ],
|
||||
'shipping contains available shipping option when a shipper is passed',
|
||||
);
|
||||
is( $cart->get('shippingAddressId'), 'OtherShippert', 'calling www_ajaxPrices w/ shipperId updates the cart shipperId' );
|
||||
|
||||
$cart->update( { shippingAddressId => $shipper->getId } );
|
||||
}
|
||||
|
||||
$product->purge;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue