Merge commit 'v7.10.15' into 8

Conflicts:
	docs/gotcha.txt
	docs/previousVersion.sql
	docs/templates.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset.pm
	lib/WebGUI/Asset/Event.pm
	lib/WebGUI/Asset/File.pm
	lib/WebGUI/Asset/MapPoint.pm
	lib/WebGUI/Asset/RichEdit.pm
	lib/WebGUI/Asset/Sku/Product.pm
	lib/WebGUI/Asset/Snippet.pm
	lib/WebGUI/Asset/Story.pm
	lib/WebGUI/Asset/Template.pm
	lib/WebGUI/Asset/Template/TemplateToolkit.pm
	lib/WebGUI/Asset/Wobject/Calendar.pm
	lib/WebGUI/Asset/Wobject/Carousel.pm
	lib/WebGUI/Asset/Wobject/Collaboration.pm
	lib/WebGUI/Asset/Wobject/Dashboard.pm
	lib/WebGUI/Asset/Wobject/DataForm.pm
	lib/WebGUI/Asset/Wobject/Folder.pm
	lib/WebGUI/Asset/Wobject/Map.pm
	lib/WebGUI/Asset/Wobject/Search.pm
	lib/WebGUI/Asset/Wobject/Shelf.pm
	lib/WebGUI/Asset/Wobject/StockData.pm
	lib/WebGUI/Asset/Wobject/StoryTopic.pm
	lib/WebGUI/Asset/Wobject/SyndicatedContent.pm
	lib/WebGUI/Asset/Wobject/Thingy.pm
	lib/WebGUI/Asset/Wobject/WeatherData.pm
	lib/WebGUI/AssetClipboard.pm
	lib/WebGUI/AssetCollateral/DataForm/Entry.pm
	lib/WebGUI/AssetExportHtml.pm
	lib/WebGUI/AssetLineage.pm
	lib/WebGUI/AssetMetaData.pm
	lib/WebGUI/AssetTrash.pm
	lib/WebGUI/AssetVersioning.pm
	lib/WebGUI/Auth.pm
	lib/WebGUI/Cache/CHI.pm
	lib/WebGUI/Content/AssetManager.pm
	lib/WebGUI/Fork/ProgressBar.pm
	lib/WebGUI/Form/JsonTable.pm
	lib/WebGUI/Form/TimeField.pm
	lib/WebGUI/Form/Zipcode.pm
	lib/WebGUI/Group.pm
	lib/WebGUI/International.pm
	lib/WebGUI/Macro/AssetProxy.pm
	lib/WebGUI/Macro/FileUrl.pm
	lib/WebGUI/Operation/SSO.pm
	lib/WebGUI/Operation/User.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Transaction.pm
	lib/WebGUI/Shop/TransactionItem.pm
	lib/WebGUI/Test.pm
	lib/WebGUI/URL/Content.pm
	lib/WebGUI/URL/Uploads.pm
	lib/WebGUI/User.pm
	lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm
	lib/WebGUI/Workflow/Activity/SendNewsletters.pm
	lib/WebGUI/i18n/English/Asset.pm
	lib/WebGUI/i18n/English/WebGUI.pm
	sbin/installClass.pl
	sbin/rebuildLineage.pl
	sbin/search.pl
	sbin/testEnvironment.pl
	t/Asset/Asset.t
	t/Asset/AssetClipboard.t
	t/Asset/AssetLineage.t
	t/Asset/AssetMetaData.t
	t/Asset/Event.t
	t/Asset/File.t
	t/Asset/File/Image.t
	t/Asset/Post/notification.t
	t/Asset/Sku.t
	t/Asset/Story.t
	t/Asset/Template.t
	t/Asset/Wobject/Collaboration/templateVariables.t
	t/Asset/Wobject/Collaboration/unarchiveAll.t
	t/Asset/Wobject/Shelf.t
	t/Auth.t
	t/Macro/EditableToggle.t
	t/Macro/FilePump.t
	t/Shop/Cart.t
	t/Shop/Transaction.t
	t/Storage.t
	t/User.t
	t/Workflow.t
This commit is contained in:
Doug Bell 2011-05-13 18:15:11 -05:00
commit 277faae8a1
783 changed files with 32041 additions and 25495 deletions

View file

@ -15,12 +15,14 @@
use strict;
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';
#----------------------------------------------------------------------------
@ -31,7 +33,7 @@ my $i18n = WebGUI::International->new($session, "Shop");
#----------------------------------------------------------------------------
# Tests
plan tests => 29; # Increment this number for each test you create
plan tests => 35; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -173,5 +175,47 @@ $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 } );
}
# Test (part of) www_view
{
my $shippingAddressId = $cart->get( 'shippingAddressId' );
my $billingAddressId = $cart->get( 'billingAddressId' );
$cart->update( { shippingAddressId => 'NoWayDude' } );
eval { $cart->www_view };
is( $@, '', 'Invalid shippingAddressId doesn\'t make www_view crash' );
$cart->update( { billingAddressId => 'WRONG!!!!', shippingAddressId => $shippingAddressId } );
eval { $cart->www_view };
is( $@, '', 'Invalid billingAddressId doesn\'t make www_view crash' );
$cart->update( { billingAddressId => $billingAddressId } );
}
$product->purge;

View file

@ -336,7 +336,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => ignore(),
Machinable => ignore(), Ounces => ignore(),
Pounds => ignore(), Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -421,7 +421,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => ignore(),
Machinable => ignore(), Ounces => '0.0',
Pounds => 2, Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -433,7 +433,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => ignore(),
Machinable => ignore(), Ounces => '8.0',
Pounds => 1, Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -559,7 +559,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => ignore(),
Machinable => ignore(), Ounces => '0.0',
Pounds => 2, Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -571,7 +571,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => ignore(),
Machinable => ignore(), Ounces => '8.0',
Pounds => 1, Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -583,7 +583,7 @@ SKIP: {
ZipOrigination => ignore(), ZipDestination => 53703,
Machinable => ignore(), Ounces => '0.0',
Pounds => 12, Size => ignore(),
Zone => ignore(),
Zone => ignore(), Container => {},
Postage => {
CLASSID => ignore(),
MailService => ignore(),
@ -719,7 +719,7 @@ SKIP: {
{
Package => [
{
ID => 0,
ID => 0, Container => {},
ZipOrigination => ignore(), ZipDestination => ignore(),
Ounces => ignore(), Pounds => ignore(),
Size => ignore(), Zone => ignore(),
@ -783,7 +783,7 @@ SKIP: {
{
Package => [
{
ID => 0,
ID => 0, Container => {},
ZipOrigination => ignore(), ZipDestination => ignore(),
Ounces => ignore(), Pounds => ignore(),
Size => ignore(), Zone => ignore(),

View file

@ -308,7 +308,7 @@ SKIP: {
SvcCommitments => ignore(),
SvcDescription => ignore(),
},
(ignore())x12,
(ignore())x20,
],
},
],

View file

@ -231,8 +231,9 @@ plan tests => $tests;
'addVATNumber returns the correct message when VIES is unavailable',
);
my $workflows = WebGUI::Workflow::Instance->getAllInstances( $session );
my ($workflow) = grep { $_->get('parameters')->{ vatNumber } eq $noServiceVAT } @{ $workflows };
my ($workflow) = grep { $_->get('parameters')->{ vatNumber } eq $noServiceVAT }
grep { ref $_->get('parameters') eq 'HASH' }
@{ WebGUI::Workflow::Instance->getAllInstances( $session ) };
ok( defined $workflow , 'addVATNumber fires a recheck workflow when VIES is down' );
#----- valid number

View file

@ -16,6 +16,7 @@
use strict;
use Test::More;
use Test::Deep;
use Test::LongString;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Test::MockAsset;
use WebGUI::Session;
@ -31,7 +32,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 77; # Increment this number for each test you create
plan tests => 83; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -39,6 +40,7 @@ plan tests => 77; # Increment this number for each test you create
my $transaction = WebGUI::Shop::Transaction->new($session,{
amount => 40,
shippingAddressId => 'xxx1',
shippingOrganization => 'Ship To Us',
shippingAddressName => 'abc',
shippingAddress1 => 'def',
shippingAddress2 => 'hij',
@ -53,6 +55,7 @@ my $transaction = WebGUI::Shop::Transaction->new($session,{
shippingPrice => 5,
paymentAddressId => 'xxx3',
paymentAddressName => 'abc1',
paymentOrganization => 'Pay To Us',
paymentAddress1 => 'def1',
paymentAddress2 => 'hij1',
paymentAddress3 => 'lmn1',
@ -76,6 +79,7 @@ isa_ok($transaction->session, "WebGUI::Session");
is($transaction->amount, 40, "set and get amount");
is($transaction->shippingAddressId, 'xxx1', "set and get shipping address id");
is($transaction->shippingAddressName, 'abc', "set and get shipping address name");
is($transaction->shippingOrganization, 'Ship To Us', "set and get shipping organization");
is($transaction->shippingAddress1, 'def', "set and get shipping address 1");
is($transaction->shippingAddress2, 'hij', "set and get shipping address 2");
is($transaction->shippingAddress3, 'lmn', "set and get shipping address 3");
@ -89,6 +93,7 @@ is($transaction->shippingDriverLabel, 'foo', "set and get shipping driver label"
is($transaction->shippingPrice, 5, "set and get shipping price");
is($transaction->paymentAddressId, 'xxx3', "set and get payment address id");
is($transaction->paymentAddressName, 'abc1', "set and get payment address name");
is($transaction->paymentOrganization, 'Pay To Us', "set and get payment organization");
is($transaction->paymentAddress1, 'def1', "set and get payment address 1");
is($transaction->paymentAddress2, 'hij1', "set and get payment address 2");
is($transaction->paymentAddress3, 'lmn1', "set and get payment address 3");
@ -101,7 +106,6 @@ is($transaction->paymentDriverId, 'xxx4', "set and get payment driver id");
is($transaction->paymentDriverLabel, 'kkk', "set and get payment driver label");
is($transaction->taxes, 7, "set and get taxes");
$transaction->update({
isSuccessful => 1,
transactionCode => 'yyy',
@ -109,11 +113,11 @@ $transaction->update({
statusMessage => 'was a success',
});
is($transaction->get("isSuccessful"), 1,"update and get isSuccessful");
is($transaction->get("transactionCode"), 'yyy',"update and get transaction code");
is($transaction->get("statusCode"), 'jd31',"update and get status code");
is($transaction->get("statusMessage"), 'was a success',"update and get status message");
is($transaction->get('taxes'), 7, 'update does not modify things it was not sent');
is($transaction->isSuccessful, 1,"update and get isSuccessful");
is($transaction->transactionCode, 'yyy',"update and get transaction code");
is($transaction->statusCode, 'jd31',"update and get status code");
is($transaction->statusMessage, 'was a success',"update and get status message");
is($transaction->taxes, 7, 'update does not modify things it was not sent');
# make sure new() works
my $tcopy = WebGUI::Shop::Transaction->new($session, $transaction->getId);
@ -127,6 +131,7 @@ my $item = $transaction->addItem({
assetId => 'a',
configuredTitle => 'b',
options => {color=>'blue'},
shippingOrganization => 'organized',
shippingAddressId => 'c',
shippingName => 'd',
shippingAddress1 => 'e',
@ -161,6 +166,7 @@ is($item->get("shippingPhoneNumber"), 'l', "set and get shipping phone number");
is($item->get("quantity"), 5, "set and get quantity");
is($item->get("price"), 33, "set and get price");
is($item->get('taxRate'), 19, 'set and get taxRate' );
is($item->shippingOrganization, 'organized', 'set and get shipping organization' );
$item->update({
shippingTrackingNumber => 'adfs',
@ -279,6 +285,50 @@ $session->setting->set('shopReceiptEmailTemplateId', $templateId);
like($templateVars[1]->{viewDetailUrl}, qr/shop=transaction;method=view;/ , '... viewDetailUrl okay for admin');
}
#######################################################################
#
# formatAddress
#
#######################################################################
my $formattedAddress = $transaction->formatAddress({
name => 'Red',
address1 => 'Cell Block #5',
city => 'Shawshank',
state => 'MN',
code => 55555,
country => 'USA',
phoneNumber => '555.555.5555',
});
is_string $formattedAddress, 'Red<br />Cell Block #5<br />Shawshank, MN 55555<br />USA<br />555.555.5555', 'formatAddress: a regular address';
my $formattedAddress = $transaction->formatAddress({
name => 'Red',
address1 => 'Cell Block #5',
address2 => 'Next to Andy',
city => 'Shawshank',
state => 'MN',
code => 55555,
country => 'USA',
phoneNumber => '555.555.5555',
});
is_string $formattedAddress, 'Red<br />Cell Block #5<br />Next to Andy<br />Shawshank, MN 55555<br />USA<br />555.555.5555', '... a regular address with address2';
my $formattedAddress = $transaction->formatAddress({
name => 'Red',
organization => 'Shawshank Prison',
address1 => 'Cell Block #5',
city => 'Shawshank',
state => 'MN',
code => 55555,
country => 'USA',
phoneNumber => '555.555.5555',
});
is_string $formattedAddress, 'Red<br />Shawshank Prison<br />Cell Block #5<br />Shawshank, MN 55555<br />USA<br />555.555.5555', '... a regular address with address2';
#######################################################################
#
# delete

136
t/Shop/TransactionItem.t Normal file
View file

@ -0,0 +1,136 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use Test::Exception;
use Test::MockObject::Extends;
use WebGUI::Test; # Must use this before any other WebGUI modules
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;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
$session->user({userId => 3});
#----------------------------------------------------------------------------
# Tests
plan tests => 8;
#----------------------------------------------------------------------------
# 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 $versionTag = WebGUI::VersionTag->getWorking($session);
my $home = WebGUI::Asset->getDefault($session);
my $rockHammer = $home->addChild({
className => 'WebGUI::Asset::Sku::Product',
isShippingRequired => 0, title => 'Rock Hammers',
shipsSeparately => 0,
});
my $smallHammer = $rockHammer->setCollateral('variantsJSON', 'variantId', 'new',
{
shortdesc => 'Small rock hammer', price => 7.50,
varSku => 'small-hammer', weight => 1.5,
quantity => 9999,
}
);
my $foreignHammer = $rockHammer->setCollateral('variantsJSON', 'variantId', 'new',
{
shortdesc => '錘', price => 7.00,
varSku => 'foreigh-hammer', weight => 1.0,
quantity => 9999,
}
);
$versionTag->commit;
$cart->update({gatewayId => 'gzUxkEZJxREF9JpylOg2zw',}); ##Cash checkout
my $transaction = WebGUI::Shop::Transaction->new($session, {
cart => $cart,
isRecurring => $cart->requiresRecurringPayment,
});
##Block sending emails and inbox messages on this transation
$transaction = Test::MockObject::Extends->new($transaction);
$transaction->set_true('sendNotifications');
WebGUI::Test->addToCleanup($versionTag, $transaction);
my $credit = WebGUI::Shop::Credit->new($session, '3');
WebGUI::Test->addToCleanup(sub { $credit->purge });
my $hammer2 = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $foreignHammer));
my $transactionItem = $transaction->addItem({ item => $hammer2 });
$transaction->update({isSuccessful => 1});
$transactionItem->update({orderStatus => 'Cancelled'});
$transactionItem->issueCredit;
is $credit->getSum, '0.00', 'issueCredit fails if the item is Cancelled';
$transactionItem->update({orderStatus => 'Shipped'});
$transactionItem->issueCredit;
is $credit->getSum, '7.00', '... succeeds if the item is not Cancelled';
is $transactionItem->get('orderStatus'), 'Cancelled', '... item status updated to Cancelled';
$transaction->update({isSuccessful => 0});
$transactionItem->update({orderStatus => 'Not Shipped'});
$transactionItem->issueCredit;
is $credit->getSum, '7.00', 'issueCredit is unchanged when the transaction is not successful';
is $transactionItem->get('orderStatus'), 'Not Shipped', '... item status unchanged';
$transaction->update({isSuccessful => 1});
$transactionItem->update({orderStatus => 'Shipped'});
$rockHammer->purge;
lives_ok { $transactionItem->issueCredit } 'issueCredit does not die if the asset does not exist';
is $credit->getSum, '14.00', '... credit is still issued';
is $transactionItem->get('orderStatus'), 'Cancelled', '... item status still updated';
#vim:ft=perl