Lines 36-45
my $builder = t::lib::TestBuilder->new;
Link Here
|
36 |
|
36 |
|
37 |
subtest "process() tests" => sub { |
37 |
subtest "process() tests" => sub { |
38 |
|
38 |
|
39 |
plan tests => 2; |
39 |
plan tests => 3; |
40 |
|
40 |
|
41 |
$schema->storage->txn_begin; |
41 |
$schema->storage->txn_begin; |
42 |
|
42 |
|
|
|
43 |
t::lib::Mocks::mock_preference('SearchEngine', 'Elasticsearch'); |
44 |
|
43 |
my $biblio = $builder->build_sample_biblio; |
45 |
my $biblio = $builder->build_sample_biblio; |
44 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->id }); |
46 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->id }); |
45 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->id }); |
47 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->id }); |
Lines 54-64
subtest "process() tests" => sub {
Link Here
|
54 |
} |
56 |
} |
55 |
); |
57 |
); |
56 |
|
58 |
|
57 |
my $counter = 0; |
59 |
my $update_biblio_counter = 0; |
58 |
|
60 |
|
59 |
my $mock_holds_queue_job = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
61 |
my $mock_holds_queue_job = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
60 |
$mock_holds_queue_job->mock( 'enqueue', sub { |
62 |
$mock_holds_queue_job->mock( 'enqueue', sub { |
61 |
$counter++; |
63 |
$update_biblio_counter++; |
|
|
64 |
}); |
65 |
|
66 |
my $index_biblio_counter = 0; |
67 |
|
68 |
my $mock_index = Test::MockModule->new("Koha::SearchEngine::Elasticsearch::Indexer"); |
69 |
$mock_index->mock( 'index_records', sub { |
70 |
$index_biblio_counter++; |
62 |
}); |
71 |
}); |
63 |
|
72 |
|
64 |
my $job = Koha::BackgroundJob::BatchDeleteBiblio->new( |
73 |
my $job = Koha::BackgroundJob::BatchDeleteBiblio->new( |
Lines 81-87
subtest "process() tests" => sub {
Link Here
|
81 |
} |
90 |
} |
82 |
); |
91 |
); |
83 |
|
92 |
|
84 |
is( $counter, 1, 'Holds queue update is enqueued only once' ); |
93 |
is( $update_biblio_counter, 1, 'Holds queue update is enqueued only once' ); |
|
|
94 |
is( $index_biblio_counter, 1, 'Index update is enqueued only once' ); |
85 |
|
95 |
|
86 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); |
96 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); |
87 |
|
97 |
|
Lines 105-111
subtest "process() tests" => sub {
Link Here
|
105 |
} |
115 |
} |
106 |
); |
116 |
); |
107 |
|
117 |
|
108 |
is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' ); |
118 |
is( $update_biblio_counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' ); |
109 |
|
119 |
|
110 |
$schema->storage->txn_rollback; |
120 |
$schema->storage->txn_rollback; |
111 |
}; |
121 |
}; |
112 |
- |
|
|