merged with HEAD and other interesting changes
This commit is contained in:
parent
66c6c0fae5
commit
856cc06d04
151 changed files with 7335 additions and 2602 deletions
|
|
@ -17,6 +17,7 @@ use FindBin;
|
|||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Scalar::Util qw/refaddr/;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
|
|
@ -32,7 +33,7 @@ my $i18n = WebGUI::International->new($session, "Shop");
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 21; # Increment this number for each test you create
|
||||
plan tests => 28; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -73,6 +74,7 @@ is(scalar(@{$cart->getItems}), 1, "Should have 1 item type in cart regardless of
|
|||
|
||||
$item->update({shippingAddressId => "XXXX"});
|
||||
is($item->get("shippingAddressId"), "XXXX", "Can set values to the cart item properties.");
|
||||
$item->update({shippingAddressId => undef});
|
||||
|
||||
like($cart->getId, qr/[A-Za-z0-9\_\-]{22}/, "Id looks like a guid.");
|
||||
|
||||
|
|
@ -88,9 +90,67 @@ is($cart->get("shippingAddressId"), "XXXX", "Can set values to the cart properti
|
|||
|
||||
isa_ok($cart->getAddressBook, "WebGUI::Shop::AddressBook", "can get an address book");
|
||||
|
||||
$cart->empty;
|
||||
is($session->db->quickScalar("select count(*) from cartItem where cartId=?",[$cart->getId]), 0, "Items are removed from cart.");
|
||||
#
|
||||
# readyForCheckout ( )
|
||||
#
|
||||
|
||||
# Setup a checkout'able cart and verify that it is
|
||||
my $address = $cart->getAddressBook->addAddress( { firstName => 'C.D.', lastName => 'Murray'} );
|
||||
my $ship = WebGUI::Shop::Ship->new( $session );
|
||||
my $shipper = $ship->addShipper( 'WebGUI::Shop::ShipDriver::FlatRate', {flatFee => 1 } );
|
||||
$cart->update( {
|
||||
shippingAddressId => $address->getId,
|
||||
shipperId => $shipper->getId,
|
||||
} );
|
||||
is($cart->readyForCheckout, 1, 'Cart is ready for checkout');
|
||||
|
||||
# Check shipping address constraint
|
||||
$cart->update( {shippingAddressId => 'Does Not Exist'} );
|
||||
is( $cart->readyForCheckout, 0, 'Cannot checkout cart without shipping address' );
|
||||
|
||||
# Check shipper constraint
|
||||
$cart->update( {
|
||||
shippingAddressId => $address->getId,
|
||||
shipperId => 'Does Not Exist',
|
||||
} );
|
||||
is( $cart->readyForCheckout, 0, 'Cannot checkout cart without shipper' );
|
||||
|
||||
# Check minimum transaction amount
|
||||
$session->setting->set( 'shopCartCheckoutMinimum', 1000 );
|
||||
$cart->update( {
|
||||
shippingAddressId => $address->getId,
|
||||
shipperId => $shipper->getId,
|
||||
} );
|
||||
is( $cart->readyForCheckout, 0, 'Cannot checkout cart when cart total is lower than required' );
|
||||
$session->setting->set( 'shopCartCheckoutMinimum', 0 );
|
||||
|
||||
# Check empty cart constraint
|
||||
$cart->empty;
|
||||
is( $cart->readyForCheckout, 0, 'Cannot checkout an empty cart' );
|
||||
|
||||
#
|
||||
# empty ( )
|
||||
#
|
||||
is($session->db->quickScalar("select count(*) from cartItem where cartId=?",[ $cart->getId ]), 0, "Items are removed from cart.");
|
||||
|
||||
|
||||
my $session2 = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
|
||||
$session2->user({userId => 3});
|
||||
my $cart2 = WebGUI::Shop::Cart->newBySession($session2);
|
||||
isnt(
|
||||
refaddr $cart->getAddressBook,
|
||||
refaddr $cart2->getAddressBook,
|
||||
'Different carts with different sessions have different AddressBooks'
|
||||
);
|
||||
$cart2->delete;
|
||||
|
||||
my $cart3 = WebGUI::Shop::Cart->newBySession($session);
|
||||
isnt(
|
||||
refaddr $cart->getAddressBook,
|
||||
refaddr $cart3->getAddressBook,
|
||||
'Different carts with same sessions will each have different AddressBooks since no book has been assigned yet.'
|
||||
);
|
||||
$cart3->delete;
|
||||
|
||||
$cart->delete;
|
||||
is($cart->delete, undef, "Can destroy cart.");
|
||||
|
|
@ -101,5 +161,5 @@ $product->purge;
|
|||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
$session2->close;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
my $tests = 44;
|
||||
my $tests = 49;
|
||||
plan tests => 1 + $tests;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -283,6 +283,27 @@ cmp_deeply(
|
|||
'delete removed the correct vendor'
|
||||
);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# isVendorInfoComplete
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
my %completeProps = (
|
||||
name => 'Esquerita',
|
||||
userId => $fenceUser->userId,
|
||||
preferredPaymentType => 'PayPal',
|
||||
paymentInformation => 'esquerita@example.com',
|
||||
);
|
||||
$fence->update( { %completeProps } );
|
||||
is( $fence->isVendorInfoComplete, 1, 'Vendor information is complete' );
|
||||
|
||||
foreach (keys %completeProps ) {
|
||||
$fence->update( { %completeProps, $_ => undef } );
|
||||
ok( !$fence->isVendorInfoComplete, "Vendor information is not complete without $_" );
|
||||
}
|
||||
|
||||
|
||||
undef $guard;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue