Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f2b06135

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID f2b0613517ee267a475695ee26457691ab3e48e6
  • Vorgänger 84826d21
  • Nachfolger ef8a858d

Methode zum Auflisten bekannter Hintergrundjobklassen

Unterschiede anzeigen:

SL/BackgroundJob/Base.pm
4 4

  
5 5
use parent qw(Rose::Object);
6 6

  
7
use IO::Dir;
7 8
use SL::DB::BackgroundJob;
9
use SL::System::Process;
10

  
11
sub get_known_job_classes {
12
  tie my %dir_h, 'IO::Dir', File::Spec->catdir(File::Spec->splitdir(SL::System::Process->exe_dir), 'SL', 'BackgroundJob');
13
  return sort map { s/\.pm$//; $_ } grep { m/\.pm$/ && !m/(?: ALL | Base) \.pm$/x } keys %dir_h;
14
}
8 15

  
9 16
sub create_standard_job {
10 17
  my $self_or_class = shift;
t/background_job/known_jobs.t
1
use Test::More tests => 4;
2

  
3
use lib 't';
4

  
5
use Support::TestSetup;
6

  
7
use_ok 'SL::BackgroundJob::Base';
8

  
9
my @expected_known_job_classes = qw(CleanBackgroundJobHistory CreatePeriodicInvoices SelfTest Test);
10
is_deeply [ SL::BackgroundJob::Base->get_known_job_classes ], \@expected_known_job_classes, 'get_known_job_classes called as class method';
11

  
12
my $job = new_ok 'SL::BackgroundJob::Base';
13
is_deeply [ $job->get_known_job_classes ], \@expected_known_job_classes, 'get_known_job_classes called as instance method';

Auch abrufbar als: Unified diff