$::lxdebug = LXDebug->new(target => LXDebug::STDERR_TARGET);
$::lxdebug->disable_sub_tracing;
$::locale = Locale->new($::lx_office_conf{system}->{language});
- $::form = Form->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;
- $::request = SL::Request->new( cgi => CGI->new({}), layout => SL::Layout::None->new );
+ $::request = Support::TestSetup->create_new_request;
die 'cannot reach auth db' unless $::auth->session_tables_present;
$SIG{__DIE__} = sub { Carp::confess( @_ ) } if $::lx_office_conf{debug}->{backtrace_on_die};
- # Always use English locale for messages from the database during
- # tests.
- my $query = qq|SET lc_messages = 'en_US.UTF-8'|;
- SL::DB->auth->dbh->do($query) || die 'Cannot set database locale to en_US.UTF-8 for auth database';
- SL::DB->client->dbh->do($query) || die 'Cannot set database locale to en_US.UTF-8 for main database';
return 1;
}
-sub templates_cache_writable {
- my $dir = $::lx_office_conf{paths}->{userspath} . '/templates-cache';
- return 1 if -w $dir;
+sub create_new_form { Form->new('') }
- # 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;
+sub create_new_request {
+ my $self = shift;
- return 1;
+ my $request = SL::Request->new(
+ cgi => CGI->new({}),
+ layout => SL::Layout::None->new,
+ @_,
+ );
+
+ $request->presenter->{template} = Template->new(template_config()) || die;
+
+ return $request;
+}
+
+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;