3 # This file is part of Koha
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test::More tests => 1;
24 use Koha::BackgroundJobs;
25 use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
28 use t::lib::TestBuilder;
30 my $schema = Koha::Database->new->schema;
31 my $builder = t::lib::TestBuilder->new;
33 subtest 'enqueue() tests' => sub {
37 $schema->storage->txn_begin;
39 my $biblio_ids = [ 1, 2 ];
42 { Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue() }
43 'Koha::Exceptions::MissingParameter',
44 "Exception thrown if 'biblio_ids' param is missing";
46 like( "$@", qr/Missing biblio_ids parameter is mandatory/, 'Expected exception message' );
48 my $job_id = Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => $biblio_ids } );
49 my $job = Koha::BackgroundJobs->find($job_id)->_derived_class;
51 is( $job->size, scalar @{$biblio_ids}, 'Size is correct' );
52 is( $job->status, 'new', 'Initial status set correctly' );
53 is( $job->queue, 'default', 'BatchUpdateItem should use the default queue' );
55 $schema->storage->txn_rollback;