# roll back ES index changes.
t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
- my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
- $bgj_mock->mock( 'enqueue', undef );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
my $isbn = '0590353403';
my $title = 'Foundation';
subtest 'deletedbiblio_metadata' => sub {
plan tests => 2;
- my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
- $bgj_mock->mock( 'enqueue', undef );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
plan tests => 5;
- my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
- $bgj_mock->mock( 'enqueue', undef );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
my $deleted = C4::Biblio::DelBiblio( $biblionumber );
my $biblio = $builder->build_sample_biblio;
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
$mock->mock( 'enqueue', sub {
my ( $self, $args ) = @_;
$biblio->frameworkcode, { skip_holds_queue => 1 }
);
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ # this call should not trigger the mocked 'enqueue'
+ C4::Biblio::ModBiblio(
+ $biblio->metadata->record, $biblio->id,
+ $biblio->frameworkcode, { skip_holds_queue => 0 }
+ );
+
+ # this call shoul not trigger the mocked 'enqueue'
+ C4::Biblio::ModBiblio(
+ $biblio->metadata->record, $biblio->id,
+ $biblio->frameworkcode, { skip_holds_queue => 1 }
+ );
+
$schema->storage->txn_rollback;
};
$schema->storage->txn_begin;
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
my $biblio = $builder->build_sample_biblio;
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
C4::Biblio::DelBiblio( $biblio->id );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $biblio = $builder->build_sample_biblio;
+
+ C4::Biblio::DelBiblio( $biblio->id );
+
$schema->storage->txn_rollback;
};
t::lib::Mocks::mock_userenv({ branchcode => $library->id });
t::lib::Mocks::mock_preference( 'UpdateTotalIssuesOnCirc', 1 );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
my $action;
$action = 'AddReturn';
AddReturn( $item->barcode );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $action = 'AddIssue';
+ AddIssue( $patron->unblessed, $item->barcode, );
+
+ $action = 'AddReturn';
+ AddReturn( $item->barcode );
+
$schema->storage->txn_rollback;
};
use Koha::BackgroundJob::BatchDeleteBiblio;
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
+use t::lib::Mocks;
use t::lib::TestBuilder;
my $schema = Koha::Database->new->schema;
subtest "process() tests" => sub {
- plan tests => 1;
+ plan tests => 2;
$schema->storage->txn_begin;
}
);
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
$job->process(
{
record_ids => [ $biblio->id ],
is( $counter, 1, 'Holds queue update is enqueued only once' );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $biblio = $builder->build_sample_biblio;
+
+ $job = Koha::BackgroundJob::BatchDeleteBiblio->new(
+ {
+ status => 'new',
+ size => 1,
+ borrowernumber => undef,
+ type => 'batch_biblio_record_deletion',
+ data => encode_json {
+ record_ids => [ $biblio->id ],
+ }
+ }
+ );
+
+ $job->process(
+ {
+ record_ids => [ $biblio->id ],
+ }
+ );
+
+ is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' );
+
$schema->storage->txn_rollback;
};
use Koha::Database;
use Koha::BackgroundJob::BatchDeleteItem;
+use t::lib::Mocks;
use t::lib::TestBuilder;
my $schema = Koha::Database->new->schema;
subtest "process() tests" => sub {
- plan tests => 1;
+ plan tests => 2;
$schema->storage->txn_begin;
$counter++;
});
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
my $job = Koha::BackgroundJob::BatchDeleteItem->new(
{
status => 'new',
size => 2,
borrowernumber => undef,
- type => 'batch_biblio_record_modification',
+ type => 'batch_item_record_deletion',
data => encode_json {
record_ids => [ $item_1->id, $item_2->id ],
delete_biblios => 1,
is( $counter, 1, 'Holds queue update is enqueued only once' );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $biblio = $builder->build_sample_biblio;
+ my $item = $builder->build_sample_item({ biblionumber => $biblio->id });
+
+ $job = Koha::BackgroundJob::BatchDeleteItem->new(
+ {
+ status => 'new',
+ size => 2,
+ borrowernumber => undef,
+ type => 'batch_item_record_deletion',
+ data => encode_json {
+ record_ids => [ $item->id ],
+ delete_biblios => 1,
+ }
+ }
+ );
+
+ $job->process(
+ {
+ record_ids => [ $item->id ],
+ delete_biblios => 1,
+ }
+ );
+
+ is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' );
+
$schema->storage->txn_rollback;
};
);
} );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
+ $builder->build_object(
+ {
+ class => 'Koha::Holds',
+ value => {
+ biblionumber => $biblio->id,
+ }
+ }
+ )->fill;
+
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+ # this call shouldn't add a new test
$builder->build_object(
{
class => 'Koha::Holds',
my $biblio = $builder->build_sample_biblio;
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
$mock->mock( 'enqueue', sub {
my ( $self, $args ) = @_;
}
}
)->cancel({ skip_holds_queue => 1 });
+
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $builder->build_object(
+ {
+ class => 'Koha::Holds',
+ value => {
+ biblionumber => $biblio->id,
+ }
+ }
+ )->cancel({ skip_holds_queue => 0 });
};
$schema->storage->txn_rollback;
my $biblio = $builder->build_sample_biblio;
my $action;
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
$mock->mock( 'enqueue', sub {
my ( $self, $args ) = @_;
class => 'Koha::Holds',
value => {
biblionumber => $biblio->id,
+ found => undef,
}
}
);
);
} );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
# new item
my $item = $builder->build_sample_item({ biblionumber => $biblio->id });
# updated item
$item->set({ reserves => 1 })->store;
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+ # updated item
+ $item->set({ reserves => 0 })->store;
+
$schema->storage->txn_rollback;
};
};
);
} );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
# Revert the waiting status
C4::Reserves::RevertWaitingStatus(
{ itemnumber => $item->itemnumber } );
is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ $hold->set_waiting;
+
+ # Revert the waiting status, RealTimeHoldsQueue => shouldn't add a test
+ C4::Reserves::RevertWaitingStatus(
+ { itemnumber => $item->itemnumber } );
+
$hold->delete; # cleanup
};
);
} );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
+
+ AddReserve(
+ {
+ branchcode => $library->branchcode,
+ borrowernumber => $patron->id,
+ biblionumber => $biblio->id,
+ }
+ );
+
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
AddReserve(
{
branchcode => $library->branchcode,
);
} );
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 );
AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 );
is($hold->priority,3,'Successfully altered priority to bottom');
+ t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 );
+
+ AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 );
+
$schema->storage->txn_rollback;
};