From b70eb7f8b0dbe513fa9a878b5a244bf3226aa797 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 471facdf269e7d4a9223f960b8049198e85cf8ad) Signed-off-by: Lucas Gass (cherry picked from commit 544b89cf90fc57645bc7533803280b7a9712b5f6) Signed-off-by: Arthur Suzuki --- 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 9aa8d0c54f..cecb1cc609 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -779,7 +779,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 d4e99ede63..9889c343b5 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -962,7 +962,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]); @@ -970,7 +970,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]); @@ -978,7 +978,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.39.5