Bug 35979: (follow-up) Add check in ->enqueue

Foundation for removing same check elsewhere (later on).

Test plan:
Run t/db_dependent/Koha/BackgroundJob/BatchUpdateBiblioHoldsQueue.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

PA amended: Fix bug # in commit message

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Marcel de Rooy 2024-04-23 12:47:11 +00:00 committed by Katrin Fischer
parent 310ba95efa
commit c317bb34c0
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 10 additions and 1 deletions

View File

@ -129,6 +129,8 @@ Enqueue the new job
sub enqueue {
my ( $self, $args ) = @_;
return if !C4::Context->preference('RealTimeHoldsQueue'); #TODO Remove check from callers
Koha::Exceptions::MissingParameter->throw(
"Missing biblio_ids parameter is mandatory")
unless exists $args->{biblio_ids};

View File

@ -32,12 +32,19 @@ my $builder = t::lib::TestBuilder->new;
subtest 'enqueue() tests' => sub {
plan tests => 5;
plan tests => 6;
$schema->storage->txn_begin;
my $biblio_ids = [ 1, 2 ];
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
is(
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => $biblio_ids } ),
undef, 'No result when pref is off'
);
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
throws_ok
{ Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue() }
'Koha::Exceptions::MissingParameter',