webgui/t/Session.t
Colin Kuskie ac6116b7a0 Added a dbSlave test to Session.t. It's kind of a hack as it sets up
a slave reference back to the original db from the config.
Bug fixes for the TrashClipboard workflow activity.  The dates were off,
since the interval returns an epoch, and the call to Asset->new didn't
have the session.
2007-03-02 16:51:49 +00:00

68 lines
1.9 KiB
Perl

#-------------------------------------------------------------------
# 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
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::User;
use Test::More;
plan tests => 2; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $user = WebGUI::User->new($session, "new");
$session->user({user => $user});
my ($userId) = $session->db->quickArray("select userId from userSession where sessionId=?",[$session->getId]);
is($userId, $user->userId, 'changing session user changes sessionId inside userSession table');
################################################################
#
# dbSlave
#
################################################################
##Manually build one dbSlave in the config file to use
my $slaveHash2 = {
dsn => $session->config->get('dsn'),
user => $session->config->get('dbuser'),
pass => $session->config->get('dbpass'),
};
my $slaveHash1 = {
dsn => $session->config->get('dsn').';host=192.168.104.202',
user => $session->config->get('dbuser'),
pass => $session->config->get('dbpass'),
};
diag $slaveHash1->{dsn};
$session->config->set('dbslave2', $slaveHash2);
$session->config->set('dbslave1', $slaveHash1);
my $slave2 = $session->dbSlave;
isa_ok($slave2, 'WebGUI::SQL');
END {
foreach my $dude ($user) {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}
$session->config->delete('dbslave2');
$session->config->delete('dbslave1');
}