Merge commit '4635b91554' into WebGUI8. Syntax clean up to 7.10.2
This commit is contained in:
commit
87326192a3
46 changed files with 956 additions and 969 deletions
|
|
@ -127,24 +127,6 @@ isnt($event6a->get('storageId'), $event6->get('storageId'), '... and it is diffe
|
|||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->addToCleanup($versionTag2);
|
||||
$versionTag2->commit;
|
||||
|
||||
my $event7 = $cal->addChild(
|
||||
{
|
||||
className => 'WebGUI::Asset::Event',
|
||||
assetId => 'EventAssetTestStorage6',
|
||||
url => 'hidden_event',
|
||||
}, undef, undef, { skipNotifications => 1, skipAutoCommitWorkflows => 1 },
|
||||
);
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
addToCleanup($tag);
|
||||
|
||||
is $event7->isHidden, 1, 'isHidden set to 1 by default';
|
||||
|
||||
$event7->isHidden(0);
|
||||
is $event7->isHidden, 1, 'isHidden cannot be set to 0';
|
||||
|
||||
my $event7 = $cal->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
use strict;
|
||||
|
||||
use WebGUI::Test;
|
||||
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::File::ZipArchive;
|
||||
|
||||
use WebGUI::Test;
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
plan tests => 3;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use WebGUI::Session;
|
|||
use WebGUI::Asset::Template;
|
||||
use Exception::Class;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use Test::Exception;
|
||||
|
|
|
|||
67
t/Asset/Wobject/WikiMaster/search.t
Normal file
67
t/Asset/Wobject/WikiMaster/search.t
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Test the featured page of the Wiki
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $import = WebGUI::Asset->getImportNode( $session );
|
||||
|
||||
my $templateId = 'WIKIMASTER_TEMPLATE___';
|
||||
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
my $wiki
|
||||
= $import->addChild( {
|
||||
className => 'WebGUI::Asset::Wobject::WikiMaster',
|
||||
searchTemplateId => $templateId,
|
||||
} );
|
||||
|
||||
WebGUI::Test->addToCleanup($wiki);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 1; # Increment this number for each test you create
|
||||
|
||||
$session->request->setup_body({
|
||||
query => 'Red&Andy',
|
||||
});
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$wiki->www_search();
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
is $templateVars->{addPageUrl},
|
||||
$wiki->getUrl('func=add;class=WebGUI::Asset::WikiPage;title=Red%26Andy'),
|
||||
'search encodes unsafe characters in addPageUrl';
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
#vim:ft=perl
|
||||
42
t/Auth.t
42
t/Auth.t
|
|
@ -43,7 +43,26 @@ my $createAccountSession = WebGUI::Test->newSession(0, {
|
|||
$auth = WebGUI::Auth->new( $createAccountSession, $AUTH_METHOD );
|
||||
my $username = $createAccountSession->id->generate;
|
||||
push @cleanupUsernames, $username;
|
||||
$output = $auth->createAccountSave( $username, { }, "PASSWORD" );
|
||||
$output = $auth->createAccountSave( $username, { }, "PASSWORD" );
|
||||
WebGUI::Test->addToCleanup(sub {
|
||||
for my $username ( @cleanupUsernames ) {
|
||||
# We don't create actual, real users, so we have to cleanup by hand
|
||||
my $userId = $session->db->quickScalar(
|
||||
"SELECT userId FROM users WHERE username=?",
|
||||
[ $username ]
|
||||
);
|
||||
|
||||
my @tableList
|
||||
= qw{authentication users userProfileData groupings inbox userLoginLog};
|
||||
|
||||
for my $table ( @tableList ) {
|
||||
$session->db->write(
|
||||
"DELETE FROM $table WHERE userId=?",
|
||||
[ $userId ]
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is(
|
||||
$createAccountSession->http->getRedirectLocation, 'REDIRECT_URL',
|
||||
|
|
@ -70,24 +89,3 @@ is(
|
|||
);
|
||||
is $output, undef, 'login returns undef when showMessageOnLogin is false';
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
for my $username ( @cleanupUsernames ) {
|
||||
# We don't create actual, real users, so we have to cleanup by hand
|
||||
my $userId = $session->db->quickScalar(
|
||||
"SELECT userId FROM users WHERE username=?",
|
||||
[ $username ]
|
||||
);
|
||||
|
||||
my @tableList
|
||||
= qw{authentication users userProfileData groupings inbox userLoginLog};
|
||||
|
||||
for my $table ( @tableList ) {
|
||||
$session->db->write(
|
||||
"DELETE FROM $table WHERE userId=?",
|
||||
[ $userId ]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ $output = WebGUI::Content::Asset::dispatch( $session );
|
|||
is $output, 'www_view one', 'an empty URL returns the default asset';
|
||||
$session->setting->set('defaultPage', $originalDefaultPage);
|
||||
|
||||
<<<<<<< HEAD
|
||||
#----------------------------------------------------------------------------
|
||||
# 304 Content Not Modified response
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ my $testBlock = [
|
|||
|
||||
my $formType = 'date';
|
||||
|
||||
my $numTests = 26 + scalar @{ $testBlock } ;
|
||||
my $numTests = 27 + scalar @{ $testBlock } ;
|
||||
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -79,7 +79,7 @@ is($input->name, 'TestDate', 'Checking input name');
|
|||
is($input->type, 'text', 'Checking input type');
|
||||
is(
|
||||
$input->value,
|
||||
WebGUI::DateTime->new($session, $defaultTime)->toMysqlDate,
|
||||
WebGUI::DateTime->new($session, $defaultTime)->set_time_zone($session->user->get('timeZone'))->toMysqlDate,
|
||||
"Checking default value"
|
||||
);
|
||||
is($input->{size}, 10, 'Checking size param, default');
|
||||
|
|
@ -143,7 +143,7 @@ is(
|
|||
$date2 = WebGUI::Form::Date->new($session, {defaultValue => '2008-008-001'});
|
||||
is(
|
||||
getValueFromForm($session, $date2->toHtml),
|
||||
'1970-01-01',
|
||||
'1969-12-31',
|
||||
"toHtml: defaultValue in bad mysql format returns date from epoch 0"
|
||||
);
|
||||
|
||||
|
|
@ -159,6 +159,18 @@ is($date2->getValueAsHtml(), '8/16/2001', "getValueAsHtml: defaultValue in mysql
|
|||
$date2 = WebGUI::Form::Date->new($session, {defaultValue => '2008-08-01', value => '2001-08-16', });
|
||||
is($date2->getValueAsHtml(), '2001-08-16', "getValueAsHtml: defaultValue in mysql format, value as mysql returns value in mysql format");
|
||||
|
||||
my $dutchie = WebGUI::User->create($session);
|
||||
WebGUI::Test->addToCleanup($dutchie);
|
||||
$dutchie->update({timeZone => 'Europe/Amsterdam', });
|
||||
$session->user({user => $dutchie});
|
||||
my $date_form = WebGUI::Form::Date->new($session, { name => 'test_date', });
|
||||
$session->request->setup_body({ test_date => '2001-08-16', });
|
||||
my $epochal_value = $date_form->getValue;
|
||||
|
||||
$date_form->set(value => $epochal_value);
|
||||
my $mysql_date = getValueFromForm($session, $date_form->toHtml);
|
||||
is $mysql_date, '2001-08-16', 'Form data processed and rendered round trip';
|
||||
|
||||
sub getValueFromForm {
|
||||
my ($session, $textForm) = @_;
|
||||
my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session));
|
||||
|
|
|
|||
142
t/Shop/Credit.t
Normal file
142
t/Shop/Credit.t
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 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 Data::Dumper;
|
||||
use JSON;
|
||||
use HTML::Form;
|
||||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::User;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 27;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# figure out if the test can actually run
|
||||
|
||||
my $e;
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# new
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
my $credit;
|
||||
my $credit_user = WebGUI::User->create($session);
|
||||
WebGUI::Test->addToCleanup($credit_user);
|
||||
|
||||
# Test incorrect for parameters
|
||||
|
||||
eval { $credit = WebGUI::Shop::Credit->new(); };
|
||||
$e = Exception::Class->caught();
|
||||
isa_ok ($e, 'WebGUI::Error::InvalidParam', 'new takes exception to not giving it a session object');
|
||||
cmp_deeply (
|
||||
$e,
|
||||
methods(
|
||||
error => 'Need a session.',
|
||||
),
|
||||
'new takes exception to not giving it a session object',
|
||||
);
|
||||
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session, $credit_user->userId); } 'new works with an explicit userId';
|
||||
can_ok($credit, qw/adjust purge getSum getLedger calculateDeduction session userId/);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# session
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
isa_ok ($credit->session, 'WebGUI::Session', 'session method returns a session object');
|
||||
is ($session->getId, $credit->session->getId, 'session method returns OUR session object');
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# userId
|
||||
#
|
||||
#######################################################################
|
||||
is ($credit->userId, $credit_user->userId, 'userId accessor returns the userId we set');
|
||||
|
||||
$session->user({userId => 3});
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session); } 'new works without an explicit userId';
|
||||
is $credit->userId, 3, '... by default, it uses the session user';
|
||||
|
||||
$session->user({userId => 1});
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session); } 'new works for visitor, too';
|
||||
|
||||
##Restore the original user for more testing
|
||||
$credit = WebGUI::Shop::Credit->new($session, $credit_user->userId);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# adjust, getSum, calculateDeduction
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
my $credit1 = WebGUI::Shop::Credit->new($session, 1);
|
||||
my $credit3 = WebGUI::Shop::Credit->new($session, 3);
|
||||
WebGUI::Test->addToCleanup(sub { $credit3->purge });
|
||||
WebGUI::Test->addToCleanup(sub { $credit->purge });
|
||||
|
||||
is $credit1->adjust(300, 'bonus for visitors'), 0, 'visitor cannot have credit';
|
||||
is $credit1->getSum, "0.00", 'getSum: Formatting and amount for Visitor';
|
||||
is $credit3->getSum, "0.00", '... for Admin';
|
||||
is $credit->getSum, "0.00", '... for credit user';
|
||||
|
||||
is $credit3->adjust(200, 'Admin never gets enough credit'), 200, 'Give Admin 200 credit';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin';
|
||||
is $credit->getSum, "0.00", '... for credit user';
|
||||
|
||||
is $credit->adjust(50, 'Refund'), 50, 'Give credit user 50 credit';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin, uniqueness check';
|
||||
is $credit->getSum, "50.00", '... for credit user';
|
||||
|
||||
is $credit->adjust(-10, 'Typo in original refund'), -10, 'Negative adustment';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin, uniqueness check';
|
||||
is $credit->getSum, "40.00", '... for credit user';
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# calculateDeduction
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
is $credit->calculateDeduction(10), "-10.00", 'calculateDeduction returns the max of either the amount';
|
||||
is $credit->calculateDeduction(80), "-40.00", '... or the available credit';
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# purge
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
$credit->purge;
|
||||
is $credit->getSum, "0.00", 'user credit purged';
|
||||
is $credit3->getSum, "200.00", '... but only for credit user';
|
||||
|
|
@ -22,8 +22,11 @@ use HTML::Form;
|
|||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shop::Cart;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::Shop::PayDriver;
|
||||
use Clone;
|
||||
use WebGUI::User;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -394,11 +397,14 @@ my $blue_widget = $widget->setCollateral('variantsJSON', 'variantId', 'new',
|
|||
);
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
$widget = $widget->cloneFromDb;
|
||||
|
||||
$session->user({userId => 3});
|
||||
my $credited_user = WebGUI::User->create($session);
|
||||
$session->user({user => $credited_user});
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
WebGUI::Test->addToCleanup($versionTag, $cart);
|
||||
WebGUI::Test->addToCleanup($versionTag, $cart, $credited_user);
|
||||
my $addressBook = $cart->getAddressBook;
|
||||
my $workAddress = $addressBook->addAddress({
|
||||
label => 'work',
|
||||
|
|
@ -432,6 +438,26 @@ cmp_deeply(
|
|||
'appendCartVariables: checking shippableItemsInCart and totalPrice & subtotal formatting'
|
||||
);
|
||||
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $credited_user->userId);
|
||||
$credit->adjust('1', 'credit for testing');
|
||||
$cart_variables = {};
|
||||
$driver->appendCartVariables($cart_variables);
|
||||
cmp_deeply(
|
||||
$cart_variables,
|
||||
{
|
||||
taxes => ignore(),
|
||||
shippableItemsInCart => 1,
|
||||
subtotal => '5.00',
|
||||
inShopCreditDeduction => '-1.00',
|
||||
inShopCreditAvailable => '1.00',
|
||||
totalPrice => '4.00',
|
||||
shipping => ignore(),
|
||||
|
||||
},
|
||||
'... checking credit display'
|
||||
);
|
||||
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# delete
|
||||
|
|
|
|||
3
t/User.t
3
t/User.t
|
|
@ -18,7 +18,7 @@ use WebGUI::User;
|
|||
use WebGUI::ProfileField;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
|
||||
use Test::More tests => 226; # increment this value for each test you create
|
||||
use Test::More tests => 225; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
|
|
@ -417,7 +417,6 @@ ok($user->isInGroup(3), "addToGroups: New user is in group 3(Admin)");
|
|||
ok($user->isInGroup(11), "New user is in group 11(Secondary Admins)");
|
||||
ok($user->isInGroup(12), "New user is in group 12(Turn On Admin)");
|
||||
ok($user->isInGroup(13), "New user is in group 13(Export Managers)");
|
||||
ok($user->isInGroup(14), "New user is in group 14(Product Managers)");
|
||||
|
||||
$user->deleteFromGroups([3]);
|
||||
ok(!$user->isInGroup(3), "deleteFromGroups: New user is not in group 3(Admin)");
|
||||
|
|
|
|||
|
|
@ -10,10 +10,6 @@
|
|||
|
||||
use File::Spec::Functions qw( catdir rel2abs );
|
||||
use File::Basename;
|
||||
use Test::Class;
|
||||
use Module::Find;
|
||||
use lib rel2abs( catdir ( dirname( __FILE__ ), 'tests' ) );
|
||||
|
||||
useall('Test::WebGUI::Form');
|
||||
use File::Basename qw( dirname );
|
||||
use Test::Class::Load rel2abs( catdir ( dirname( __FILE__ ), 'tests' ) );
|
||||
Test::Class->runtests;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue