diff --git a/lib/WebGUI/Session/Scratch.pm b/lib/WebGUI/Session/Scratch.pm index d9e222fdd..9feca8352 100644 --- a/lib/WebGUI/Session/Scratch.pm +++ b/lib/WebGUI/Session/Scratch.pm @@ -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)); } diff --git a/lib/WebGUI/Session/Var.pm b/lib/WebGUI/Session/Var.pm index 8b49f2a8d..08df8a1c6 100644 --- a/lib/WebGUI/Session/Var.pm +++ b/lib/WebGUI/Session/Var.pm @@ -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 diff --git a/t/Session_Var.t b/t/Session_Var.t new file mode 100644 index 000000000..18f48c10c --- /dev/null +++ b/t/Session_Var.t @@ -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(); +}