Merge remote branch 'upstream/WebGUI8' into 8-merge

Conflicts:
	docs/gotcha.txt
	docs/previousVersion.sql
	lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
	lib/WebGUI/Asset/Wobject/Navigation.pm
	lib/WebGUI/AssetLineage.pm
	lib/WebGUI/Config.pm
	lib/WebGUI/Form/Template.pm
	lib/WebGUI/Group.pm
	lib/WebGUI/VersionTag.pm
	lib/WebGUI/Workflow/Activity/TrashExpiredEvents.pm
	t/AdSpace.t
	t/Asset/AssetExportHtml.t
	t/Asset/AssetLineage.t
	t/Asset/Story.t
	t/Asset/Template/HTMLTemplateExpr.t
	t/Asset/Wobject/Gallery/00base.t
	t/Asset/Wobject/GalleryAlbum/00base.t
	t/Asset/Wobject/GalleryAlbum/ajax.t
	t/Asset/Wobject/InOutBoard.t
	t/Asset/Wobject/StoryArchive.t
	t/Asset/Wobject/Survey/ExpressionEngine.t
	t/Asset/Wobject/Survey/Reports.t
	t/AssetAspect/RssFeed.t
	t/Auth/mech.t
	t/Group.t
	t/Mail/Send.t
	t/Operation/AdSpace.t
	t/Session/ErrorHandler.t
	t/Session/Scratch.t
	t/Session/Url.t
	t/Shop/Cart.t
	t/Shop/Pay.t
	t/Shop/Ship.t
	t/Shop/ShipDriver.t
	t/Shop/TaxDriver/Generic.t
	t/Shop/Vendor.t
	t/VersionTag.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Doug Bell 2010-07-14 18:20:00 -05:00
commit 708b47d73c
165 changed files with 3199 additions and 5718 deletions

View file

@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 28;
plan tests => 20;
#----------------------------------------------------------------------------
# put your tests here
@ -42,13 +42,13 @@ my $address;
#######################################################################
#
# create
# new
#
#######################################################################
eval { $address = WebGUI::Shop::Address->create(); };
eval { $address = WebGUI::Shop::Address->new(); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidObject', 'create takes exception to not giving it an address book');
isa_ok($e, 'WebGUI::Error::InvalidObject', 'new takes exception to not giving it an address book');
cmp_deeply(
$e,
methods(
@ -57,12 +57,12 @@ cmp_deeply(
got => '',
param => undef,
),
'create takes exception to not giving it address book',
'... parameter check',
);
eval { $address = WebGUI::Shop::Address->create($session); };
eval { $address = WebGUI::Shop::Address->new($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidObject', 'create takes exception to not giving it a session variable');
isa_ok($e, 'WebGUI::Error::InvalidObject', 'new takes exception to giving it a session variable');
cmp_deeply(
$e,
methods(
@ -71,29 +71,17 @@ cmp_deeply(
got => 'WebGUI::Session',
param => $session,
),
'create takes exception to giving it a session variable',
'... parameter check',
);
$session->user({userId => 3});
my $book = WebGUI::Shop::AddressBook->create($session);
my $book2 = WebGUI::Shop::AddressBook->create($session);
my $book = WebGUI::Shop::AddressBook->new($session);
my $book2 = WebGUI::Shop::AddressBook->new($session);
WebGUI::Test->addToCleanup($book, $book2);
eval { $address = WebGUI::Shop::Address->create($book); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'create takes exception to not giving it address data');
cmp_deeply(
$e,
methods(
error => 'Need a hash reference.',
param => undef,
),
'create takes exception to giving it address data',
);
$address = WebGUI::Shop::Address->create($book, {});
isa_ok($address, 'WebGUI::Shop::Address', 'create returns an Address object with an empty hashref');
$address = WebGUI::Shop::Address->new($book, {});
isa_ok($address, 'WebGUI::Shop::Address', 'new returns an Address object with an empty hashref');
#######################################################################
#
@ -126,28 +114,29 @@ is($address->getId, $address->get('addressId'), 'getId is an alias for get addre
cmp_deeply(
$address->get,
{
label => undef,
firstName => undef,
lastName => undef,
address1 => undef,
address2 => undef,
address3 => undef,
city => undef,
state => undef,
country => undef,
code => undef,
phoneNumber => undef,
email => undef,
organization => undef,
addressId => ignore(), #checked elsewhere
label => '',
firstName => '',
lastName => '',
address1 => '',
address2 => '',
address3 => '',
city => '',
state => '',
country => '',
code => '',
phoneNumber => '',
email => '',
organization => '',
addressId => ignore(), #checked elsewhere
addressBookId => $book->getId,
addressBook => $book,
},
'get the whole thing and check a new, blank object'
);
my $addressGuts = $address->get();
$addressGuts->{'label'} = 'hacked';
is($address->get('label'), undef, 'get returns a safe copy of the hash');
is($address->get('label'), '', 'get returns a safe copy of the hash');
#######################################################################
#
@ -172,46 +161,6 @@ $address->update({ addressBookId => $book->getId });
#
#######################################################################
eval { $address = WebGUI::Shop::Address->new(); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidObject', 'new takes exception to not giving it an address book');
cmp_deeply(
$e,
methods(
error => 'Need an address book.',
expected => 'WebGUI::Shop::AddressBook',
got => '',
param => ignore,
),
'new takes exception to not giving it address book',
);
eval { $address = WebGUI::Shop::Address->new($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidObject', 'new takes exception to not giving it a session variable');
cmp_deeply(
$e,
methods(
error => 'Need an address book.',
expected => 'WebGUI::Shop::AddressBook',
got => 'WebGUI::Session',
param => ignore,
),
'new takes exception to giving it a session variable',
);
eval { $address = WebGUI::Shop::Address->new($book); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'new takes exception to not giving it an address to instanciate');
cmp_deeply(
$e,
methods(
error => 'Need an addressId.',
param => undef,
),
'new takes exception to giving it an address to instanciate',
);
eval { $address = WebGUI::Shop::Address->new($book, 'neverAnId'); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::ObjectNotFound', 'new takes exception to not giving it a bad address instanciate');

View file

@ -32,7 +32,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 26;
plan tests => 23;
#----------------------------------------------------------------------------
# put your tests here
@ -60,17 +60,7 @@ cmp_deeply(
'new takes exception to not giving it a session object',
);
eval { $book = WebGUI::Shop::AddressBook->new($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'new takes exception to not giving it a addressBookId');
cmp_deeply(
$e,
methods(
error => 'Need an addressBookId.',
),
'new takes exception to not giving it a addressBook Id',
);
$session->user({userId => 3});
eval { $book = WebGUI::Shop::AddressBook->new($session, 'neverAGUID'); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::ObjectNotFound', 'new takes exception to not giving it an existing addressBookId');
@ -82,31 +72,12 @@ cmp_deeply(
),
'new takes exception to not giving it a addressBook Id',
);
#######################################################################
#
# create
#
#######################################################################
eval { $book = WebGUI::Shop::AddressBook->create(); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'create takes exception to not giving it a session object');
cmp_deeply(
$e,
methods(
error => 'Need a session.',
expected => 'WebGUI::Session',
got => '',
),
'create takes exception to not giving it a session object',
);
$session->user({userId => 1});
eval { $book = WebGUI::Shop::AddressBook->create($session); };
eval { $book = WebGUI::Shop::AddressBook->new($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'create takes exception to making an address book for Visitor');
isa_ok($e, 'WebGUI::Error::InvalidParam', 'new takes exception to making an address book for Visitor');
cmp_deeply(
$e,
methods(
@ -116,22 +87,23 @@ cmp_deeply(
);
$session->user({userId => 3});
$book = WebGUI::Shop::AddressBook->create($session);
isa_ok($book, 'WebGUI::Shop::AddressBook', 'create returns the right kind of object');
$book = WebGUI::Shop::AddressBook->new($session);
isa_ok($book, 'WebGUI::Shop::AddressBook', 'new returns the right kind of object');
isa_ok($book->session, 'WebGUI::Session', 'session method returns a session object');
is($session->getId, $book->session->getId, 'session method returns OUR session object');
ok($session->id->valid($book->getId), 'create makes a valid GUID style addressBookId');
ok($session->id->valid($book->getId), 'new makes a valid GUID style addressBookId');
is($book->get('userId'), 3, 'create uses $session->user to get the userid for this book');
is($book->get('userId'), 3, 'new uses $session->user to get the userid for this book');
is($book->userId, 3, '... testing direct accessor');
my $bookCount = $session->db->quickScalar('select count(*) from addressBook');
is($bookCount, 1, 'only 1 address book was created');
my $alreadyHaveBook = WebGUI::Shop::AddressBook->create($session);
isnt($book->getId, $alreadyHaveBook->getId, 'creating an addressbook as visitor, even when you already have one, always returns a new one');
my $alreadyHaveBook = WebGUI::Shop::AddressBook->new($session);
isnt($book->getId, $alreadyHaveBook->getId, 'creating an addressbook, even when you already have one, always returns a new one');
#######################################################################
#
@ -177,15 +149,16 @@ $book->update({ lastShipId => $address1->getId, lastPayId => $address2->getId});
cmp_deeply(
$book->get(),
{
userId => ignore(),
addressBookId => ignore(),
userId => ignore(),
addressBookId => ignore(),
defaultAddressId => ignore(),
},
'update updates the object properties cache'
'update does not add new properties to the object'
);
my $bookClone = WebGUI::Shop::AddressBook->new($session, $book->getId);
delete $book->{_addressCache};
cmp_deeply(
$bookClone,
$book,
@ -223,13 +196,14 @@ my $otherSession = WebGUI::Test->newSession;
my $mergeUser = WebGUI::User->create($otherSession);
WebGUI::Test->addToCleanup($mergeUser);
$otherSession->user({user => $mergeUser});
my $adminBook = WebGUI::Shop::AddressBook->create($otherSession);
my $adminBook = WebGUI::Shop::AddressBook->new($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->newByUserId($session2);
WebGUI::Test->addToCleanup($bookAdmin);
cmp_bag(
[ map { $_->getId } @{ $bookAdmin->getAddresses } ],

View file

@ -33,7 +33,7 @@ my $i18n = WebGUI::International->new($session, "Shop");
#----------------------------------------------------------------------------
# Tests
plan tests => 30; # Increment this number for each test you create
plan tests => 29; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -81,11 +81,7 @@ $item->update({shippingAddressId => "XXXX"});
is($item->get("shippingAddressId"), "XXXX", "Can set shippingAddressId in the cart item properties.");
$item->update({shippingAddressId => undef});
my $now = time();
$cart->update({creationDate => $now});
is($cart->get('creationDate'), $now, 'update: set creationDate');
like($cart->getId, qr/[A-Za-z0-9\_\-]{22}/, "Id looks like a guid.");
ok($session->id->valid($cart->getId), "Id looks like a guid.");
is(ref($cart->get), "HASH", "Cart properties are a hash reference.");
is($cart->get("sessionId"), $session->getId, "Can retrieve a value from the cart properties.");
@ -154,8 +150,8 @@ is( $cart->readyForCheckout, 0, 'Cannot checkout an empty cart' );
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->file);
addToCleanup($session2);
my $session2 = WebGUI::Test->newSession;
WebGUI::Test->addToCleanup($session2);
$session2->user({userId => 3});
my $cart2 = WebGUI::Shop::Cart->newBySession($session2);
WebGUI::Test->addToCleanup($cart2);

View file

@ -30,9 +30,6 @@ use WebGUI::TestException;
# Init
my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
#----------------------------------------------------------------------------
# put your tests here
@ -220,6 +217,7 @@ cmp_bag(
#######################################################################
done_testing();
<<<<<<< HEAD
#----------------------------------------------------------------------------
# Cleanup
@ -227,3 +225,5 @@ END {
defined $newDriver and $newDriver->delete;
defined $newDriver and $anotherDriver->delete;
}
=======
>>>>>>> upstream/WebGUI8

View file

@ -205,9 +205,4 @@ $cart->delete;
done_testing();
#----------------------------------------------------------------------------
# Cleanup
END {
$driver->delete;
$driver2->delete;
}
#vim:ft=perl

View file

@ -668,10 +668,4 @@ sub getAddExceptions {
},
];
}
#----------------------------------------------------------------------------
# Cleanup
END {
$session->db->write('delete from tax_generic_rates');
}
#vim:ft=perl

View file

@ -31,14 +31,14 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 49;
plan tests => 55;
#----------------------------------------------------------------------------
# put your tests here
my $loaded = use_ok('WebGUI::Shop::Vendor');
my ($vendor, $guard, $numberOfVendors);
my ($vendor);
my ($fence, $fenceCopy);
my $fenceUser = WebGUI::User->new($session, 'new');
$fenceUser->username('fence');
@ -46,8 +46,6 @@ my $guardUser = WebGUI::User->new($session, 'new');
$guardUser->username('guard');
WebGUI::Test->addToCleanup($fenceUser, $guardUser);
$numberOfVendors = scalar @{ WebGUI::Shop::Vendor->getVendors($session) };
#######################################################################
#
# new
@ -69,6 +67,19 @@ cmp_deeply(
'new: requires a session variable',
);
eval { $vendor = WebGUI::Shop::Vendor->new({ userId => 3, }); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidObject', 'new via property hash takes an exception to not giving it a session variable');
cmp_deeply(
$e,
methods(
error => 'Need a session.',
got => '',
expected => 'WebGUI::Session',
),
'... requires a session variable',
);
eval { $vendor = WebGUI::Shop::Vendor->new($session); };
$e = Exception::Class->caught();
isa_ok($e, 'WebGUI::Error::InvalidParam', 'new takes an exception to not giving it a vendor id to instanciate');
@ -92,6 +103,13 @@ cmp_deeply(
'new: requires a valid vendorId',
);
my $test_vendor = eval { WebGUI::Shop::Vendor->new({ session => $session, }); };
$e = Exception::Class->caught();
ok(!$e, 'new via property hash with session');
isa_ok($test_vendor, 'WebGUI::Shop::Vendor', '... returns correct type of object');
WebGUI::Test->addToCleanup($test_vendor);
$test_vendor->delete;
eval { $vendor = WebGUI::Shop::Vendor->new($session, 'defaultvendor000000000'); };
$e = Exception::Class->caught();
ok(!$e, 'No exception thrown');
@ -125,15 +143,18 @@ cmp_deeply(
my $now = WebGUI::DateTime->new($session, time);
eval { $fence = WebGUI::Shop::Vendor->create($session, { userId => $fenceUser->userId, }); };
WebGUI::Test->addToCleanup($fence);
$e = Exception::Class->caught();
ok(!$e, 'No exception thrown by create');
ok(!$e, 'No exception thrown by create') ||
diag $@;
isa_ok($vendor, 'WebGUI::Shop::Vendor', 'create returns correct type of object');
WebGUI::Test->addToCleanup($fence);
is $fence->userId, $fenceUser->userId, 'object made with create has properties initialized correctly';
$fence->write;
ok($fence->get('dateCreated'), 'dateCreated is not null');
my $dateCreated = WebGUI::DateTime->new($session, $fence->get('dateCreated'));
my $deltaDC = $dateCreated - $now;
cmp_ok( $deltaDC->seconds, '<=', 2, 'dateCreated is set properly');
cmp_ok( $deltaDC->in_units('seconds'), '<=', 2, 'dateCreated is set properly');
#######################################################################
#
@ -144,12 +165,15 @@ cmp_ok( $deltaDC->seconds, '<=', 2, 'dateCreated is set properly');
ok($session->id->valid($fence->get('vendorId')), 'get: vendorId is a valid guid');
is($fence->getId, $fence->get('vendorId'), 'get: getId is an alias for get vendorId');
is($fence->get('userId'), $fenceUser->userId, 'get: userId');
is($fence->get('name'), undef, 'get: by default, no name is set');
is($fence->get('name'), '', 'get: by default, no name is set');
$fence->update({name => 'Bogs Diamond'});
is($fence->get('name'), 'Bogs Diamond', 'get: get name');
is($fence->get('userId'), $fenceUser->userId, 'get: updating name did not affect userId');
my $fence_fresh = WebGUI::Shop::Vendor->new($session, $fence->vendorId);
is($fence->name, 'Bogs Diamond', 'update wrote to the db');
my $newProps = {
name => 'Warden Norton',
url => 'http://www.shawshank.com',
@ -170,7 +194,6 @@ cmp_deeply(
paymentInformation => ignore(),
vendorId => ignore(),
preferredPaymentType => ignore(),
paymentAddressId => ignore(),
dateCreated => ignore(),
url => 'http://www.shawshank.com',
userId => $fenceUser->userId,
@ -246,10 +269,11 @@ my $defaultVendor = WebGUI::Shop::Vendor->newByUserId($session, 3);
#
#######################################################################
$guard = WebGUI::Shop::Vendor->create($session, { userId => $guardUser->userId, name => q|Warden Norton|});
my $guard = WebGUI::Shop::Vendor->create($session, { userId => $guardUser->userId, name => q|Warden Norton|});
$guard->write;
WebGUI::Test->addToCleanup($guard);
my $vendorsList = WebGUI::Shop::Vendor->getVendors($session);
cmp_deeply(
cmp_bag(
$vendorsList,
[ $guard, $fence, $defaultVendor, ],
'getVendors returns all 3 vendors as an array ref'