Projekt

Allgemein

Profil

Herunterladen (1,79 KB) Statistiken
| Zweig: | Markierung: | Revision:
1d64d7e5 Sven Schöling
package Support::TestSetup;

use strict;

use Data::Dumper;
use CGI qw( -no_xhtml);
a67ad20f Moritz Bunkus
use IO::File;
1d64d7e5 Sven Schöling
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
8317b7aa Moritz Bunkus
sub login {
51c2badb Moritz Bunkus
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 2;

8317b7aa Moritz Bunkus
SL::LxOfficeConf->read;
1d64d7e5 Sven Schöling
8317b7aa Moritz Bunkus
my $client = 'Unit-Tests';
my $login = 'unittests';
1d64d7e5 Sven Schöling
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;
ef9698b3 Moritz Bunkus
$::auth = SL::Auth->new(unit_tests_database => 1);
d31f77ea Sven Schöling
die "Cannot find client with ID or name '$client'" if !$::auth->set_client($client);

1d64d7e5 Sven Schöling
$::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
die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode});

ff049c83 Moritz Bunkus
$SIG{__DIE__} = sub { Carp::confess( @_ ) } if $::lx_office_conf{debug}->{backtrace_on_die};

1d64d7e5 Sven Schöling
return 1;
}

a67ad20f Moritz Bunkus
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;
}

1d64d7e5 Sven Schöling
1;