]> wagnertech.de Git - mfinanz.git/blobdiff - SL/BackgroundJob/SelfTest.pm
Mehr als eine SelfTest-Modul prüfen
[mfinanz.git] / SL / BackgroundJob / SelfTest.pm
index aab279610a6de4902cfcc353230ec90125188454..c1c608bbf5f6f6c5140ffa366bc27a7d70bd3e08 100644 (file)
@@ -13,6 +13,8 @@ use FindBin;
 use SL::DB::AuthUser;
 use SL::DB::Default;
 use SL::Common;
 use SL::DB::AuthUser;
 use SL::DB::Default;
 use SL::Common;
+use SL::Locale::String qw(t8);
+use Carp;
 
 use Rose::Object::MakeMethods::Generic (
   array => [
 
 use Rose::Object::MakeMethods::Generic (
   array => [
@@ -46,11 +48,18 @@ sub setup {
 
 sub run {
   my $self        = shift;
 
 sub run {
   my $self        = shift;
+  my $db_obj      = shift;
+  # options
+  my $options = $db_obj->data_as_hash;
   $self->setup;
 
   return 1 unless $self->modules;
 
   $self->setup;
 
   return 1 unless $self->modules;
 
+
+  $main::lxdebug->message(0, 'optioni' . Dumper($self->modules));
   foreach my $module ($self->modules) {
   foreach my $module ($self->modules) {
+    next unless $module eq $options->{module};
+    $main::lxdebug->message(0, 'hieur' . $module);
     $self->run_module($module);
   }
 
     $self->run_module($module);
   }
 
@@ -66,6 +75,7 @@ sub run {
     $self->_send_email;
   }
 
     $self->_send_email;
   }
 
+  croak t8("Unsuccessfully executed:" . join ("\n", $self->errors)) if $self->errors;
   return 1;
 }
 
   return 1;
 }
 
@@ -92,11 +102,10 @@ sub run_module {
   } or $self->add_errors($::locale->text('Could not load class #1 (#2): "#3"', $module, $file, $@)) && return;
 
   eval {
   } or $self->add_errors($::locale->text('Could not load class #1 (#2): "#3"', $module, $file, $@)) && return;
 
   eval {
-    my $worker = $module->new;
-    $worker->tester($self->tester);
-
-    $worker->run;
-    1;
+    $self->tester->subtest($module => sub {
+      $module->new->run;
+    });
+  1
   } or $self->add_errors($::locale->text('Could not load class #1, #2', $module, $@)) && return;
 
   $self->add_full_diag($output);
   } or $self->add_errors($::locale->text('Could not load class #1, #2', $module, $@)) && return;
 
   $self->add_full_diag($output);
@@ -124,7 +133,7 @@ sub _send_email {
 
   my ($output, $content_type) = $self->_prepare_report;
 
 
   my ($output, $content_type) = $self->_prepare_report;
 
-  my $mail              = Mailer->new(charset => $::locale->is_utf8 ? 'UTF-8' : Common->DEFAULT_CHARSET );
+  my $mail              = Mailer->new;
   $mail->{from}         = $self->config->{email_from};
   $mail->{to}           = $email;
   $mail->{subject}      = $self->config->{email_subject};
   $mail->{from}         = $self->config->{email_from};
   $mail->{to}           = $email;
   $mail->{subject}      = $self->config->{email_subject};
@@ -153,8 +162,10 @@ sub _prepare_report {
   my %params = (
     SELF     => $self,
     host     => hostname,
   my %params = (
     SELF     => $self,
     host     => hostname,
-    database => $::myconfig{dbname},
+    database => $::auth->client->{dbname},
+    client   => $::auth->client->{name},
     path     => $FindBin::Bin,
     path     => $FindBin::Bin,
+    errors   => $self->errors,
   );
 
   my $output;
   );
 
   my $output;