]> wagnertech.de Git - mfinanz.git/blobdiff - t/Support/TestSetup.pm
Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[mfinanz.git] / t / Support / TestSetup.pm
index c23b4fd7fb2311caa759b18d40989255d80a5846..2fbbd2d5fe409c19b80212c620fdc774ca5f3f6d 100644 (file)
@@ -9,23 +9,27 @@ use SL::Form;
 use SL::Locale;
 use SL::LXDebug;
 use Data::Dumper;
+use SL::Layout::None;
 use SL::LxOfficeConf;
 use SL::InstanceConfiguration;
-SL::LxOfficeConf->read;
+use SL::Request;
 
 sub _login {
-  my $login = shift;
+  my ($client, $login) = @_;
 
-  die 'need login' unless $login;
+  die 'need client and login' unless $client && $login;
 
   package main;
 
-  $::lxdebug       = LXDebug->new(file => \*STDERR);
+  $::lxdebug       = LXDebug->new(target => LXDebug::STDERR_TARGET);
+  $::lxdebug->disable_sub_tracing;
   $::locale        = Locale->new($::lx_office_conf{system}->{language});
   $::form          = Form->new;
   $::auth          = SL::Auth->new;
+  die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);
+
   $::instance_conf = SL::InstanceConfiguration->new;
-  $::request       = { cgi => CGI->new({}) };
+  $::request       = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
 
   die 'cannot reach auth db'               unless $::auth->session_tables_present;
 
@@ -33,7 +37,7 @@ sub _login {
 
   require "bin/mozilla/common.pl";
 
-  die "cannot find user $login"            unless %::myconfig = $::auth->read_user($login);
+  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
 
   $::form->{login} = $login; # normaly implicit at login
 
@@ -45,8 +49,11 @@ sub _login {
 }
 
 sub login {
+  SL::LxOfficeConf->read;
+
   my $login        = shift || $::lx_office_conf{testing}{login}        || 'demo';
-  _login($login);
+  my $client        = shift || $::lx_office_conf{testing}{client}      || '';
+  _login($client, $login);
 }
 
 1;