Merge commit '17ce3572bf' into WebGUI8. All tests passing.
This commit is contained in:
commit
5e502fee53
117 changed files with 2012 additions and 1027 deletions
|
|
@ -301,3 +301,4 @@ $session->user({user => $dude});
|
|||
is($dt->epochToHuman($wgbday), '8/16/2001 9:00 pm', 'epochToHuman: constructs a default locale if the language does not provide one.');
|
||||
$session->user({userId => 1});
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ my $session = WebGUI::Test->session;
|
|||
####################################################
|
||||
|
||||
my $origToolbar = $session->user->profileField('toolbar');
|
||||
WebGUI::Test->addToCleanup(sub { $session->user->profileField('toolbar', $origToolbar); },);
|
||||
my $toolbars = $session->url->extras('toolbar/');
|
||||
|
||||
my $request = $session->request;
|
||||
|
|
@ -167,12 +168,6 @@ sub linkAndText {
|
|||
return @parsedParams;
|
||||
}
|
||||
|
||||
my $icon = $session->icon->drag();
|
||||
|
||||
END {
|
||||
$session->user->profileField('toolbar', $origToolbar);
|
||||
}
|
||||
|
||||
sub fetchTestSet {
|
||||
return (
|
||||
{
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ my $session = WebGUI::Test->session;
|
|||
my $privilege = $session->privilege;
|
||||
|
||||
my ($versionTag, $userTemplate) = setup_assets($session);
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
|
||||
isa_ok($privilege, 'WebGUI::Session::Privilege', 'session has correct object type');
|
||||
|
||||
|
|
@ -135,9 +136,4 @@ sub setup_assets {
|
|||
return ($versionTag, $userTemplate);
|
||||
}
|
||||
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -1,140 +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;
|
||||
|
||||
##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');
|
||||
|
||||
END {
|
||||
$session->scratch->deleteAll;
|
||||
foreach my $wgSess ($newSession, @sessionBank) {
|
||||
if (defined $wgSess and ref $wgSess eq 'WebGUI::Session') {
|
||||
note "Closing session";
|
||||
$wgSess->scratch->deleteAll;
|
||||
$wgSess->var->end;
|
||||
$wgSess->close;
|
||||
}
|
||||
}
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -80,3 +80,4 @@ is( $session->stow->get( 'possibilities', { noclone => 1 } ), $arr,
|
|||
"With noclone returns same reference"
|
||||
);
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ is($macroOutput, 1, 'generateAdditionalHeadTags: process a macro');
|
|||
####################################################
|
||||
|
||||
my ($versionTag, $templates, $article, $snippet) = setup_assets($session);
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
|
||||
$style->sent(0);
|
||||
is($style->sent, 0, 'process: setup sent to 0');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue