Martin Renvoize
ad66e214bd
This patch highlights a possible issue with the triggers.. though it may not actually matter in reality. I appear to already see test failures before this patch with a double enqueue of the rebuild for both AddIssue and AddReturn.. I couldn't spot what was causing that but whilst digging I did find another case where it could happen as highlighted here... Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
66 lines
2 KiB
Perl
Executable file
66 lines
2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
use Modern::Perl;
|
|
|
|
use Test::More tests => 1;
|
|
use Test::MockModule;
|
|
|
|
use C4::Circulation qw( AddIssue AddReturn );
|
|
|
|
use Koha::Database;
|
|
|
|
use t::lib::Mocks;
|
|
use t::lib::TestBuilder;
|
|
|
|
my $schema = Koha::Database->schema;
|
|
my $builder = t::lib::TestBuilder->new;
|
|
|
|
subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub {
|
|
|
|
plan tests => 2;
|
|
|
|
$schema->storage->txn_begin;
|
|
|
|
my $library = $builder->build_object({ class => 'Koha::Libraries' });
|
|
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
|
my $item = $builder->build_sample_item({ library => $library->id });
|
|
|
|
t::lib::Mocks::mock_userenv({ branchcode => $library->id });
|
|
t::lib::Mocks::mock_preference( 'UpdateTotalIssuesOnCirc', 1 );
|
|
|
|
my $action;
|
|
|
|
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
|
|
$mock->mock( 'enqueue', sub {
|
|
my ( $self, $args ) = @_;
|
|
my ($package, $filename, $line) = caller;
|
|
is_deeply(
|
|
$args->{biblio_ids},
|
|
[ $item->biblionumber ],
|
|
"$action triggers a holds queue update for the related biblio from $package"
|
|
);
|
|
} );
|
|
|
|
$action = 'AddIssue';
|
|
AddIssue( $patron->unblessed, $item->barcode, );
|
|
|
|
$action = 'AddReturn';
|
|
AddReturn( $item->barcode );
|
|
|
|
$schema->storage->txn_rollback;
|
|
};
|