kivitendo/t/Support/TestSetup.pm @ bc08036a
1d64d7e5 | Sven Schöling | package Support::TestSetup;
|
||
use strict;
|
||||
use Data::Dumper;
|
||||
use CGI qw( -no_xhtml);
|
||||
use SL::Auth;
|
||||
use SL::Form;
|
||||
use SL::Locale;
|
||||
use SL::LXDebug;
|
||||
use Data::Dumper;
|
||||
dac8a136 | Moritz Bunkus | use SL::Layout::None;
|
||
1d64d7e5 | Sven Schöling | use SL::LxOfficeConf;
|
||
use SL::InstanceConfiguration;
|
||||
dac8a136 | Moritz Bunkus | use SL::Request;
|
||
1d64d7e5 | Sven Schöling | |||
sub _login {
|
||||
my $login = shift;
|
||||
die 'need login' unless $login;
|
||||
package main;
|
||||
5b4b9d4b | Sven Schöling | $::lxdebug = LXDebug->new(target => LXDebug::STDERR_TARGET);
|
||
$::lxdebug->disable_sub_tracing;
|
||||
1d64d7e5 | Sven Schöling | $::locale = Locale->new($::lx_office_conf{system}->{language});
|
||
$::form = Form->new;
|
||||
$::auth = SL::Auth->new;
|
||||
$::instance_conf = SL::InstanceConfiguration->new;
|
||||
dac8a136 | Moritz Bunkus | $::request = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
|
||
1d64d7e5 | Sven Schöling | |||
die 'cannot reach auth db' unless $::auth->session_tables_present;
|
||||
$::auth->restore_session;
|
||||
require "bin/mozilla/common.pl";
|
||||
4531a6c7 | Sven Schöling | die "cannot find user $login" unless %::myconfig = $::auth->read_user(login => $login);
|
||
1d64d7e5 | Sven Schöling | |||
$::form->{login} = $login; # normaly implicit at login
|
||||
die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode});
|
||||
$::instance_conf->init;
|
||||
return 1;
|
||||
}
|
||||
sub login {
|
||||
fef4ba5a | Sven Schöling | SL::LxOfficeConf->read;
|
||
1d64d7e5 | Sven Schöling | my $login = shift || $::lx_office_conf{testing}{login} || 'demo';
|
||
_login($login);
|
||||
}
|
||||
1;
|