From dceb3ededd0b9451fde598fe6a5af4f3d9a3ed22 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 13 Sep 2022 13:06:03 +0000 Subject: [PATCH] Bug 25375: Adjust tests and test itemlost, not notforloan Previous commit correctly lists Zebra availability test, but was a bad edit. This fixes the availability test to use itemlost Additiionally, tests were written before limits were agreed. Adjusted for the current settings --- Koha/SearchEngine/Elasticsearch.pm | 2 +- t/db_dependent/Koha/SearchEngine/Elasticsearch.t | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 28dd05c2f3..1fe6fb1c6f 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -781,7 +781,7 @@ sub marc_records_to_documents { my $avail_items = Koha::Items->search({ biblionumber => $biblionumber, onloan => undef, - notforloan => 0, + itemlost => 0, })->count; $record_document->{available} = $avail_items ? \1 : \0; diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index d0a11d924d..6356d9c20a 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -1006,7 +1006,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->notforloan(1)->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is "notforloan" is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is "notforloan" is available'); $item->set({ notforloan => 0, onloan => '2022-03-03' })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); @@ -1014,7 +1014,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->set({ onloan => undef, withdrawn => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is withdrawn is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is withdrawn is available'); $item->set({ withdrawn => 0, itemlost => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); @@ -1022,7 +1022,7 @@ subtest 'marc_records_to_documents should set the "available" field' => sub { $item->set({ itemlost => 0, damaged => 1 })->store(); $docs = $see->marc_records_to_documents([$marc_record_1]); - is_deeply($docs->[0]->{available}, \0, 'a biblio with one item that is damaged is not available'); + is_deeply($docs->[0]->{available}, \1, 'a biblio with one item that is damaged is available'); my $item2 = Koha::Item->new({ biblionumber => $biblionumber, -- 2.30.2