session var tests working and a few more bug fixes
This commit is contained in:
parent
4487a7a8c7
commit
fc16c9ce95
3 changed files with 56 additions and 4 deletions
|
|
@ -76,7 +76,7 @@ Deletes all scratch variables for this session.
|
|||
sub deleteAll {
|
||||
my $self = shift;
|
||||
delete $self->{_data};
|
||||
$self->session->db->write("delete from userSessionScratch where sessionId=".quote($self->{_sessionId}));
|
||||
$self->session->db->write("delete from userSessionScratch where sessionId=".$self->session->db->quote($self->{_sessionId}));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ sub deleteName {
|
|||
my $name = shift;
|
||||
return undef unless ($name);
|
||||
delete $self->{_data}{$name};
|
||||
$self->session->db->write("delete from userSessionScratch where name=".quote($name));
|
||||
$self->session->db->write("delete from userSessionScratch where name=".$self->session->db->quote($name));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ Removes the specified user session from memory and database.
|
|||
sub end {
|
||||
my $self = shift;
|
||||
$self->session->scratch->deleteAll;
|
||||
$self->delete;
|
||||
$self->session->db->write("delete from userSession where sessionId=".$self->session->db->quote($self->getId));
|
||||
delete $self->session->{_user};
|
||||
$self->DESTROY;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ sub isAdminOn {
|
|||
|
||||
=head2 new ( session )
|
||||
|
||||
Constructor. Returns a stow object.
|
||||
Constructor. Returns a var object.
|
||||
|
||||
=head3 session
|
||||
|
||||
|
|
|
|||
52
t/Session_Var.t
Normal file
52
t/Session_Var.t
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# ---- BEGIN DO NOT EDIT ----
|
||||
use strict;
|
||||
use lib '../lib';
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
# ---- END DO NOT EDIT ----
|
||||
use Test::More tests => 6; # increment this value for each test you create
|
||||
|
||||
my $session = initialize(); # this line is required
|
||||
|
||||
# put your tests here
|
||||
use WebGUI::Session::Var;
|
||||
|
||||
ok($session->var->getId ne "", "getId()");
|
||||
ok($session->var->get("lastPageView") > 0, "get()");
|
||||
is($session->var->isAdminOn, 0, "isAdminOn()");
|
||||
$session->var->switchAdminOn;
|
||||
is($session->var->isAdminOn, 1, "switchAdminOn()");
|
||||
$session->var->switchAdminOff;
|
||||
is($session->var->isAdminOn, 0, "switchAdminOff()");
|
||||
my $id = $session->var->getId;
|
||||
$session->var->end;
|
||||
my ($count) = $session->db->quickArray("select count(*) from userSession where sessionId=".$session->db->quote($id));
|
||||
ok($count == 0,"end()");
|
||||
|
||||
|
||||
cleanup($session); # this line is required
|
||||
|
||||
# ---- DO NOT EDIT BELOW THIS LINE -----
|
||||
sub initialize {
|
||||
$|=1; # disable output buffering
|
||||
my $configFile;
|
||||
GetOptions(
|
||||
'configFile=s'=>\$configFile
|
||||
);
|
||||
exit 1 unless ($configFile);
|
||||
my $session = WebGUI::Session->open("..",$configFile);
|
||||
}
|
||||
sub cleanup {
|
||||
my $session = shift;
|
||||
$session->close();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue