From: Moritz Bunkus Date: Tue, 30 Oct 2012 12:41:26 +0000 (+0100) Subject: Methode zum Auflisten bekannter Hintergrundjobklassen X-Git-Tag: release-3.0.0beta1~69 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f2b0613517ee267a475695ee26457691ab3e48e6;p=kivitendo-erp.git Methode zum Auflisten bekannter Hintergrundjobklassen --- diff --git a/SL/BackgroundJob/Base.pm b/SL/BackgroundJob/Base.pm index 27f608129..912fdc6fd 100644 --- a/SL/BackgroundJob/Base.pm +++ b/SL/BackgroundJob/Base.pm @@ -4,7 +4,14 @@ use strict; use parent qw(Rose::Object); +use IO::Dir; use SL::DB::BackgroundJob; +use SL::System::Process; + +sub get_known_job_classes { + tie my %dir_h, 'IO::Dir', File::Spec->catdir(File::Spec->splitdir(SL::System::Process->exe_dir), 'SL', 'BackgroundJob'); + return sort map { s/\.pm$//; $_ } grep { m/\.pm$/ && !m/(?: ALL | Base) \.pm$/x } keys %dir_h; +} sub create_standard_job { my $self_or_class = shift; diff --git a/t/background_job/known_jobs.t b/t/background_job/known_jobs.t new file mode 100644 index 000000000..c6b43f0e6 --- /dev/null +++ b/t/background_job/known_jobs.t @@ -0,0 +1,13 @@ +use Test::More tests => 4; + +use lib 't'; + +use Support::TestSetup; + +use_ok 'SL::BackgroundJob::Base'; + +my @expected_known_job_classes = qw(CleanBackgroundJobHistory CreatePeriodicInvoices SelfTest Test); +is_deeply [ SL::BackgroundJob::Base->get_known_job_classes ], \@expected_known_job_classes, 'get_known_job_classes called as class method'; + +my $job = new_ok 'SL::BackgroundJob::Base'; +is_deeply [ $job->get_known_job_classes ], \@expected_known_job_classes, 'get_known_job_classes called as instance method';