View | Details | Raw Unified | Return to bug 32013
Collapse All | Expand All

(-)a/t/db_dependent/Koha/SearchEngine/Indexer.t (-3 / +48 lines)
Lines 4-10 Link Here
4
4
5
use Modern::Perl;
5
use Modern::Perl;
6
6
7
use Test::More tests => 2;
7
use Test::More tests => 3;
8
use Test::Warn;
8
use Test::Warn;
9
9
10
use MARC::Field;
10
use MARC::Field;
Lines 17-23 use t::lib::Mocks; Link Here
17
#use C4::Biblio qw//;
17
#use C4::Biblio qw//;
18
use C4::AuthoritiesMarc qw( AddAuthority DelAuthority merge );
18
use C4::AuthoritiesMarc qw( AddAuthority DelAuthority merge );
19
use C4::Biblio qw( ModZebra ModBiblio ModBiblioMarc DelBiblio );
19
use C4::Biblio qw( ModZebra ModBiblio ModBiblioMarc DelBiblio );
20
use C4::Circulation qw( MarkIssueReturned AddReturn LostItem );
20
use C4::Circulation qw( MarkIssueReturned AddReturn LostItem AddRenewal );
21
use C4::Items qw( ModDateLastSeen ModItemTransfer );
21
use C4::Items qw( ModDateLastSeen ModItemTransfer );
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::SearchEngine::Elasticsearch;
23
use Koha::SearchEngine::Elasticsearch;
Lines 246-249 subtest 'Test indexer calls' => sub { Link Here
246
246
247
};
247
};
248
248
249
subtest 'Test AddRenewal indexer call' => sub {
250
    plan tests => 4;
251
252
    my @engines = ('Zebra');
253
    eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; };
254
    push @engines, 'Elasticsearch' unless $@;
255
    SKIP: {
256
    skip 'Elasticsearch configuration not available', 20
257
            if scalar @engines == 1;
258
    }
259
260
    for my $engine ( @engines ){
261
        t::lib::Mocks::mock_preference( 'SearchEngine', $engine );
262
        my $mock_index = Test::MockModule->new("Koha::SearchEngine::".$engine."::Indexer");
263
264
        $mock_index->mock( index_records => sub {
265
            warn $engine;
266
            my ($package, undef, undef) = caller;
267
            warn $package;
268
        });
269
270
        my $biblio = $builder->build_sample_biblio();
271
        my $patron  = $builder->build_object( { class => 'Koha::Patrons' } );
272
        my $item = $builder->build_sample_item({
273
            biblionumber => $biblio->biblionumber,
274
            onloan => '2020-02-02',
275
            datelastseen => '2020-01-01',
276
            replacementprice => 0
277
        });
278
        my $issue = $builder->build({
279
            source => 'Issue',
280
            value  => {
281
                itemnumber => $item->itemnumber
282
            }
283
        });
284
285
        warnings_are{
286
            AddRenewal($patron->borrowernumber, $item->itemnumber, $item->homebranch, undef, undef, undef, 0);
287
        } [$engine,"Koha::Item"], "index_records is called for $engine when adding a renewal (AddRenewal())";
288
        warnings_are{
289
            AddRenewal($patron->borrowernumber, $item->itemnumber, undef, undef, undef, undef, 0, 1);
290
        } undef, "index_records is not called for $engine when adding a renewal (AddRenewal()) with skip_record_index";
291
292
    }
293
};
294
249
$schema->storage->txn_rollback;
295
$schema->storage->txn_rollback;
250
- 

Return to bug 32013