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:
commit
708b47d73c
165 changed files with 3199 additions and 5718 deletions
|
|
@ -185,9 +185,9 @@ sub testCount {
|
|||
plan tests => testCount() ;
|
||||
|
||||
foreach my $testSet (@testArray) {
|
||||
$session->request->env->{HTTP_USER_AGENT} = $testSet->{agent};
|
||||
$session->request->headers->user_agent($testSet->{agent});
|
||||
$session->request->env->{REMOTE_ADDR} = $testSet->{address} || '69.42.78.32';
|
||||
my $output = $session->env->requestNotViewed;
|
||||
my $output = $session->request->requestNotViewed;
|
||||
is($output, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 2; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
||||
cmp_ok($session->env->get("REMOTE_ADDR"), 'ne', "", "get() one valid entry");
|
||||
|
||||
my $env = $session->env;
|
||||
$session->request->env->{REMOTE_ADDR} = '192.168.0.2';
|
||||
is ($env->getIp, '192.168.0.2', 'getIp');
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ WebGUI::Test->interceptLogging( sub {
|
|||
is($log_data->{warn}, "Second warning", "warn: Log4perl called again");
|
||||
$eh->security('Shields up, red alert');
|
||||
my $security = sprintf '%s (%d) connecting from %s attempted to %s',
|
||||
$session->user->username, $session->user->userId, $session->env->getIp, 'Shields up, red alert';
|
||||
$session->user->username, $session->user->userId, $session->request->address, 'Shields up, red alert';
|
||||
is($log_data->{warn}, $security, 'security: calls warn with username, userId and IP address');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,132 +1,133 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 62; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $scratch = $session->scratch;
|
||||
my $maxCount = 10;
|
||||
|
||||
$scratch->deleteAll();
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
$scratch->set("Test$count",$count);
|
||||
}
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
is($scratch->get("Test$count"), $count, "Passed set/get $count");
|
||||
}
|
||||
|
||||
is($scratch->delete("nonExistantVariable"), undef, 'delete returns value if deleted, otherwise undef');
|
||||
is($scratch->delete("Test1"), 1, 'delete returns number deleted');
|
||||
is($scratch->delete(), undef, 'delete without name of variable to delete returns undef');
|
||||
is($scratch->get("Test1"), undef, "delete()");
|
||||
|
||||
$scratch->deleteAll;
|
||||
is($scratch->get("Test2"), undef, "deleteAll()");
|
||||
|
||||
my $testScratchSession = $scratch->session();
|
||||
|
||||
is($testScratchSession, $session, "session()");
|
||||
|
||||
##Build some variables to test database persistency
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
$scratch->set("dBase$count",$count);
|
||||
my ($setValue) = $session->db->quickArray("select value from userSessionScratch where sessionId=? and name=?",[$session->getId, "dBase$count"]);
|
||||
is($setValue, $count, "database store for set on $count");
|
||||
}
|
||||
|
||||
##Creating a new session with the previous session's Id should clone the scratch data
|
||||
my $newSession = WebGUI::Session->open(WebGUI::Test->file, undef, $session->getId);
|
||||
|
||||
is($newSession->getId, $session->getId, "Successful session duplication");
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
is($newSession->scratch->get("dBase$count"), $count, "Passed set/get $count");
|
||||
}
|
||||
|
||||
$scratch->set("dBase5", 15);
|
||||
|
||||
my ($changedValue) = $session->db->quickArray("select value from userSessionScratch where sessionId=? and name=?",[$session->getId, "dBase5"]);
|
||||
is($changedValue, 15, "changing stored scratch value");
|
||||
is($scratch->get("dBase5"), 15, "checking cached scratch value");
|
||||
|
||||
$newSession->scratch->deleteAll;
|
||||
$newSession->close;
|
||||
|
||||
is($scratch->set('retVal',2), 1, 'set returns number of rows affected');
|
||||
is($scratch->set(), undef, 'set returns undef unless it gets a name');
|
||||
is($scratch->set('','value'), undef, 'set returns undef unless it gets a name even if there is a value');
|
||||
|
||||
############################################
|
||||
#
|
||||
# Multi-session deleting
|
||||
#
|
||||
############################################
|
||||
|
||||
my @sessionBank = map { WebGUI::Session->open(WebGUI::Test->file) } 0..3;
|
||||
|
||||
WebGUI::Test->addToCleanup(@sessionBank);
|
||||
|
||||
##Set variables to be deleted by name
|
||||
foreach my $i (0..3) {
|
||||
$sessionBank[$i]->scratch->set('deletableName', $i);
|
||||
}
|
||||
##Set variables to be deleted by name and value
|
||||
$sessionBank[0]->scratch->set('deletableValue', 'a');
|
||||
$sessionBank[1]->scratch->set('deletableValue', 'a');
|
||||
$sessionBank[2]->scratch->set('deletableValue', 'b');
|
||||
$sessionBank[2]->scratch->set('falseValue', '');
|
||||
$sessionBank[3]->scratch->set('deletableValue', 'c');
|
||||
$sessionBank[3]->scratch->set('falseValue', '0');
|
||||
|
||||
is($scratch->deleteName(), undef, 'deleteName without name of variable to delete returns undef');
|
||||
is($sessionBank[2]->scratch->deleteName("deletableName"), 4, 'deleteName returns number of elements deleted');
|
||||
is($sessionBank[2]->scratch->get("deletableName"), undef, 'deleteName clears session cached in the object that calls it');
|
||||
is($sessionBank[1]->scratch->get('deletableName'), 1, "deleteName does not change session cached vriables");
|
||||
my ($entries) = $session->db->quickArray("select count(name) from userSessionScratch where name=?",['deletableName']);
|
||||
is($entries, 0, "deleteName deletes entries in the database");
|
||||
|
||||
is($sessionBank[1]->scratch->deleteNameByValue('deletableValue', 'a'), 2, 'deleteNameByValue deleted two rows');
|
||||
($entries) = $session->db->quickArray("select count(name) from userSessionScratch where name=?",['deletableValue']);
|
||||
is($entries, 2, "deleteNameByValue deleted entries in the database");
|
||||
is($sessionBank[1]->scratch->get('deletableValue'), undef, 'deleteNameByValue removes session cache in object that called it...');
|
||||
is($sessionBank[0]->scratch->get('deletableValue'), 'a', 'but not in any other object whose database entry was cleared');
|
||||
cmp_bag($session->db->buildArrayRef('select value from userSessionScratch where name=?',['deletableValue']), ['b', 'c'], 'deleteNameByValue values that were not deleted');
|
||||
|
||||
is($sessionBank[2]->scratch->deleteNameByValue('deletableValue', 'c'), 1, 'deleteNameByValue deleted one row');
|
||||
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('',35), undef, 'deleteNameByValue requires a NAME');
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('scratch'), undef, 'deleteNameByValue requires a value');
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('',''), undef, 'deleteNameByValue require a NAME and a VALUE');
|
||||
is($sessionBank[3]->scratch->deleteNameByValue('falseValue','0'), 1, 'deleteNameByValue will delete values that are false (0)');
|
||||
is($sessionBank[2]->scratch->deleteNameByValue('falseValue',''), 1, "deleteNameByValue will delete values that are false ('')");
|
||||
|
||||
$scratch->setLanguageOverride('English');
|
||||
is($scratch->getLanguageOverride, 'English', 'session scratch language is not correctly set');
|
||||
$scratch->removeLanguageOverride;
|
||||
is($scratch->getLanguageOverride, undef, 'The session scratch variable language is not removed');
|
||||
$scratch->setLanguageOverride('myimmaginarylanguagethatisnotinstalled');
|
||||
is($scratch->getLanguageOverride, undef, 'A non-existing language is set');
|
||||
$scratch->setLanguageOverride('English');
|
||||
$scratch->setLanguageOverride();
|
||||
is($scratch->getLanguageOverride, 'English', 'A empty string is falsely recognised as a language');
|
||||
|
||||
#vim:ft=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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 62; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $scratch = $session->scratch;
|
||||
my $maxCount = 10;
|
||||
|
||||
$scratch->deleteAll();
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
$scratch->set("Test$count",$count);
|
||||
}
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
is($scratch->get("Test$count"), $count, "Passed set/get $count");
|
||||
}
|
||||
|
||||
is($scratch->delete("nonExistantVariable"), undef, 'delete returns value if deleted, otherwise undef');
|
||||
is($scratch->delete("Test1"), 1, 'delete returns number deleted');
|
||||
is($scratch->delete(), undef, 'delete without name of variable to delete returns undef');
|
||||
is($scratch->get("Test1"), undef, "delete()");
|
||||
|
||||
$scratch->deleteAll;
|
||||
is($scratch->get("Test2"), undef, "deleteAll()");
|
||||
|
||||
my $testScratchSession = $scratch->session();
|
||||
|
||||
is($testScratchSession, $session, "session()");
|
||||
|
||||
##Build some variables to test database persistency
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
$scratch->set("dBase$count",$count);
|
||||
my ($setValue) = $session->db->quickArray("select value from userSessionScratch where sessionId=? and name=?",[$session->getId, "dBase$count"]);
|
||||
is($setValue, $count, "database store for set on $count");
|
||||
}
|
||||
|
||||
##Creating a new session with the previous session's Id should clone the scratch data
|
||||
my $newSession = WebGUI::Session->open(WebGUI::Test->file, undef, $session->getId);
|
||||
WebGUI::Test->addToCleanup($newSession);
|
||||
|
||||
is($newSession->getId, $session->getId, "Successful session duplication");
|
||||
|
||||
for (my $count = 1; $count <= $maxCount; $count++){
|
||||
is($newSession->scratch->get("dBase$count"), $count, "Passed set/get $count");
|
||||
}
|
||||
|
||||
$scratch->set("dBase5", 15);
|
||||
|
||||
my ($changedValue) = $session->db->quickArray("select value from userSessionScratch where sessionId=? and name=?",[$session->getId, "dBase5"]);
|
||||
is($changedValue, 15, "changing stored scratch value");
|
||||
is($scratch->get("dBase5"), 15, "checking cached scratch value");
|
||||
|
||||
$newSession->scratch->deleteAll;
|
||||
$newSession->close;
|
||||
|
||||
is($scratch->set('retVal',2), 1, 'set returns number of rows affected');
|
||||
is($scratch->set(), undef, 'set returns undef unless it gets a name');
|
||||
is($scratch->set('','value'), undef, 'set returns undef unless it gets a name even if there is a value');
|
||||
|
||||
############################################
|
||||
#
|
||||
# Multi-session deleting
|
||||
#
|
||||
############################################
|
||||
|
||||
my @sessionBank = map { WebGUI::Session->open(WebGUI::Test->file) } 0..3;
|
||||
|
||||
WebGUI::Test->addToCleanup(@sessionBank);
|
||||
|
||||
##Set variables to be deleted by name
|
||||
foreach my $i (0..3) {
|
||||
$sessionBank[$i]->scratch->set('deletableName', $i);
|
||||
}
|
||||
##Set variables to be deleted by name and value
|
||||
$sessionBank[0]->scratch->set('deletableValue', 'a');
|
||||
$sessionBank[1]->scratch->set('deletableValue', 'a');
|
||||
$sessionBank[2]->scratch->set('deletableValue', 'b');
|
||||
$sessionBank[2]->scratch->set('falseValue', '');
|
||||
$sessionBank[3]->scratch->set('deletableValue', 'c');
|
||||
$sessionBank[3]->scratch->set('falseValue', '0');
|
||||
|
||||
is($scratch->deleteName(), undef, 'deleteName without name of variable to delete returns undef');
|
||||
is($sessionBank[2]->scratch->deleteName("deletableName"), 4, 'deleteName returns number of elements deleted');
|
||||
is($sessionBank[2]->scratch->get("deletableName"), undef, 'deleteName clears session cached in the object that calls it');
|
||||
is($sessionBank[1]->scratch->get('deletableName'), 1, "deleteName does not change session cached vriables");
|
||||
my ($entries) = $session->db->quickArray("select count(name) from userSessionScratch where name=?",['deletableName']);
|
||||
is($entries, 0, "deleteName deletes entries in the database");
|
||||
|
||||
is($sessionBank[1]->scratch->deleteNameByValue('deletableValue', 'a'), 2, 'deleteNameByValue deleted two rows');
|
||||
($entries) = $session->db->quickArray("select count(name) from userSessionScratch where name=?",['deletableValue']);
|
||||
is($entries, 2, "deleteNameByValue deleted entries in the database");
|
||||
is($sessionBank[1]->scratch->get('deletableValue'), undef, 'deleteNameByValue removes session cache in object that called it...');
|
||||
is($sessionBank[0]->scratch->get('deletableValue'), 'a', 'but not in any other object whose database entry was cleared');
|
||||
cmp_bag($session->db->buildArrayRef('select value from userSessionScratch where name=?',['deletableValue']), ['b', 'c'], 'deleteNameByValue values that were not deleted');
|
||||
|
||||
is($sessionBank[2]->scratch->deleteNameByValue('deletableValue', 'c'), 1, 'deleteNameByValue deleted one row');
|
||||
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('',35), undef, 'deleteNameByValue requires a NAME');
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('scratch'), undef, 'deleteNameByValue requires a value');
|
||||
is($sessionBank[0]->scratch->deleteNameByValue('',''), undef, 'deleteNameByValue require a NAME and a VALUE');
|
||||
is($sessionBank[3]->scratch->deleteNameByValue('falseValue','0'), 1, 'deleteNameByValue will delete values that are false (0)');
|
||||
is($sessionBank[2]->scratch->deleteNameByValue('falseValue',''), 1, "deleteNameByValue will delete values that are false ('')");
|
||||
|
||||
$scratch->setLanguageOverride('English');
|
||||
is($scratch->getLanguageOverride, 'English', 'session scratch language is not correctly set');
|
||||
$scratch->removeLanguageOverride;
|
||||
is($scratch->getLanguageOverride, undef, 'The session scratch variable language is not removed');
|
||||
$scratch->setLanguageOverride('myimmaginarylanguagethatisnotinstalled');
|
||||
is($scratch->getLanguageOverride, undef, 'A non-existing language is set');
|
||||
$scratch->setLanguageOverride('English');
|
||||
$scratch->setLanguageOverride();
|
||||
is($scratch->getLanguageOverride, 'English', 'A empty string is falsely recognised as a language');
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ my @getRefererUrlTests = (
|
|||
);
|
||||
|
||||
use Test::More;
|
||||
use Test::MockObject::Extends;
|
||||
plan tests => 84 + scalar(@getRefererUrlTests);
|
||||
plan tests => 82 + scalar(@getRefererUrlTests);
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $request = $session->request;
|
||||
|
|
@ -258,12 +257,8 @@ $session->asset($sessionAsset);
|
|||
#
|
||||
#######################################
|
||||
|
||||
$env->{'HTTP_REFERER'} = 'test';
|
||||
|
||||
is($session->env->get('HTTP_REFERER'), 'test', 'testing overridden ENV');
|
||||
|
||||
foreach my $test (@getRefererUrlTests) {
|
||||
$env->{HTTP_REFERER} = $test->{input};
|
||||
$session->request->referer($test->{input});
|
||||
is($session->url->getRefererUrl, $test->{output}, $test->{comment});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue