X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/ff049c83e9cadde7be6b616390ec256cda6c40f6..83c97773d846f04f47d62b532e3e44b7917f9f96:/t/Support/TestSetup.pm diff --git a/t/Support/TestSetup.pm b/t/Support/TestSetup.pm index bd067d232..5a1e42fd1 100644 --- a/t/Support/TestSetup.pm +++ b/t/Support/TestSetup.pm @@ -15,18 +15,22 @@ use SL::LxOfficeConf; use SL::InstanceConfiguration; use SL::Request; -sub _login { - my ($client, $login) = @_; +sub login { + $Data::Dumper::Sortkeys = 1; + $Data::Dumper::Indent = 2; + + SL::LxOfficeConf->read; - die 'need client and login' unless $client && $login; + my $client = 'Unit-Tests'; + my $login = 'unittests'; package main; $::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; + $::form = Support::TestSetup->create_new_form; + $::auth = SL::Auth->new(unit_tests_database => 1); die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client); $::instance_conf = SL::InstanceConfiguration->new; @@ -40,38 +44,32 @@ sub _login { die "cannot find user $login" unless %::myconfig = $::auth->read_user(login => $login); - $::form->{login} = $login; # normaly implicit at login - die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode}); - $::instance_conf->init; - $SIG{__DIE__} = sub { Carp::confess( @_ ) } if $::lx_office_conf{debug}->{backtrace_on_die}; + return 1; } -sub login { - SL::LxOfficeConf->read; - - my $login = shift || $::lx_office_conf{testing}{login} || 'demo'; - my $client = shift || $::lx_office_conf{testing}{client} || ''; - _login($client, $login); +sub create_new_form { + my $form = Form->new(''); + $form->template(Template->new(template_config())) || die; + return $form; } -sub templates_cache_writable { - my $dir = $::lx_office_conf{paths}->{userspath} . '/templates-cache'; - return 1 if -w $dir; - - # Try actually creating a file. Due to ACLs this might be possible - # even if the basic Unix permissions and Perl's -w test say - # otherwise. - my $file = "${dir}/.writetest"; - my $out = IO::File->new($file, "w") || return 0; - $out->close; - unlink $file; - - return 1; +sub template_config { + return { + INTERPOLATE => 0, + EVAL_PERL => 0, + ABSOLUTE => 1, + CACHE_SIZE => 0, + PLUGIN_BASE => 'SL::Template::Plugin', + INCLUDE_PATH => '.:templates/webpages/', + COMPILE_DIR => 'users/templates-cache-for-tests', + COMPILE_EXT => '.tcc', + ENCODING => 'utf8', + }; } 1;