Merge commit '41575d24bb' into webgui8. Some tests still failing.

Conflicts:
	docs/gotcha.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset.pm
	lib/WebGUI/Asset/File/GalleryFile/Photo.pm
	lib/WebGUI/Asset/Post.pm
	lib/WebGUI/Asset/Template.pm
	lib/WebGUI/Asset/WikiPage.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/Cache.pm
	lib/WebGUI/Content/Setup.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Pay.pm
	lib/WebGUI/Shop/PayDriver/ITransact.pm
	sbin/testEnvironment.pl
	t/Asset/WikiPage.t
	t/Shop/PayDriver.t
	t/Shop/PayDriver/ITransact.t
	t/Shop/PayDriver/Ogone.t
	t/Shop/TaxDriver/EU.t
	t/Shop/TaxDriver/Generic.t
	t/Workflow/Activity/RemoveOldCarts.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Colin Kuskie 2010-06-25 23:25:26 -07:00
commit 5febc0ebbc
258 changed files with 5528 additions and 2230 deletions

View file

@ -74,8 +74,11 @@ cmp_deeply(
'create takes exception to giving it a session variable',
);
$session->user({userId => 3});
my $book = WebGUI::Shop::AddressBook->create($session);
my $book2 = WebGUI::Shop::AddressBook->create($session);
WebGUI::Test->addToCleanup($book, $book2);
eval { $address = WebGUI::Shop::Address->create($book); };
$e = Exception::Class->caught();
@ -242,8 +245,3 @@ cmp_deeply(
$address->delete;
my $check = $session->db->quickScalar('select count(*) from address where addressId=?',[$address->getId]);
is( $check, 0, 'delete worked');
END {
$session->db->write('delete from addressBook');
$session->db->write('delete from address');
}

View file

@ -32,7 +32,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 24;
plan tests => 26;
#----------------------------------------------------------------------------
# put your tests here
@ -104,7 +104,18 @@ cmp_deeply(
);
$session->user({userId => 1});
eval { $book = WebGUI::Shop::AddressBook->create($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'create takes exception to making an address book for Visitor');
cmp_deeply(
$e,
methods(
error => 'Visitor cannot have an address book.',
),
'... correct error message',
);
$session->user({userId => 3});
$book = WebGUI::Shop::AddressBook->create($session);
isa_ok($book, 'WebGUI::Shop::AddressBook', 'create returns the right kind of object');
@ -114,7 +125,7 @@ is($session->getId, $book->session->getId, 'session method returns OUR session o
ok($session->id->valid($book->getId), 'create makes a valid GUID style addressBookId');
is($book->get('userId'), 1, 'create uses $session->user to get the userid for this book');
is($book->get('userId'), 3, 'create uses $session->user to get the userid for this book');
my $bookCount = $session->db->quickScalar('select count(*) from addressBook');
is($bookCount, 1, 'only 1 address book was created');
@ -167,7 +178,6 @@ cmp_deeply(
$book->get(),
{
userId => ignore(),
sessionId => ignore(),
addressBookId => ignore(),
defaultAddressId => ignore(),
},
@ -204,7 +214,7 @@ undef $book;
#######################################################################
#
# newBySession
# newByUserId
#
#######################################################################
@ -214,22 +224,15 @@ my $mergeUser = WebGUI::User->create($otherSession);
WebGUI::Test->addToCleanup($mergeUser);
$otherSession->user({user => $mergeUser});
my $adminBook = WebGUI::Shop::AddressBook->create($otherSession);
WebGUI::Test->addToCleanup($adminBook);
my $goodAddress = $adminBook->addAddress({label => 'first'});
my $session2 = WebGUI::Test->newSession;
$session2->user({user => $mergeUser});
my $bookAdmin = WebGUI::Shop::AddressBook->newBySession($session2);
my $bookAdmin = WebGUI::Shop::AddressBook->newByUserId($session2);
cmp_bag(
[ map { $_->getId } @{ $bookAdmin->getAddresses } ],
[ $goodAddress->getId, ],
'newBySession merges address books by userId'
'newByUserId works'
);
$adminBook->delete;
$bookAdmin->delete;
END {
$session->db->write('delete from addressBook');
$session->db->write('delete from address');
}

View file

@ -48,7 +48,10 @@ throws_deeply ( sub { my $cart = WebGUI::Shop::Cart->newBySession(); },
'newBySession takes an exception to not giving it a session variable'
);
$session->user({userId => 3});
my $cart = WebGUI::Shop::Cart->newBySession($session);
WebGUI::Test->addToCleanup($cart);
isa_ok($cart, "WebGUI::Shop::Cart");
isa_ok($cart->session, "WebGUI::Session");
@ -62,6 +65,7 @@ my $product = $root->addChild({
className=>"WebGUI::Asset::Sku::Donation",
title=>"Test Product",
});
WebGUI::Test->addToCleanup($product);
$product->applyOptions({price=>50.25});
my $item = $cart->addItem($product);
isa_ok($item, "WebGUI::Shop::CartItem");
@ -100,16 +104,33 @@ isa_ok($cart->getAddressBook, "WebGUI::Shop::AddressBook", "can get an address b
#
# Setup a checkout'able cart and verify that it is
my $address = $cart->getAddressBook->addAddress( { firstName => 'C.D.', lastName => 'Murray'} );
my $address = $cart->getAddressBook->addAddress( {
label => 'cell block',
firstName => 'C.D.', lastName => 'Murray',
address1 => 'cell block #5',
city => 'Shawshank', state => 'MN',
code => '55555', country => 'United States of America',
phoneNumber => '555.555.5555', email => 'newFish@shawshank.gov',
} );
my $ship = WebGUI::Shop::Ship->new( $session );
my $shipper = $ship->addShipper( 'WebGUI::Shop::ShipDriver::FlatRate', {flatFee => 1 } );
WebGUI::Test->addToCleanup($shipper);
$cart->update( {
shippingAddressId => $address->getId,
} );
ok(! $cart->readyForCheckout, 'readyForCheckout: returns false due to no shipperId');
$cart->update( { shipperId => $shipper->getId, } );
ok($cart->readyForCheckout, '... returns true when it has shipperId, and shipping address');
my $pay = WebGUI::Shop::Pay->new($session);
my $gateway = $pay->getPaymentGateways()->[0];
$cart->error('');
$cart->update( {
shipperId => $shipper->getId,
billingAddressId => $address->getId,
gatewayId => $gateway->getId,
} );
ok($cart->readyForCheckout, '... returns true when it has shipperId, shipping and billing addresses and a gatewayId')
|| diag $cart->error;
# Check shipping address constraint
$cart->update( {shippingAddressId => 'Does Not Exist'} );
@ -137,6 +158,7 @@ my $session2 = WebGUI::Session->open(WebGUI::Test->file);
addToCleanup($session2);
$session2->user({userId => 3});
my $cart2 = WebGUI::Shop::Cart->newBySession($session2);
WebGUI::Test->addToCleanup($cart2);
isnt(
refaddr $cart->getAddressBook,
refaddr $cart2->getAddressBook,
@ -145,6 +167,7 @@ isnt(
$cart2->delete;
my $cart3 = WebGUI::Shop::Cart->newBySession($session);
WebGUI::Test->addToCleanup($cart3);
isnt(
refaddr $cart->getAddressBook,
refaddr $cart3->getAddressBook,
@ -158,10 +181,3 @@ is($cart->delete, undef, "Can destroy cart.");
$product->purge;
#----------------------------------------------------------------------------
# Cleanup
END {
if ($shipper) {
$shipper->delete;
}
}

View file

@ -23,6 +23,7 @@ use HTML::Form;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Shop::PayDriver;
#----------------------------------------------------------------------------
# Init
@ -31,22 +32,13 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 54;
plan tests => 1 + $tests;
plan tests => 54;
#----------------------------------------------------------------------------
# figure out if the test can actually run
my $e;
my $loaded = use_ok('WebGUI::Shop::PayDriver');
my $storage;
SKIP: {
skip 'Unable to load module WebGUI::Shop::PayDriver', $tests unless $loaded;
#######################################################################
#
# definition
@ -256,6 +248,7 @@ isnt(
my $cart = $driver->getCart;
WebGUI::Test->addToCleanup($cart);
isa_ok ($cart, 'WebGUI::Shop::Cart', 'getCart returns an instantiated WebGUI::Shop::Cart object');
addToCleanup($cart);
#######################################################################
#
@ -477,4 +470,3 @@ is ($count, 0, 'delete deleted the object');
undef $driver;
}

View file

@ -23,6 +23,7 @@ use WebGUI::Session;
use WebGUI::Shop::Cart;
use WebGUI::Shop::Ship;
use WebGUI::Shop::Transaction;
use WebGUI::Shop::PayDriver::ITransact;
use JSON;
use HTML::Form;
use WebGUI::Shop::PayDriver::ITransact;
@ -30,6 +31,7 @@ use WebGUI::Shop::PayDriver::ITransact;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
$session->user({userId => 3});
#----------------------------------------------------------------------------
@ -41,6 +43,25 @@ plan tests => 28;
# figure out if the test can actually run
my $e;
my $ship = WebGUI::Shop::Ship->new($session);
my $cart = WebGUI::Shop::Cart->newBySession($session);
WebGUI::Test->addToCleanup($cart);
my $shipper = $ship->getShipper('defaultfreeshipping000');
my $address = $cart->getAddressBook->addAddress( {
label => 'red',
firstName => 'Ellis Boyd', lastName => 'Redding',
address1 => 'cell block #5',
city => 'Shawshank', state => 'MN',
code => '55555', country => 'United States of America',
phoneNumber => '555.555.5555', email => 'red@shawshank.gov',
} );
$cart->update({
billingAddressId => $address->getId,
shippingAddressId => $address->getId,
shipperId => $shipper->getId,
});
my $transaction;
my $versionTag = WebGUI::VersionTag->getWorking($session);
my $home = WebGUI::Asset->getDefault($session);
@ -82,9 +103,6 @@ $cart->update({
shipperId => $shipper->getId,
});
my $hammerItem = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $smallHammer));
#######################################################################
#
# definition
@ -254,21 +272,8 @@ $driver->{_cardData} = {
cvv2 => '1234',
};
$driver->{_billingAddress} = {
firstName => 'Ellis Boyd',
lastName => 'Redding',
address1 => '#2 Row 30265',
city => 'Shawshank',
state => 'Maine',
code => '97025',
country => 'USA',
phoneNumber => '555.555.5555',
email => '30265@shawshank.gov',
};
my $transaction = WebGUI::Shop::Transaction->create($session, {
paymentMethod => $driver,
$cart->update({gatewayId => $driver->getId,});
$transaction = WebGUI::Shop::Transaction->create($session, {
cart => $cart,
isRecurring => $cart->requiresRecurringPayment,
});

View file

@ -22,6 +22,7 @@ use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use JSON;
use HTML::Form;
use WebGUI::Shop::PayDriver::Ogone;
#----------------------------------------------------------------------------
# Init
@ -31,21 +32,13 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 45;
plan tests => 1 + $tests;
plan tests => 45;
#----------------------------------------------------------------------------
# figure out if the test can actually run
my $e;
note('Testing existence');
my $loaded = use_ok('WebGUI::Shop::PayDriver::Ogone');
SKIP: {
skip 'Unable to load module WebGUI::Shop::PayDriver::Ogone', $tests unless $loaded;
#######################################################################
#
# definition
@ -110,6 +103,13 @@ my $expectDefinition = {
hoverHelp => ignore(),
defaultValue => 1,
},
summaryTemplateId => {
fieldType => 'template',
label => ignore(),
hoverHelp => ignore(),
defaultValue => ignore(),
namespace => 'Shop/Credentials',
},
},
};
@ -355,6 +355,7 @@ isnt(
my $cart = $driver->getCart;
WebGUI::Test->addToCleanup($cart);
isa_ok ($cart, 'WebGUI::Shop::Cart', 'getCart returns an instantiated WebGUI::Shop::Cart object');
WebGUI::Test->addToCleanup($cart);
#######################################################################
#
@ -373,7 +374,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
is (scalar @forms, 1, 'getEditForm generates just 1 form');
my @inputs = $forms[0]->inputs;
is (scalar @inputs, 17, 'getEditForm: the form has 17 controls');
is (scalar @inputs, 18, 'getEditForm: the form has 18 controls');
my @interestingFeatures;
foreach my $input (@inputs) {
@ -453,6 +454,10 @@ cmp_deeply(
name => 'useTestMode',
type => 'radio',
},
{
name => 'summaryTemplateId',
type => 'option',
},
],
'getEditForm made the correct form with all the elements'
@ -577,5 +582,4 @@ is ($count, 0, 'delete deleted the object');
undef $driver;
}
#vim:ft=perl

View file

@ -189,10 +189,12 @@ cmp_deeply(
$defaultDriver->getId => {
label => $defaultDriver->get('label'),
price => ignore(),
hasPrice => 0,
},
$driver->getId => {
label => $driver->get('label'),
price => ignore(),
hasPrice => 0,
},
},
'getOptions returns the two enabled shipping drivers'

View file

@ -27,6 +27,7 @@ use WebGUI::Session;
use WebGUI::Text;
use WebGUI::Shop::Cart;
use WebGUI::Shop::AddressBook;
use WebGUI::Shop::TaxDriver::EU;
#----------------------------------------------------------------------------
# Init
@ -36,6 +37,7 @@ my $session = WebGUI::Test->session;
my $taxUser = WebGUI::User->new( $session, 'new' );
$taxUser->username( 'Tex Evasion' );
WebGUI::Test->addToCleanup($taxUser);
$session->user({userId => $taxUser->getId});
# Test VAT numbers
my $testVAT_NL = 'NL123456789B12';
@ -58,8 +60,10 @@ my $sku = WebGUI::Asset->getRoot($session)->addChild( {
title => 'Taxable donation',
defaultPrice => 100.00,
} );
WebGUI::Test->addToCleanup($sku);
my $book = WebGUI::Shop::AddressBook->create($session);
WebGUI::Test->addToCleanup($book);
# setup address in EU but not in residential country of merchant
my $beAddress = $book->addAddress({
@ -82,22 +86,15 @@ my $usAddress = $book->addAddress({
country => 'US',
});
my $cart;
#----------------------------------------------------------------------------
# Tests
my $tests = 342;
plan tests => 1 + $tests;
plan tests => $tests;
#----------------------------------------------------------------------------
# put your tests here
my $loaded = use_ok('WebGUI::Shop::TaxDriver::EU');
SKIP: {
skip 'Unable to load module WebGUI::Shop::TaxDriver::EU', $tests unless $loaded;
#######################################################################
#
@ -474,7 +471,8 @@ SKIP: {
), 'appendCartItemVars returns correct error for missing CartItem' );
$cart = WebGUI::Shop::Cart->newBySession( $session );
my $cart = WebGUI::Shop::Cart->newBySession( $session );
WebGUI::Test->addToCleanup($cart);
my $item = $cart->addItem( $sku );
$item->setQuantity( 2 );
@ -554,8 +552,6 @@ SKIP: {
}
} #SKIP BLOCK
#----------------------------------------------------------------------------
sub setupTestNumbers {
my $taxer = WebGUI::Shop::TaxDriver::EU->new($session);
@ -574,11 +570,8 @@ sub setupTestNumbers {
# Cleanup
END {
$session->db->write('delete from tax_eu_vatNumbers');
$cart->delete;
$session->db->write('delete from cart');
$session->db->write('delete from addressBook');
$session->db->write('delete from address');
$session->db->write('delete from taxDriver where className=?', [ 'WebGUI::Shop::TaxDriver::EU' ]);
$sku->purge;
}

View file

@ -31,13 +31,14 @@ use WebGUI::Shop::TaxDriver::Generic;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
$session->user({userId => 3});
#----------------------------------------------------------------------------
# Tests
my $addExceptions = getAddExceptions($session);
plan tests => 78
plan tests => 79
+ 2*scalar(@{$addExceptions});
#----------------------------------------------------------------------------
@ -471,6 +472,7 @@ $taxer->importTaxData(
WebGUI::Test->getTestCollateralPath('taxTables/largeTaxTable.csv')
),
my $book = WebGUI::Shop::AddressBook->create($session);
WebGUI::Test->addToCleanup($book);
my $taxingAddress = $book->addAddress({
label => 'taxing',
city => 'Madison',
@ -579,12 +581,11 @@ $tag2->commit;
WebGUI::Test->addToCleanup($tag2);
$taxFreeDonation = $taxFreeDonation->cloneFromDb;
$taxFreeDonation->setTaxConfiguration( 'WebGUI::Shop::TaxDriver::Generic', {
overrideTaxRate => 1,
taxRateOverride => 0,
});
my $tax = $taxer->getTaxRate( $taxableDonation, $taxingAddress );
is($tax, 5.5, 'calculate: simple tax calculation on 1 item in the cart');
is($taxer->getTaxRate( $taxFreeDonation, $taxingAddress), 0, 'getTaxRate: tax rate override should override tax derived from address');
$cart->update({ shippingAddressId => $taxFreeAddress->getId});
is($taxer->getTaxRate( $taxableDonation, $taxFreeAddress ), 0, 'calculate: simple tax calculation on 1 item in the cart, tax free location');
#######################################################################
#